pysme.atmosphere package#
Subpackages#
Submodules#
pysme.linelist.linelist module#
Handles abstract LineList data Implementation of a specific source (e.g. Vald) should be in its own file
Uses a pandas dataframe under the hood to handle the data
- exception pysme.linelist.linelist.LineListError[source]#
Bases:
ExceptionRaise when attempt to read a line data file fails
- class pysme.linelist.linelist.LineList(linedata=None, lineformat='short', medium=None, **kwargs)[source]#
Bases:
IPersistAtomic data for a list of spectral lines
- add(species, wlcent, excit, gflog, gamrad, gamqst, gamvw)[source]#
Add a new line to the existing linelist
This replaces the underlying datastructure, i.e. any references (atomic, etc.) will not be updated
- Parameters:
species (str) – Name of the element and ionization
wlcent (float) – central wavelength
excit (float) – excitation energy in eV
gflog (float) – gf logarithm
gamrad (float) – broadening factor radiation
gamqst (float) – broadening factor qst
gamvw (float) – broadening factor van der Waals
- append(linelist: LineList)[source]#
Append a linelist to this one
Note this replaces the underlying data and sorts the lines by wavelength
- cull(minimum_depth)[source]#
Remove lines from the linelist that are weaker than the cutoff
The linedepth is an estimate and not accurate for the final stellar parameters, so final line depths might differ from depths in the linelist
- Parameters:
minimum_depth (float) – the cutoff for lines to keep them. The cutoff is specified within the normalised spectrum, so should be between 0 and 1
- Returns:
the culled linelist
- Return type:
- cull_percentage(percentage_to_keep)[source]#
Remove a percentage of the lines in the linelist, removing the weakest lines first
The linedepth is an estimate and not accurate for the final stellar parameters, so final line depths might differ from depths in the linelist
The cut is not exact in the number of lines, e.g. if there are many lines with the same depth as the cutoff, then the resulting Linelist will have slightly more than half the lines.
- Parameters:
percentage_to_keep (float) – The percentage to keep in the linelist, should be between 0 and 100
- Returns:
the culled linelist
- Return type:
- Raises:
ValueError – if the percentage is not between 0 and 100
- static parse_line_error(error_flags, values=None)[source]#
Transform Line Error flags into relative error values
- Parameters:
error_flags (list(str)) – Error Flags as defined by various references
values (float) – depths of the lines, to convert absolute to relative errors
- Returns:
errors – relative errors for each line
- Return type:
list(float)
- sort(field='wlcent', ascending=True)[source]#
Sort the linelist
The underlying datastructure will be replaced, i.e. any references will not be sorted or updated
- Parameters:
field (str, optional) – Field to use for sorting (default: “wlcent”)
ascending (bool, optional) – Wether to sort in ascending or descending order (default: True)
- Returns:
self – The sorted LineList object
- Return type:
- trim(wave_min, wave_max, vrad=None, strong_line_margin=0, strong_line_element=['H', 'Mg', 'Ca', 'Na'])[source]#
Remove lines from the linelist outside the specified wavelength range
- Parameters:
wave_min (float) – lower wavelength limit in Angstrom
wave_max (float) – upper wavelength limit in Angstrom
vrad (float, optional) – add an additional buffer on each side, corresponding to this radial velocity, by default None
strong_line_margin (float, optional) – keep the strong line in the range of wave_min-strong_line_margin, wave_max+strong_line_margin.
strong_line_element (list, optional) – The element of lines to be classified as strong lines.
- Returns:
trimmed linelist
- Return type:
- property atomic#
Data array passed to C library, should only be used for this purpose
- Type:
list(float) of size (nlines, 8)
- citation_info = ''#
- property columns#
- property extra#
additional line level information for NLTE calculation
- Type:
list(float) of size (nlines, 3)
- property index#
- lineformat#
Defines how much information is available
- Type:
{“short”, “long”}
- property lulande#
Lower and Upper Lande factors
- Type:
list(float) of size (nlines, 2)
- property medium#
- property species#
Species name of each line
- Type:
list(str) of size (nlines,)
- string_columns = ['species', 'term_lower', 'term_upper', 'reference']#
pysme.linelist.vald module#
Module for handling linelist data from the VALD3 database (http://vald.astro.uu.se/).
- exception pysme.linelist.vald.ValdError[source]#
Bases:
LineListErrorVald Data File Error
- class pysme.linelist.vald.ValdFile(filename, medium=None)[source]#
Bases:
LineListAtomic data for a list of spectral lines.
- identify_valdtype(lines)[source]#
Determines whether the file was created with extract_all, extract_stellar, or extract_element and whether it is in long or short format
- Parameters:
lines (list(str)) – file contents
- static load(filename)[source]#
Read line data file from the VALD extract stellar service
- Parameters:
filename (str) – Name of the VALD linelist file to read
- Returns:
vald – Parsed vald file
- Return type:
- static merge_list(vlist_1, vlist_2)[source]#
Combine two VALD line list. The two line list must have the same short/long format. Note that the code will use the metadata from vlist_1 as the ones in the combined line list. Lines with same ‘species’, ‘wlcent’, ‘gflog’ and ‘excit’ will be treated as duplicated lines and removed. Note: reference mismatch is known to be happen during line list merge.
- parse_header(line)[source]#
Parse header line from a VALD line data file and sets the internal parameters
- Parameters:
line (str) – header line of a vald file
- Raises:
ValdError – If the header is not understood
- parse_linedata(lines, fmt='short', valdtype='extract_stellar')[source]#
Parse line data from a VALD line data file
- Parameters:
lines (list of str) – lines of the input data file
fmt ({"short", "long"}, optional) – linelist format, short format has one line of data per spectral line, while the long format uses four lines per spectral line. The default is “short”
- Returns:
linelist – the parsed linelist
- Return type:
- parse_valdatmo(line)[source]#
Parse VALD model atmosphere line from a VALD line data file
- Parameters:
line (str) – line form the model atmosphere
- Returns:
atmo – Name of the model atmosphere
- Return type:
str
- Raises:
ValdError – If the line is not from a model atmosphere
- acknowledgement = 'This work has made use of the VALD database, operated at Uppsala University,the Institute of Astronomy RAS in Moscow, and the University of Vienna.'#
- citation_info = '\n @ARTICLE{2015PhyS...90e4005R,\n author = {{Ryabchikova}, T. and {Piskunov}, N. and {Kurucz}, R.~L. and\n {Stempels}, H.~C. and {Heiter}, U. and {Pakhomov}, Yu and\n {Barklem}, P.~S.},\n title = "{A major upgrade of the VALD database}",\n journal = {Physica Scripta},\n year = "2015",\n month = "May",\n volume = {90},\n number = {5},\n eid = {054005},\n pages = {054005},\n doi = {10.1088/0031-8949/90/5/054005},\n adsurl = {https://ui.adsabs.harvard.edu/abs/2015PhyS...90e4005R},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n }\n @ARTICLE{2000BaltA...9..590K,\n author = {{Kupka}, F.~G. and {Ryabchikova}, T.~A. and {Piskunov}, N.~E. and\n {Stempels}, H.~C. and {Weiss}, W.~W.},\n title = "{VALD-2 -- The New Vienna Atomic Line Database}",\n journal = {Baltic Astronomy},\n keywords = {ATOMIC DATA, METHODS: SPECTROSCOPIC, STARS: ABUNDANCES, STARS: CHEMICALLY PECULIAR},\n year = "2000",\n month = "Jan",\n volume = {9},\n pages = {590-594},\n doi = {10.1515/astro-2000-0420},\n adsurl = {https://ui.adsabs.harvard.edu/abs/2000BaltA...9..590K},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n }\n @ARTICLE{1999A&AS..138..119K,\n author = {{Kupka}, F. and {Piskunov}, N. and {Ryabchikova}, T.~A. and\n {Stempels}, H.~C. and {Weiss}, W.~W.},\n title = "{VALD-2: Progress of the Vienna Atomic Line Data Base}",\n journal = {\\aaps},\n keywords = {ATOMIC DATA, TECHNIQUES: SPECTROSCOPIC, SUN: ABUNDANCES, STARS: ABUNDANCES, STARS: ATMOSPHERES, STARS: CHEMICALLY PECULIAR},\n year = "1999",\n month = "Jul",\n volume = {138},\n pages = {119-133},\n doi = {10.1051/aas:1999267},\n adsurl = {https://ui.adsabs.harvard.edu/abs/1999A&AS..138..119K},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n }\n @ARTICLE{1997BaltA...6..244R,\n author = {{Ryabchikova}, T.~A. and {Piskunov}, N.~E. and {Kupka}, F. and\n {Weiss}, W.~W.},\n title = "{The Vienna Atomic Line Database : Present State and Future Development}",\n journal = {Baltic Astronomy},\n keywords = {DATABASES: ATOMIC LINE PARAMETERS, STELLAR SPECTROSCOPY},\n year = "1997",\n month = "Mar",\n volume = {6},\n pages = {244-247},\n doi = {10.1515/astro-1997-0216},\n adsurl = {https://ui.adsabs.harvard.edu/abs/1997BaltA...6..244R},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n }\n @ARTICLE{1995A&AS..112..525P,\n author = {{Piskunov}, N.~E. and {Kupka}, F. and {Ryabchikova}, T.~A. and\n {Weiss}, W.~W. and {Jeffery}, C.~S.},\n title = "{VALD: The Vienna Atomic Line Data Base.}",\n journal = {\\aaps},\n keywords = {ATOMIC DATA, STARS: ABUNDANCES, ASTRONOMICAL DATA BASES: MISCELLANEOUS},\n year = "1995",\n month = "Sep",\n volume = {112},\n pages = {525},\n adsurl = {https://ui.adsabs.harvard.edu/abs/1995A&AS..112..525P},\n adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n }\n '#
pysme.linelist.ges module#
Module for handling linelist data from the VALD3 database (http://vald.astro.uu.se/).
- exception pysme.linelist.ges.GesError[source]#
Bases:
LineListErrorVald Data File Error
- class pysme.linelist.ges.GesFile(filename, medium=None)[source]#
Bases:
LineListAtomic data for a list of spectral lines.