""" Code to derive Solar abundance

Context : SRP
Module  : SRPSolarAbundance.py
Version : 1.0.0
Author  : Stefano Covino
Date    : 26/10/2010
E-mail  : stefano.covino@brera.inaf.it
URL:    : http://www.merate.mi.astro.it/utenti/covino

Usage   : SRPSolarAbundance [-e arg1] [-h] [-v]
            -e is the element to look for, e.g. Fe
            Data are from Asplund et al. (2009, ARA&A, 47, 481)

History : (29/06/2011) First version.
"""



from optparse import OptionParser
from SRP.SRPSpectroscopy.SolarAbundance import SolarAbundance


parser = OptionParser(usage="usage: %prog [-e arg1] [-h] [-v]", version="%prog 1.0.0")
parser.add_option("-e", "--element", action="store", nargs=1, type="string", dest="element", help="Element to search for (e.g. Fe)")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Fully describe operations")
(options, args) = parser.parse_args()


if options.element:
    val = SolarAbundance(options.element)
    if val != None:
        if options.verbose:
            print "Abundance of element %s is: %.3g" % (options.element, val)
        else:
            print "%s %.3g" % (options.element, val)
    else:
        if options.verbose:
            print "Element %s not present in table or not existent" % (options.element)
else:
    parser.print_help()
