tools
- tools.nearest_index(array, target_value)[source]
Finds the index of a value in
array
that is closest totarget_value
.- Parameters:
- array
numpy.array
Target array.
- target_value
float
Target value.
- array
- Returns:
- index
int
Index of the value in
array
that is closest totarget_value
.
- index
- tools.standard_spectrum(stellar_type, semi_major_axis, reference_spectra_dir=None, stellar_radius=None, truncate_wavelength_grid=False, cutoff_thresh=13.6)[source]
Construct a dictionary containing an input spectrum for a given spectral type. The code scales this to the spectrum received at your planet provided a value for the scaled
semi_major_axis
.Spectrum of iota Horologii was kindly provided by Jorge Sanz-Forcada (priv. comm.). Spectrum of HD 108147 and HR 8799 were obtained from the X-exoplanets database and combined with PHOENIX atmosphere models for the NUV. Solar spectrum comes from the Whole Heliosphere Interval (WHI) Reference Spectra obtained from the LASP Interactive Solar Irradiance Datacenter. All other spectra are from the MUSCLES survey.
- Parameters:
- stellar_type
str
Define the stellar type. The available options are:
'mid-A'
(based on HR 8799)'early-F'
(based on WASP-17)'late-F'
(based on HD 108147)'early-G'
(based on HD 149026)'solar'
(based on the Sun)'young-sun'
(based on iota Horologii)'late-G'
(based on TOI-193)'active-K'
(based on epsilon Eridanii)'early-K'
(based on HD 97658)'late-k'
(based on WASP-43)'active-M'
(based on Proxima Centauri)'early-M'
(based on GJ 436)'late-M'
(based on TRAPPIST-1)
- semi_major_axis
float
Semi-major axis of the planet in units of stellar radii. The code first converts the MUSCLES spectrum to what it would be at R_star;
semi_major_axis
is needed to get the spectrum at the planet.- reference_spectra_dir
str
, optional Path to the directory with the MUSCLES data. Default value is defined by the environment variable
$PWINDS_REFSPEC_DIR
.- stellar_radius
float
, optional Stellar radius in unit of solar radii. Setting a value for this parameter allows the spectrum to be scaled to an arbitrary stellar radius instead of the radius of the MUSCLES star. If
None
, then the scaling is performed using the radius of the MUSCLES star. Default isNone
.- truncate_wavelength_grid
bool
, optional If
True
, will only return the spectrum with energy > 13.6 eV. This may be useful for computational expediency. If False, returns the whole spectrum. Default isFalse
.- cutoff_thresh
float
, optional If
truncate_wavelength_grid
is set toTrue
, then the truncation happens for energies whose value in eV is above this threshold, also in eV. Default is13.6
.
- stellar_type
- Returns:
- spectrum
dict
Spectrum dictionary with entries for the wavelength and flux, and their units.
- spectrum
- tools.generate_muscles_spectrum(host_star_name, semi_major_axis, reference_spectra_dir=None, stellar_radius=None, truncate_wavelength_grid=False, cutoff_thresh=13.6)[source]
Construct a dictionary containing an input spectrum from a MUSCLES spectrum. MUSCLES reports spectra as observed at Earth, the code scales this to the spectrum received at your planet provided a value for the scaled
semi-major-axis
.- Parameters:
- host_star_name
str
Name of the MUSCLES stellar spectrum you want to use. Must be one of: [‘gj176’, ‘gj436’, ‘gj551’, ‘gj581’, ‘gj667c’, ‘gj832’, ‘gj876’, ‘gj1214’, ‘hd40307’, ‘hd85512’, ‘hd97658’, ‘v-eps-eri’, ‘gj1132’, ‘hat-p-12’, ‘hat-p-26’, ‘hd-149026’, ‘l-98-59’, ‘l-678-39’, ‘l-980-5’, ‘lhs-2686’, ‘lp-791-18’, ‘toi-193’, ‘trappist-1’, ‘wasp-17’, ‘wasp-43’, ‘wasp-77a’, ‘wasp-127’].
- semi_major_axis
float
Semi-major axis of the planet in units of stellar radii. The code first converts the MUSCLES spectrum to what it would be at R_star;
semi_major_axis
is needed to get the spectrum at the planet.- reference_spectra_dir
str
, optional Path to the directory with the reference spectra. Default value is defined by the environment variable
$PWINDS_REFSPEC_DIR
.- stellar_radius
float
, optional Stellar radius in unit of solar radii. Setting a value for this parameter allows the spectrum to be scaled to an arbitrary stellar radius instead of the radius of the MUSCLES star. If
None
, then the scaling is performed using the radius of the MUSCLES star. Default isNone
.- truncate_wavelength_grid
bool
, optional If
True
, will only return the spectrum with energy > 13.6 eV. This may be useful for computational expediency. If False, returns the whole spectrum. Default isFalse
.- cutoff_thresh
float
, optional If
truncate_wavelength_grid
is set toTrue
, then the truncation happens for energies whose value in eV is above this threshold, also in eV. Default is13.6
.
- host_star_name
- Returns:
- spectrum
dict
Spectrum dictionary with entries for the wavelength and flux, and their units.
- spectrum
- tools.make_spectrum_from_file(filename, units, path='', skiprows=0, scale_flux=1.0, star_distance=None, semi_major_axis=None)[source]
Construct a dictionary containing an input spectrum from a text file. The input file must have two or more columns, in which the first is the wavelength or frequency bin center and the second is the flux per bin of wavelength or frequency. The code automatically figures out if the input spectra are binned in wavelength or frequency based on the units the user passes.
- Parameters:
- filename
str
Name of the file containing the spectrum data.
- units
dict
Units of the spectrum. This dictionary must have the entries
'wavelength'
and'flux'
, or'frequency'
and'flux'
. The units must be set inastropy.units
.- path
str
, optional Path to the spectrum data file.
- skiprows
int
, optional Number of rows to skip corresponding to the header of the input text file.
- scale_flux
float
, optional Scaling factor for flux. Default value is 1.0 (no scaling).
- star_distance
float
orNone
, optional Distance to star in unit of parsec. This is used to scale the flux as observed from Earth to the semi-major axis of the planet. If
None
, no scaling is applied. If notNone
, then a value``semi_major_axis`` must be provided as well. Default isNone
.- semi_major_axis
float
orNone
, optional Semi-major axis of the planet in unit of au. This is used to scale the flux as observed from Earth to the semi-major axis of the planet. Notice that this parameter is different from the
generate_muscles_spectrum()
function, which uses the semi-major axis in unit of stellar radii. IfNone
, no scaling is applied. If notNone
, then a value``star_distance`` must be provided as well. Default isNone
.
- filename
- Returns:
- spectrum
dict
Spectrum dictionary with entries for the wavelength and flux, and their units.
- spectrum