""" Code to convert wavelengths from air to vacuum and viceversa.

Context : SRP
Module  : SRPAirVacuum.py
Version : 1.0.3
Author  : Stefano Covino
Date    : 16/03/2011
E-mail  : stefano.covino@brera.inaf.it
URL:    : http://www.merate.mi.astro.it/utenti/covino
Purpose : Convert wavelengths from air to vacuum and viceversa.

Usage   : SRPAirVacuum -A arg1 / -V arg1  [-h] [-v]
            -A Air wavelength (Angstrom)
            -V Vacuum wavelength (Angstrom)
 

History : (30/05/2010) First version.
        : (22/06/2010) Minor improvement.
        : (17/11/2010) Better importing style.
        : (16/08/2011) Better cosmetics.
"""

from optparse import OptionParser
from SRP.SRPSpectroscopy.Air2Vacuum import Air2Vacuum
from SRP.SRPSpectroscopy.Vacuum2Air import Vacuum2Air


parser = OptionParser(usage="usage: %prog -A arg1 / -V arg1  [-h] [-v]", version="%prog 1.0.3")
parser.add_option("-A", "--air", action="store", nargs=1, type="float", dest="air", help="Air wavelength (Angstrom)")
parser.add_option("-V", "--vac", action="store", nargs=1, type="float", dest="vac", help="Vacuum wavelength (Angstrom)")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="fully describe operations")
(options, args) = parser.parse_args()


if (options.air <= 0.0 and options.vac <= 0.0) or (options.air > 0.0 and options.vac > 0.0):
    parser.print_help()
else:
    if options.air > 0.0:
        vacw = Air2Vacuum(options.air)
        if options.verbose:
            print "Vacuum wavelength: %.3f, Air wavelength: %.3f" % (options.air, vacw)
        else:
            print "%.3f %.3f" % (options.air, vacw)
    elif options.vac > 0.0:
        airw = Vacuum2Air(options.vac)
        if options.verbose:
            print "Air wavelength: %.3f, Vacuum wavelength: %.3f" % (options.vac, airw)       
        else:
            print "%.3f %.3f" % (options.vac, airw)
            
            
