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

Context : SRP
Module  : SRPAirVacuum.py
Version : 1.1.1
Author  : Stefano Covino
Date    : 26/05/2017
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.
        : (23/07/2015) python3 porting.
        : (26/05/2017) Minor update.
"""

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.1.1")
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 == None and options.vac == None:
    parser.print_help()
else:
    if options.air != None:
        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))
        else:
            print("Incorrect wavelength.")
    #
    if options.vac != None:
        if 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))
        else:
            print("Incorrect wavelength.")
