API documentation#
Broadening#
File to calculate the intensity map and broadening said map. and the velocity profile.
- scope.broadening.I_darken(lon, lat, epsilon)[source]#
takes lon and lat in. spits out the value on the limb-darkened disk.
Inputs#
- lon:
longitude in radians
- lat:
latitude in radians
- epsilon:
limb-darkening coefficient. should be between 0 and 1.
Outputs#
- res1:
the intensity at that point on the disk.
- scope.broadening.I_darken_disk(x, y, epsilon)[source]#
takes x and y in. spits out the value on the limb-darkened disk.
Inputs#
- x:
x position on the disk
- y:
y position on the disk
- epsilon:
limb-darkening coefficient. should be between 0 and 1.
Outputs#
- res1:
the intensity at that point on the disk.
- scope.broadening.I_darken_disk_integrated(x, y, epsilon)[source]#
takes x and y in. spits out the value on the limb-darkened disk.
Inputs#
- x:
x position on the disk
- y:
y position on the disk
- epsilon:
limb-darkening coefficient. should be between 0 and 1.
Outputs#
- res1:
the intensity at that point on the disk.
- exception scope.broadening.RotationalBroadeningError[source]#
Bases:
ExceptionCustom exception for rotational broadening calculation errors.
- scope.broadening.broaden_spectrum(wav, spectrum_flux, epsilon, n_samples=10000, vl=5, model='igrins')[source]#
Broadens a spectrum by a line profile.
- Parameters:
wl_model (array-like) – The wavelength model.
spectrum_flux (array-like) – The flux of the spectrum.
epsilon (float) – The spot contrast.
n_samples (int) – The number of samples to use in the integration.
vl (float) – The rotational velocity of the object.
- Returns:
The broadened spectrum.
- Return type:
array-like
- scope.broadening.calculate_velocity_step(wavelengths: Array) float[source]#
Calculate the velocity step size from wavelength array.
- scope.broadening.convert_lon_to_vz(lon, R, sigma_jet, amp_jet, mu_jet)[source]#
Converts longitude to a vz
- Parameters:
lon (float) – The longitude.
R (float) – The radius of the planet.
sigma_jet (float) – The width of the jet.
amp_jet (float) – The amplitude of the jet.
mu_jet (float) – The center of the jet.
- scope.broadening.convert_vz_to_lon(vz, R, sigma_jet, amp_jet, mu_jet)[source]#
Converts vz to a longitude.
- Parameters:
vz (float) – The velocity along the line of sight.
R (float) – The radius of the star.
sigma_jet (float) – The width of the jet.
amp_jet (float) – The amplitude of the jet.
mu_jet (float) – The center of the jet.
- scope.broadening.fix_nan_result(res)[source]#
Fixes the result of a calculation that has NaNs in it.
- Parameters:
res (float) – The result of a calculation.
- Returns:
The result of the calculation with NaNs fixed.
- Return type:
float
- scope.broadening.gaussian_term(lon, lat, offset, sigma, amp)[source]#
the gaussian term.
Inputs#
- lat:
latitude in radians
- lon:
longitude in radians
- offset:
the offset of the gaussian
- sigma:
the sigma of the gaussian
- amp:
the amplitude of the gaussian
Outputs#
- res1:
the gaussian term.
- scope.broadening.gaussian_term_1d(lat, offset, sigma, amp)[source]#
the gaussian term. this time there’s no longitude dependence!
Inputs#
- lat:
latitude in radians
- lon:
longitude in radians
- offset:
the offset of the gaussian
- sigma:
the sigma of the gaussian
- amp:
the amplitude of the gaussian
Outputs#
- res1:
the gaussian term.
- scope.broadening.get_rot_ker(v_sin_i: float | ndarray | Array, wavelengths: ndarray | Array | list, observation: str = 'emission') Array[source]#
Safe wrapper for get_rotational_kernel with automatic array conversion.
- Args:
v_sin_i: Projected rotational velocity in km/s wavelengths: Array of wavelength points observation: Type of observation, either “emission” or “transmission”
- Returns:
Normalized kernel array
- Raises:
RotationalBroadeningError: If calculation fails or if invalid observation type
- scope.broadening.get_rotational_kernel(v_sin_i: float | Array, wavelengths: Array, is_transmission: bool = False) Array[source]#
Calculate rotational broadening kernel using JAX.
- Args:
v_sin_i: Projected rotational velocity in km/s wavelengths: Array of wavelength points (must be sorted) is_transmission: If True, use transmission profile (1/pi/sqrt(1-x²)),
else emission profile (sqrt(1-x²))
- Returns:
Normalized rotational broadening kernel
- scope.broadening.get_theta(lat, lon)[source]#
Converts latitude and longitude to Theta, the angular distance across the disk.
Inputs#
- lat:
latitude in radians
- lon:
longitude in radians
Outputs#
- res1:
the angular distance across the disk.
- scope.broadening.line_profile_no_exponent(epsilon, dRV, n_samples=10000, model='igrins', vl=5)[source]#
calculates the line profile for a given epsilon and dRV. this is the version without the exponent.
- Parameters:
epsilon (float) – The limb-darkening coefficient.
dRV (float) – The width of the line profile.
n_samples (int) – The number of samples to use in the integration.
model (str)
vl (float) – The equatorial rotational velocity of the star.
- Returns:
big_resoluts – The line profile.
- Return type:
np.ndarray
- scope.broadening.numerator_integral_no_sigma(vz, epsilon, n_samples=100)[source]#
calculates the numerator of the line profile. this is the version without the exponent.
- Parameters:
vz (float) – The velocity of the star.
epsilon (float) – The limb-darkening coefficient.
n_samples (int) – The number of samples to use in the integration.
- Returns:
total_res – The numerator of the line profile.
- Return type:
float
- scope.broadening.numerator_no_sigma(vz, epsilon, n_samples=100)[source]#
calculates the numerator of the line profile. this is the version without the exponent.
- Parameters:
vz (float) – The velocity of the star.
epsilon (float) – The limb-darkening coefficient.
n_samples (int) – The number of samples to use in the integration.
- Returns:
res1 – The numerator of the line profile.
- Return type:
float
Fitting#
Module to fit (simulated) HRCCS data with emcee, using MPI (multi-core). The fit is with respect to the velocity parameters (Kp, Vsys) and the scale factor.
- scope.emcee_fit_hires.log_prob(x, best_kp, wl_cube_model, Fp_conv, n_order, n_exposure, n_pixel, A_noplanet, star, n_princ_comp, flux_cube, wl_model, Fstar_conv, Rp_solar, Rstar, phases, do_pca)[source]#
just add the log likelihood and the log prob.
Inputs#
- x:
(array) array of parameters
- best_kp:
(float) best-fit planet velocity
- wl_cube_model:
(array) wavelength cube model
- Fp_conv:
(array) convolved planet spectrum
- n_order:
(int) number of orders
- n_exposure:
(int) number of exposures
- n_pixel:
(int) number of pixels
- A_noplanet:
(array) no planet spectrum
- star:
(array) stellar spectrum
- n_princ_comp:
(int) number of principal components
- flux_cube:
(array) flux cube
- wl_model:
(array) wavelength model
- Fstar_conv:
(array) convolved stellar spectrum
- Rp_solar:
(float) planet radius in solar radii
- Rstar:
(float) stellar radius
- phases:
(array) array of phases
- do_pca:
(bool) whether to do PCA
Outputs#
- log_prob:
(float) log probability.
- scope.emcee_fit_hires.prior(x, best_kp)[source]#
Prior on the parameters. Only uniform!
Inputs#
- x:
(array) array of parameters
- best_kp:
(float) best-fit planet velocity
Outputs#
- prior_val:
(float) log prior value.
- scope.emcee_fit_hires.sample(nchains, nsample, A_noplanet, Fp_conv, wl_cube_model, n_order, n_exposure, n_pixel, star, n_princ_comp, flux_cube, wl_model, Fstar_conv, Rp_solar, Rstar, phases, seed=42, do_pca=True, best_kp=192.06, best_vsys=0.0, best_log_scale=0.0, multicore=True, walker_dispersion=0.01)[source]#
Samples the likelihood. right now, it needs an instantiated best-fit value.
Inputs#
- nchains:
(int) number of chains
- nsample:
(int) number of samples
- A_noplanet:
(array) array of the no planet spectrum
- Fp_conv:
(array) array of the stellar spectrum
- wl_cube_model:
(array) wavelength cube model
- n_order:
(int) number of orders
- n_exposure:
(int) number of exposures
- n_pixel:
(int) number of pixels
- star:
(array) stellar spectrum
- n_princ_comp:
(int) number of principal components
- flux_cube:
(array) flux cube
- wl_model:
(array) wavelength model
- Fstar_conv:
(array) convolved stellar spectrum
- Rp_solar:
(float) planet radius in solar radii
- Rstar:
(float) stellar radius
- phases:
(array) array of phases
- do_pca:
(bool) whether to do PCA
- best_kp:
(float) best-fit planet velocity
- best_vsys:
(float) best-fit system velocity
- best_log_scale:
(float) best-fit log scale
- walker_dispersion:
(float) scale by which to disperse the walkers at initialization
Outputs#
- sampler:
(emcee.EnsembleSampler) the sampler object.
Utility functions#
Utility functions for simulating HRCCS data.
- scope.utils.add_blaze_function(wl_cube_model, flux_cube_model, n_order, n_exp, instrument='IGRINS')[source]#
Adds the blaze function to the model.
Inputs#
- wl_cube_model:
(array) wavelength cube model
- flux_cube_model:
(array) flux cube model
- n_order:
(int) number of orders
- n_exp:
(int) number of exposures
Outputs#
- flux_cube_model:
(array) flux cube model with blaze function included.
- scope.utils.calc_doppler_shift(eval_wave, template_wave, template_flux, v)[source]#
Doppler shifts a spectrum. Evaluates the flux at a different grid. convention: positive v is redshift.
Inputs#
- wl:
wavelength grid
- flux:
flux grid
- v:
velocity. Must be in m/s.
Outputs#
- flux_shifted:
shifted flux grid
- scope.utils.calc_limb_darkening(u1, u2, a, b, Rstar, ph, LD)[source]#
calculates limb darkening as a function of phase
- U1:
(float) linear limb darkening coefficient
- U2:
(float) quadratic limb darkening coefficient
- A:
(float) semi-major axis in meters
- B:
(float) impact parameter
- Rstar:
(float) stellar radius in solar radii
- Ph:
(array) phase
- LD:
(bool) whether to apply limb darkening
- scope.utils.calc_rvs(v_sys, v_sys_measured, Kp, Kstar, phases)[source]#
calculate radial velocities of planet and star.
Inputs#
- v_sys: float
Systemic velocity of the system. Measured in km/s
- v_sys_measured: float
Measured systemic velocity of the system. Measured in km/s
- Kp: float
Planet semi-amplitude. Measured in km/s
- Kstar: float
Star semi-amplitude. Measured in km/s
- phases: array
Orbital phases of the system. Measured in radians.
- returns:
rv_planet (array) – Radial velocities of the planet. Measured in m/s
rv_star (array) – Radial velocities of the star. Measured in m/s
- scope.utils.change_wavelength_solution(wl_cube_model, flux_cube_model, doppler_shifts)[source]#
Takes a finalized wavelength cube and makes the wavelength solution for each exposure just slightly wrong.
for now, it just shifts things. doesn’t stretch.
this basically interpolates the flux array onto a different wavelength grid. don’t worry about the edge, it’ll be trimmed?
for now: uses prescribed pixel shifts!
Inputs#
- wl_cube_model:
(array) wavelength grid of simulated data!
- flux_cube_model:
(array) flux cube for simulated data!
- pixel_shifts:
(array) N_exp long array of number of wavelength pixels to shift. Convention: positive number is redshift (shift to larger pixels). shifts must be in km/s.
- scope.utils.detrend_cube(cube, n_order, n_exp, blaze=False)[source]#
Detrends the cube by dividing each order by its maximum value.
Inputs#
- cube:
(array) flux cube
- n_order:
(int) number of orders
- n_exp:
(int) number of exposures
Outputs#
- cube:
(array) detrended flux cube
- scope.utils.doppler_shift_planet_star(model_flux_cube, n_exposure, phases, rv_planet, rv_star, wlgrid_order, wl_model, Fp_conv, Rp_solar, Fstar_conv, Rstar, u1, u2, a, b, LD, scale, star, observation, reprocessing=False)[source]#
- scope.utils.get_instrument_kernel(instrument, model_resolution=250000, kernel_size=41)[source]#
Creates a Gaussian kernel for instrument response using an alternative implementation.
- Parameters:
resolution_ratio (float) – Ratio of resolutions (default: 250000/45000)
kernel_size (int) – Size of the kernel (must be odd, default: 41)
- Returns:
Normalized Gaussian kernel
- Return type:
numpy.ndarray
- scope.utils.get_star_spline(star_wave, star_flux, planet_wave, yker, smooth=True)[source]#
Calculates the stellar spline using an alternative implementation with linear interpolation instead of B-splines.
Inputs#
- star_wave: array
Wavelengths of the star. Measured in microns.
- star_flux: array
Fluxes of the star. Measured in W/m^2/micron.
- planet_wave: array
Wavelengths of the planet. Measured in microns.
- yker: array
Convolution kernel.
- smooth: bool
Whether or not to smooth the star spectrum. Default is True.
- returns:
star_flux – Interpolated and processed stellar fluxes. Measured in W/m^2/micron.
- rtype:
array
- scope.utils.perform_pca(input_matrix, n_princ_comp, pca_removal='subtract')[source]#
Perform PCA using SVD and remove principal components via subtraction or division.
- Parameters:
input_matrix (ndarray) – 2D array where rows are observations and columns are features.
n_princ_comp (int) – Number of principal components to retain.
mode (str, optional) – Method for removing PCA fit, either “subtract” or “divide”. Default is “subtract”.
- Returns:
corrected_data (ndarray) – The input matrix with PCA components removed.
A_pca_fit (ndarray) – The PCA reconstruction used for removal.
- scope.utils.save_data(outdir, run_name, flux_cube, flux_cube_nopca, A_noplanet, just_tellurics)[source]#
Saves data to a pickle file.
Inputs#
- outdir:
(str) output directory
- run_name:
(str) name of the run
- data:
(dict) data to save
Main module for running a simulation of the HRCCS data. This module contains the main functions for simulating the data and calculating the log likelihood and cross-correlation function of the data given the model parameters.
- scope.run_simulation.calc_log_likelihood(v_sys, Kp, scale, wlgrid, wl_model, Fp_conv, Fstar_conv, flux_cube, n_order, n_exposure, n_pixel, phases, Rp_solar, Rstar, rv_semiamp_orbit, A_noplanet, do_pca=True, n_princ_comp=4, star=False, observation='emission', a=1, u1=0.3, u2=0.3, LD=True, b=0.0, v_sys_measured=0.0, pca_removal='subtract')[source]#
Calculates the log likelihood and cross-correlation function of the data given the model parameters.
Inputs#
- v_sys:
float Systemic velocity of the system in m/s :Kp: float Planet semi-amplitude in m/s :scale: float Planet-to-star flux ratio :wlgrid: array Wavelength grid :Fp_conv: array Planet spectrum convolved with the instrumental profile :Fstar_conv: array Stellar spectrum convolved with the instrumental profile :flux_cube: array Data cube :n_order: int Number of orders :n_exposure: int Number of exposures :n_pixel: int Number of pixels :phases: array Orbital phases :Rp_solar: float Planet radius in solar radii :Rstar: float Stellar radius in solar radii :rv_semiamp_orbit: float Semi-amplitude of the orbit in km/s. This is the motion of the star. :A_noplanet: array Array of the non-planet component of the data cube :do_pca: bool Whether to perform PCA on the data cube :n_princ_comp: int Number of principal components to use in the PCA :star: bool Whether to include the stellar component in the simulation. :observation: str Type of observation. Currently supported: ‘emission’, ‘transmission’
Outputs#
- logL:
float
Log likelihood of the data given the model parameters :ccf: array Cross-correlation function of the data given the model parameters
- scope.run_simulation.make_data(scale, wlgrid, wl_model, Fp_conv, Fstar_conv, n_order, n_exposure, n_pixel, phases, Rp_solar, Rstar, seed=42, do_pca=True, blaze=False, tellurics=False, n_princ_comp=4, v_sys=0.0, Kp=192.06, star=False, SNR=0, rv_semiamp_orbit=0.3229, observation='emission', tell_type='ATRAN', time_dep_tell=False, wav_error=False, order_dep_throughput=False, a=1, u1=0.3, u2=0.3, LD=True, b=0.0, divide_out_of_transit=False, out_of_transit_dur=0.1, v_sys_measured=0.0, vary_throughput=True, instrument='IGRINS', pca_removal='subtract')[source]#
Creates a simulated HRCCS dataset. Main function.
Inputs#
- scale:
(float) scaling factor for the data.
- wlgrid:
(array) wavelength grid for the data.
- do_pca:
(bool) if True, do PCA on the data.
- blaze:
(bool) if True, include the blaze function in the data.
- tellurics:
(bool) if True, include tellurics in the data.
- n_princ_comp:
(int) number of principal components to use.
- v_sys:
(float) systemic velocity of the planet.
- Kp:
(float) semi-amplitude of the planet.
- star:
(bool) if True, include the stellar spectrum in the data.
- SNR:
(float) photon signal-to-noise ratio (not of the planetary spectrum itself!)
- observation:
(str) ‘emission’ or ‘transmission’.
- tell_type:
(str) ‘ATRAN’ or ‘data-driven’.
- time_dep_tell:
(bool) if True, include time-dependent tellurics. not applicable for ATRAN.
- wav_error:
(bool) if True, include wavelength-dependent error.
- order_dep_throughput:
(bool) if True, include order-dependent throughput.
Outputs#
- pca_noise_matrix:
(array) the data cube with only the larger-scale trends.
- flux_cube:
(array) the data cube with the larger-scale trends removed.
- fTemp_nopca:
(array) the data cube with all components.
- just_tellurics:
(array) the telluric model that’s multiplied to the dataset.
- scope.run_simulation.simulate_observation(planet_spectrum_path='.', star_spectrum_path='.', data_cube_path='.', phase_start=0, phase_end=1, n_exposures=10, observation='emission', blaze=True, n_princ_comp=4, star=True, SNR=250, telluric=True, tell_type='data-driven', time_dep_tell=False, wav_error=False, rv_semiamp_orbit=0.3229, order_dep_throughput=True, Rp=1.21, Rstar=0.955, kp=192.02, v_rot=4.5, scale=1.0, v_sys=0.0, modelname='yourfirstsimulation', divide_out_of_transit=False, out_of_transit_dur=0.1, include_rm=False, v_rot_star=3.0, a=0.033, lambda_misalign=0.0, inc=90.0, seed=42, LD=True, vary_throughput=True, instrument='IGRINS', snr_path=None, planet_name='yourfirstplanet', n_kp=200, n_vsys=200, pca_removal='subtract', **kwargs)[source]#
Run a simulation of the data, given a grid index and some paths. Side effects: writes some files in the output directory.
Inputs#
- grid_ind: int
The index of the grid to use.
- planet_spectrum_path: str
The path to the planet spectrum.
- star_spectrum_path: str
The path to the star spectrum.
- phases: array-like
The phases of the observations.
- observation: str
Type of observation to simulate. Currently supported: emission, transmission.
Outputs#
None
Tellurics#
Read in and apply tellurics to simulated data.
- scope.tellurics.add_tellurics(wl_cube_model, flux_cube_model, n_order, n_exp, vary_airmass=False, tell_type='ATRAN', time_dep_tell=False)[source]#
Includes tellurics in the model. todo: allow thew airmass variation to not be the case for the data-driven tellurics
Inputs#
- wl_cube_model:
(array) wavelength cube model
- flux_cube_model:
(array) flux cube model
- n_order:
(int) number of orders
- n_exp:
(int) number of exposures
- vary_airmass:
(bool) if True, then the airmass is varied. If False, then the airmass is fixed.
- tell_type:
(str) either ‘ATRAN’ or ‘data-driven’
- time_dep_tell:
(bool) if True, then the tellurics are time dependent. If False, then the tellurics are not time dependent.
Outputs#
- flux_cube_model:
(array) flux cube model with tellurics included.
- scope.tellurics.add_tellurics_atran(wl_cube_model, flux_cube_model, n_order, n_exp, vary_airmass=False)[source]#
- scope.tellurics.calc_weighted_vector_insim(vals, eigenvector, relationships, provided_relationships=False)[source]#
Calculates the weighted vector for a given set of eigenvalues and eigenvectors.
Inputs#
- vals:
(array) eigenvalues
- eigenvector:
(array) eigenvectors
- relationships:
(list of arrays) relationships between eigenvectors and the flux vector.
- provided_relationships:
(bool) if True, then relationships are provided. If False, then relationships are calculated.
Outputs#
- fm:
(array) weighted vector
- relationships:
(list of arrays) relationships between eigenvectors and the flux vector.
- scope.tellurics.eigenweight_func(airmass, date)[source]#
Does the weighting. turns date and airmass into their correct array!
Inputs#
- airmass:
(float) airmass
- date:
(float) date
Outputs#
- array:
(array) array of values to be multiplied by the eigenvectors.
- scope.tellurics.find_closest_atran_angle(zenith_angle)[source]#
Parses through the available ATRAN files and finds the one with the zenith angle closest to the desired.
Noise#
Add noise to simulated data.
- scope.noise.add_constant_noise(flux_cube_model, wl_grid, SNR)[source]#
Adds constant noise to the flux cube model.
Inputs#
- flux_cube_model:
(array) flux cube model
- wl_grid:
(array) wavelength grid
- SNR:
(float) signal-to-noise ratio
Outputs#
- noisy_flux:
(array) flux cube model with constant noise added.
- scope.noise.add_crires_plus_noise(flux_cube_model, wl_grid, SNR)[source]#
Adds CRIRES+ noise to the flux cube model.
- scope.noise.add_igrins_noise(flux_cube_model, wl_grid, SNR)[source]#
Adds IGRINS noise to the flux cube model.
Inputs#
- flux_cube_model:
(array) flux cube model
- wl_grid:
(array) wavelength grid
- SNR:
(float) signal-to-noise ratio
Outputs#
- noisy_flux:
(array) flux cube model with IGRINS noise added.
- scope.noise.add_noise_cube(flux_cube_model, wl_grid, SNR, noise_model='constant', **kwargs)[source]#
Per the equation in Brogi + Line 19. Assumes that the flux cube is scaled 0 to 1.
I guess note that when I say “SNR”, I’m ignoring for now the wavelength-dependent flux that you get because of a blaze function. It’s the SNR at the peak of the blaze function.
Inputs#
- flux_cube_model:
(array) flux cube model
- wl_grid:
(array) wavelength grid
- SNR:
(float) signal-to-noise ratio
- noise_model:
(str) noise model to use. Can be constant, IGRINS, custom_quadratic, or custom.
Outputs#
- noisy_flux:
(array) flux cube model with noise added.
- scope.noise.add_quadratic_noise(flux_cube_model, wl_grid, SNR, IGRINS=False, **kwargs)[source]#
Currently assumes that there are two bands: A and B.
Inputs#
- flux_cube_model:
(array) flux cube model
- wl_grid:
(array) wavelength grid
- SNR:
(float) signal-to-noise ratio
- IGRINS:
(bool) if True, then the data is IGRINS data. If False, then the data is NOT IGRINS data.
Outputs#
- noisy_flux:
(array) flux cube model with quadratic noise added.
R-M effect#
Module for simulating the Rossiter-McLaughlin effect. This is experimental for now.
- scope.rm_effect.calc_areas(grid)[source]#
calculate the area of each cell in the grid. if it’s an r, theta grid, then the area is r^2 * pi / (n_r * n_theta) no, that’s not true. it involves dr. and dtheta. but we can just do it in r, theta space.
so, the :param grid: :return:
- scope.rm_effect.calc_planet_locations(phases, r_star, inc, lambda_misalign, a)[source]#
calculate the x and y positions of the planet on the stellar disk.
the phase is at 0.0 when the planet is in front of the star. 0.5 when it’s behind the star.
phases are in units of orbital phase. not radians.
a and rstar just need to be in the same units.
inclination is in radians lambda_misalign is in radians.
we need note: theta is a bit all over the place for the center of the star. but that’s more or less physical : )
Assumes a circular orbit, for now… :param phases: :param r_p: :param r_star: :param inc: :param lambda_misalign: :param kp: :return:
- scope.rm_effect.doppler_shift_grid(grid, flux, wavelengths, v_rot)[source]#
the grid is the (r, theta) values. takes in a 1D spectrum.
v_rot is in meters per second.
outputs the spectrum grid. each row is a different point on the grid. each column is a different wavelength.
- scope.rm_effect.make_stellar_disk(flux, wavelengths, v_rot, phases, r_star, inc, lambda_misalign, a, r_p, n_theta=10, n_r=10)[source]#
based on the x and y position of the planet on the disk, make the stellar spectrum.
note: doesn’t incorporate CLV variations if I just use a phoenix model.
and if i use an empirical spectrum, I’m not blocking out CLV variations.
take the average of all these approaches? lol
v_rot is in km/s
r_p in meters, and same with rstar and a
Cross-correlation#
Calculates the cross-correlation function (and log likelihood function from the Brogi & Line 2019 mapping)
- scope.ccf.calc_ccf(model_flux, data_arr_slice, n_pixel)[source]#
Calculates the CCF between a model and a data slice.
Inputs#
- model_flux:
(jnp.ndarray) The model flux, normalized and such.
- data_arr_slice:
(jnp.ndarray) The data slice, normalized and such.
- n_pixels:
(int) The number of pixels in the data slice.
Outputs#
- logl:
(float) The log-likelihood of the data given the model.
- CCF:
(float) The CCF between the model and the data.
- scope.ccf.calc_ccf_map(model_flux, data_arr_slice, n_pixel)#
Vectorized version of calc_ccf. Takes similar arguments as calc_ccf but with additional array axes over which calc_ccf is mapped.
Original documentation:
Calculates the CCF between a model and a data slice.
- model_flux:
(jnp.ndarray) The model flux, normalized and such.
- data_arr_slice:
(jnp.ndarray) The data slice, normalized and such.
- n_pixels:
(int) The number of pixels in the data slice.
- logl:
(float) The log-likelihood of the data given the model.
- CCF:
(float) The CCF between the model and the data.
Running simulation#
Main module for running a simulation of the HRCCS data. This module contains the main functions for simulating the data and calculating the log likelihood and cross-correlation function of the data given the model parameters.
- scope.run_simulation.calc_log_likelihood(v_sys, Kp, scale, wlgrid, wl_model, Fp_conv, Fstar_conv, flux_cube, n_order, n_exposure, n_pixel, phases, Rp_solar, Rstar, rv_semiamp_orbit, A_noplanet, do_pca=True, n_princ_comp=4, star=False, observation='emission', a=1, u1=0.3, u2=0.3, LD=True, b=0.0, v_sys_measured=0.0, pca_removal='subtract')[source]#
Calculates the log likelihood and cross-correlation function of the data given the model parameters.
Inputs#
- v_sys:
float Systemic velocity of the system in m/s :Kp: float Planet semi-amplitude in m/s :scale: float Planet-to-star flux ratio :wlgrid: array Wavelength grid :Fp_conv: array Planet spectrum convolved with the instrumental profile :Fstar_conv: array Stellar spectrum convolved with the instrumental profile :flux_cube: array Data cube :n_order: int Number of orders :n_exposure: int Number of exposures :n_pixel: int Number of pixels :phases: array Orbital phases :Rp_solar: float Planet radius in solar radii :Rstar: float Stellar radius in solar radii :rv_semiamp_orbit: float Semi-amplitude of the orbit in km/s. This is the motion of the star. :A_noplanet: array Array of the non-planet component of the data cube :do_pca: bool Whether to perform PCA on the data cube :n_princ_comp: int Number of principal components to use in the PCA :star: bool Whether to include the stellar component in the simulation. :observation: str Type of observation. Currently supported: ‘emission’, ‘transmission’
Outputs#
- logL:
float
Log likelihood of the data given the model parameters :ccf: array Cross-correlation function of the data given the model parameters
- scope.run_simulation.make_data(scale, wlgrid, wl_model, Fp_conv, Fstar_conv, n_order, n_exposure, n_pixel, phases, Rp_solar, Rstar, seed=42, do_pca=True, blaze=False, tellurics=False, n_princ_comp=4, v_sys=0.0, Kp=192.06, star=False, SNR=0, rv_semiamp_orbit=0.3229, observation='emission', tell_type='ATRAN', time_dep_tell=False, wav_error=False, order_dep_throughput=False, a=1, u1=0.3, u2=0.3, LD=True, b=0.0, divide_out_of_transit=False, out_of_transit_dur=0.1, v_sys_measured=0.0, vary_throughput=True, instrument='IGRINS', pca_removal='subtract')[source]#
Creates a simulated HRCCS dataset. Main function.
Inputs#
- scale:
(float) scaling factor for the data.
- wlgrid:
(array) wavelength grid for the data.
- do_pca:
(bool) if True, do PCA on the data.
- blaze:
(bool) if True, include the blaze function in the data.
- tellurics:
(bool) if True, include tellurics in the data.
- n_princ_comp:
(int) number of principal components to use.
- v_sys:
(float) systemic velocity of the planet.
- Kp:
(float) semi-amplitude of the planet.
- star:
(bool) if True, include the stellar spectrum in the data.
- SNR:
(float) photon signal-to-noise ratio (not of the planetary spectrum itself!)
- observation:
(str) ‘emission’ or ‘transmission’.
- tell_type:
(str) ‘ATRAN’ or ‘data-driven’.
- time_dep_tell:
(bool) if True, include time-dependent tellurics. not applicable for ATRAN.
- wav_error:
(bool) if True, include wavelength-dependent error.
- order_dep_throughput:
(bool) if True, include order-dependent throughput.
Outputs#
- pca_noise_matrix:
(array) the data cube with only the larger-scale trends.
- flux_cube:
(array) the data cube with the larger-scale trends removed.
- fTemp_nopca:
(array) the data cube with all components.
- just_tellurics:
(array) the telluric model that’s multiplied to the dataset.
- scope.run_simulation.simulate_observation(planet_spectrum_path='.', star_spectrum_path='.', data_cube_path='.', phase_start=0, phase_end=1, n_exposures=10, observation='emission', blaze=True, n_princ_comp=4, star=True, SNR=250, telluric=True, tell_type='data-driven', time_dep_tell=False, wav_error=False, rv_semiamp_orbit=0.3229, order_dep_throughput=True, Rp=1.21, Rstar=0.955, kp=192.02, v_rot=4.5, scale=1.0, v_sys=0.0, modelname='yourfirstsimulation', divide_out_of_transit=False, out_of_transit_dur=0.1, include_rm=False, v_rot_star=3.0, a=0.033, lambda_misalign=0.0, inc=90.0, seed=42, LD=True, vary_throughput=True, instrument='IGRINS', snr_path=None, planet_name='yourfirstplanet', n_kp=200, n_vsys=200, pca_removal='subtract', **kwargs)[source]#
Run a simulation of the data, given a grid index and some paths. Side effects: writes some files in the output directory.
Inputs#
- grid_ind: int
The index of the grid to use.
- planet_spectrum_path: str
The path to the planet spectrum.
- star_spectrum_path: str
The path to the star spectrum.
- phases: array-like
The phases of the observations.
- observation: str
Type of observation to simulate. Currently supported: emission, transmission.
Outputs#
None
Calculating quantities#
This module contains functions to calculate derived quantities from the input data.
- scope.calc_quantities.calc_crossing_time(period=1.80988198, mstar=1.458, e=0.0, mplanet=0.894, rstar=1.756, peri=0, b=0.027, R=45000, pix_per_res=3.3, phase_start=0.9668567402328337, phase_end=1.0331432597671664, plot=False)[source]#
todo: refactor this into separate functions, maybe?
Inputs#
autofilled for WASP-76b and IGRINS.
R: (int) resolution of spectrograph. pix_per_res: (float) pixels per resolution element
Outputs#
min_time: minimum time during transit before lines start smearing across resolution elements.
min_time_per_pixel: minimum time during transit before lines start smearing across a single pixel. dphase_per_exp: the amount of phase (values from 0 to 1) taken up by a single exposure, given above constraints. n_exp: number of exposures you can take during transit.
- scope.calc_quantities.calculate_derived_parameters(data)[source]#
Calculate derived parameters from the input data.
- scope.calc_quantities.calculate_velocity(distance, P, distance_unit=Unit('AU'), time_unit=Unit('d'))[source]#
Calculate a velocity over some period over some distance.
Input / output#
Module to handle the input files.
- exception scope.input_output.ScopeConfigError(message='scope input file error:')[source]#
Bases:
Exception
- scope.input_output.coerce_database(data, key, value, astrophysical_params, planet_name, database_path)[source]#
- scope.input_output.parse_input_file(file_path, database_path='data/default_params_exoplanet_archive.csv', **kwargs)[source]#
Parse an input file and return a dictionary of parameters.
- Parameters:
file_path (str) – Path to the input file.
database_path (str) – Path to the database file.
**kwargs – Additional keyword arguments to add to the data dictionary.
- Returns:
data – Dictionary of parameters.
- Return type:
dict
- scope.input_output.query_database(planet_name, parameter, database_path='data/default_params_exoplanet_archive.csv')[source]#
- scope.input_output.read_crires_data(data_path)[source]#
Reads in CRIRES data.
Inputs#
- data_path:
(str) path to the data
Outputs#
n_orders: (int) number of orders n_pixel: (int) number of pixels wl_cube_model: (array) wavelength cube model snrs: (array) signal-to-noise ratios
MCMC fitting#
Module to fit (simulated) HRCCS data with emcee, using MPI (multi-core). The fit is with respect to the velocity parameters (Kp, Vsys) and the scale factor.
- scope.emcee_fit_hires.log_prob(x, best_kp, wl_cube_model, Fp_conv, n_order, n_exposure, n_pixel, A_noplanet, star, n_princ_comp, flux_cube, wl_model, Fstar_conv, Rp_solar, Rstar, phases, do_pca)[source]#
just add the log likelihood and the log prob.
Inputs#
- x:
(array) array of parameters
- best_kp:
(float) best-fit planet velocity
- wl_cube_model:
(array) wavelength cube model
- Fp_conv:
(array) convolved planet spectrum
- n_order:
(int) number of orders
- n_exposure:
(int) number of exposures
- n_pixel:
(int) number of pixels
- A_noplanet:
(array) no planet spectrum
- star:
(array) stellar spectrum
- n_princ_comp:
(int) number of principal components
- flux_cube:
(array) flux cube
- wl_model:
(array) wavelength model
- Fstar_conv:
(array) convolved stellar spectrum
- Rp_solar:
(float) planet radius in solar radii
- Rstar:
(float) stellar radius
- phases:
(array) array of phases
- do_pca:
(bool) whether to do PCA
Outputs#
- log_prob:
(float) log probability.
- scope.emcee_fit_hires.prior(x, best_kp)[source]#
Prior on the parameters. Only uniform!
Inputs#
- x:
(array) array of parameters
- best_kp:
(float) best-fit planet velocity
Outputs#
- prior_val:
(float) log prior value.
- scope.emcee_fit_hires.sample(nchains, nsample, A_noplanet, Fp_conv, wl_cube_model, n_order, n_exposure, n_pixel, star, n_princ_comp, flux_cube, wl_model, Fstar_conv, Rp_solar, Rstar, phases, seed=42, do_pca=True, best_kp=192.06, best_vsys=0.0, best_log_scale=0.0, multicore=True, walker_dispersion=0.01)[source]#
Samples the likelihood. right now, it needs an instantiated best-fit value.
Inputs#
- nchains:
(int) number of chains
- nsample:
(int) number of samples
- A_noplanet:
(array) array of the no planet spectrum
- Fp_conv:
(array) array of the stellar spectrum
- wl_cube_model:
(array) wavelength cube model
- n_order:
(int) number of orders
- n_exposure:
(int) number of exposures
- n_pixel:
(int) number of pixels
- star:
(array) stellar spectrum
- n_princ_comp:
(int) number of principal components
- flux_cube:
(array) flux cube
- wl_model:
(array) wavelength model
- Fstar_conv:
(array) convolved stellar spectrum
- Rp_solar:
(float) planet radius in solar radii
- Rstar:
(float) stellar radius
- phases:
(array) array of phases
- do_pca:
(bool) whether to do PCA
- best_kp:
(float) best-fit planet velocity
- best_vsys:
(float) best-fit system velocity
- best_log_scale:
(float) best-fit log scale
- walker_dispersion:
(float) scale by which to disperse the walkers at initialization
Outputs#
- sampler:
(emcee.EnsembleSampler) the sampler object.