ObservationModel#
- class VSPEC.main.ObservationModel(params: InternalParameters)#
Bases:
object
Main class that stores the information of this simulation.
- Parameters:
params (VSPEC.params.InternalParameters) – The global parameters describing the VSPEC simulation.
- params#
The parameters for this simulation.
- Type:
VSPEC.params.InternalParameters
- star#
The variable host star.
- Type:
VSPEC.variable_star_model.Star or None
- rng#
A psudo-random number generator to be used in the simulation.
- Type:
Attributes Summary
The directory structure for the VSPEC run.
The wavelength axis of the observation.
Methods Summary
Build the file system for this run.
Use the PSG GlobES API to construct a planetary phase curve.
Integrate our stellar model with PSG to produce a variable host + planet simulation.
Build a variable star model based on user-specified parameters.
calculate_composite_stellar_spectrum
(...[, ...])Compute the stellar spectrum given an integration window and the side of the star facing the observer.
calculate_noise
(N1, N2, N1_frac, ...)Calculate the noise in our model based on the noise output from PSG.
calculate_reflected_spectra
(N1, N2, N1_frac, ...)Calculate the reflected spectrum based on PSG output and our own stellar model.
check_config
(cfg_from_psg)Validate the config file recieved from PSG to ensure that the parameters sent are the parameters used in the simulation.
Check that PSG is configured correctly.
from_yaml
(config_path)Initialize a VSPEC run from a YAML file.
get_layer_data
(N1, N2, N1_frac)Interpolate between two PSG .lyr files.
get_model_spectrum
(teff)Get the interpolated spectrum given an effective temperature.
Get an object to store and compute the geometric observational parameters for this simulation.
get_observation_plan
(observation_parameters)Compute the locations and geometries of each object in this simulation.
get_thermal_spectrum
(N1, N2, N1_frac, pl_frac)Get the thermal emission spectra calculated by PSG
get_transit
(N1, N2, N1_frac, phase, orbit_radius)Get the transit spectra calculated by PSG
Load a GridSpec instance.
run_psg
(path_dict, i, has_star)Run PSG
Upload the non-changing parts of the PSG config.
update_config
(phase, orbit_radius_coeff, ...)Update the PSG config with time-dependent values.
upload_gcm
([obstime, update])Upload GCM file to PSG
warm_up_star
([spot_warmup_time, ...])"Warm up" the star.
wrap_iterator
(iterator, **kwargs)Wrapper for iterators so that tqdm can be used only if self.verbose > 0
Attributes Documentation
- directories#
The directory structure for the VSPEC run.
- Returns:
Keys represent the identifiers of directories, and the values are pathlib.Path objects.
- Return type:
- wl#
The wavelength axis of the observation.
- Returns:
wl – The wavelength axis.
- Return type:
Methods Documentation
- build_directories()#
Build the file system for this run.
- build_planet()#
Use the PSG GlobES API to construct a planetary phase curve. Follow steps in original PlanetBuilder.py file
- build_spectra()#
Integrate our stellar model with PSG to produce a variable host + planet simulation. Follow the original Build_Spectra.py file to construct phase curve outputs.
- build_star()#
Build a variable star model based on user-specified parameters.
- calculate_composite_stellar_spectrum(sub_obs_coords, tstart, tfinish, granulation_fraction: float = 0.0, orbit_radius: ~astropy.units.quantity.Quantity = <Quantity 1. AU>, planet_radius: ~astropy.units.quantity.Quantity = <Quantity 1. earthRad>, phase: ~astropy.units.quantity.Quantity = <Quantity 90. deg>, inclination: ~astropy.units.quantity.Quantity = <Quantity 0. deg>, transit_depth: ~numpy.ndarray = 0)#
Compute the stellar spectrum given an integration window and the side of the star facing the observer.
- Parameters:
sub_obs_coords (dict) – A dictionary containing stellar sub-observer coordinates.
tstart (astropy.units.Quantity [time]) – The starting time of the observation.
tfinish (astropy.units.Quantity [time]) – The ending time of the observation.
granulation_fraction (float) – The fraction of the quiet photosphere that has a lower Teff due to granulation
- Returns:
base_wave (astropy.units.Quantity [wavelength]) – The wavelength coordinates of the stellar spectrum.
base_flux (astropy.units.Quantity [flambda]) – The composite stellar flux
- Raises:
ValueError – If wavenelength coordinates do not match.
- calculate_noise(N1: int, N2: int, N1_frac: float, time_scale_factor: float, cmb_flux)#
Calculate the noise in our model based on the noise output from PSG.
- Parameters:
N1 (int) – The planet index immediately before the current epoch.
N2 (int) – The planet index immediately after the current epoch.
N1_frac (float) – The fraction of the N1 epoch to use in interpolation.
time_scale_factor (float) – A scaling factor to apply to the noise at the end of the calculation. This is 1 if the planet and star sampling has the same cadence. Otherwise, it is usually sqrt(self.planet_phase_binning).
cmb_flux (astropy.units.Quantity [flambda]) – The flux of the combined spectrum.
- Returns:
noise – The noise in our model.
- Return type:
astropy.units.Quantity [flambda]
- Raises:
ValueError – If the PSG flux unit code is not recognized.
ValueError – If the wavelength coordinates from the loaded spectra do not match.
-
calculate_reflected_spectra(N1: int, N2: int, N1_frac: float, sub_planet_flux:
astropy.units.Quantity
, pl_frac: float)astropy.units.Quantity
# Calculate the reflected spectrum based on PSG output and our own stellar model. We scale the reflected spectra from PSG to our model.
- Parameters:
N1 (int) – The planet index immediately before the current epoch.
N2 (int) – The planet index immediately after the current epoch.
N1_frac (float) – The fraction of the N1 epoch to use in interpolation.
sub_planet_flux (astropy.units.Quantity) – Stellar flux to scale to.
pl_frac (float) – The fraction of the planet that is visible (in case of eclipse)
- Returns:
reflected_flux – Reflected flux.
- Return type:
- Raises:
ValueError – If the PSG flux unit code is not recognized.
ValueError – If the wavelength coordinates from the loaded spectra do not match.
- check_config(cfg_from_psg: PyConfig)#
Validate the config file recieved from PSG to ensure that the parameters sent are the parameters used in the simulation.
- Parameters:
cfg_from_psg (pypsg.PyConfig) – The config file recieved from PSG.
- Raises:
RuntimeError – If the config recieved does not match the config sent.
- check_psg()#
Check that PSG is configured correctly.
- Raises:
RuntimeError – If a local PSG container is specified but the port is not in use (i.e. PSG is not running).
- Warns:
RuntimeWarning – If calling the online PSG API, but no API key is specified.
- classmethod from_yaml(config_path: Path)#
Initialize a VSPEC run from a YAML file.
- Parameters:
config_path (pathlib.path) – The path to the YAML file.
- get_layer_data(N1: int, N2: int, N1_frac: float) PyLyr #
Interpolate between two PSG .lyr files.
- Parameters:
- Returns:
A DataFrame containing the interpolated layer data.
- Return type:
- Raises:
ValueError – If the layer file columns of layer numbers do not match.
-
get_model_spectrum(teff:
astropy.units.Quantity
)astropy.units.Quantity
# Get the interpolated spectrum given an effective temperature.
- Parameters:
teff (astropy.units.Quantity) – The effective temperature
- Returns:
The flux of the spectrum.
- Return type:
Notes
This function applies the solid angle correction.
- get_observation_parameters() SystemGeometry #
Get an object to store and compute the geometric observational parameters for this simulation.
- Returns:
An bbject storing the geometric observation parameters of this simulation.
- Return type:
-
get_observation_plan(observation_parameters: SystemGeometry, planet=False)
astropy.table.QTable
# Compute the locations and geometries of each object in this simulation.
- Parameters:
observation_parameters (VSPEC.geometry.SystemGeometry) – An object containting the system geometry.
planet (bool) – If true, use the planet phase binning parameter to compute the number of steps.
- Returns:
A table containing the observation plan.
- Return type:
QTable
- get_thermal_spectrum(N1: int, N2: int, N1_frac: float, pl_frac: float)#
Get the thermal emission spectra calculated by PSG
- Parameters:
- Returns:
wavelength (astropy.units.Quantity [wavelength]) – The wavelength of the thermal emission.
flux (astropy.units.Quantity [flambda]) – The flux of the thermal emission.
- Raises:
ValueError – If the PSG flux unit code is not recognized.
ValueError – If the wavelength coordinates from the loaded spectra do not match.
-
get_transit(N1: int, N2: int, N1_frac: float, phase:
astropy.units.Quantity
, orbit_radius:astropy.units.Quantity
) Tuple[astropy.units.Quantity
, ndarray] # Get the transit spectra calculated by PSG
- Parameters:
- Returns:
wavelength (astropy.units.Quantity) – The wavelength of the thermal emission.
flux (np.ndarray) – The dimensionless fraction of light blocked by the planet at each wavelength.
- Raises:
ValueError – If the PSG flux unit code is not recognized.
ValueError – If the wavelength coordinates from the loaded spectra do not match.
- load_spectra()#
Load a GridSpec instance.
- Returns:
The spectal grid object to draw stellar spectra from.
- Return type:
VSPEC.spectra.GridSpec
- run_psg(path_dict: dict, i: int, has_star: bool)#
Run PSG
- Parameters:
path_dict (dict) – A dictionary that determines where each downloaded file gets written to.
- set_static_config()#
Upload the non-changing parts of the PSG config.
-
update_config(phase:
astropy.units.Quantity
, orbit_radius_coeff: float, sub_stellar_lon:astropy.units.Quantity
, sub_stellar_lat:astropy.units.Quantity
, pl_sub_obs_lon:astropy.units.Quantity
, pl_sub_obs_lat:astropy.units.Quantity
, include_star: bool)# Update the PSG config with time-dependent values.
- Parameters:
phase (astropy.units.Quantity) – The phase of the planet
orbit_radius_coeff (float) – The ratio between the current planet-host difference and the semimajor axis
sub_stellar_lon (astropy.units.Quantity) – The sub-stellar longitude of the planet.
sub_stellar_lat (astropy.units.Quantity) – The sub-stellar latitude of the planet.
pl_sub_obs_lon (astropy.units.Quantity) – The sub-observer longitude of the planet.
pl_sub_obs_lat (astropy.units.Quantity) – The sub-observer latitude of the planet.
include_star (bool) – Whether to include the star in the simulation.
- upload_gcm(obstime: ~astropy.units.quantity.Quantity = <Quantity 0. s>, update=False)#
Upload GCM file to PSG
- Parameters:
is_ncdf (bool) – Whether or not to use a netCDF file for the GCM
obstime (astropy.units.Quantity, default=0*u.s) – The time since the start of the observation.
update (bool) – Whether to use the ‘upd’ keyword rather than ‘set’
- warm_up_star(spot_warmup_time: ~astropy.units.quantity.Quantity = <Quantity 0. d>, facula_warmup_time: ~astropy.units.quantity.Quantity = <Quantity 0. d>)#
“Warm up” the star. Generate spots, faculae, and/or flares for the star. The goal is to approach growth-decay equillibrium, something that is hard to do with a purely “hot star” method (like VPSEC.variable_star_model.Star.generate_mature_spots).
- Parameters:
spot_warm_up_time (astropy.units.Quantity [time], default=0*u.day) – The time to run to approach spot equillibrium.
facula_warmup_time (astropy.units.Quantity [time], default=0*u.hr) – The time to run to approach faculae equillibrium.