POSEIDON.high_res
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SYSREM procedure adapted from https://github.com/stephtdouglas/PySysRem, originally used for detrending light curves. |
|
TODO: Add docstrings. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Function that will find the index of the value in the array nearest a given value |
|
|
|
Perform the loglikelihood calculation using Principal Component Analysis (PCA). Based on M. Line 2019. |
|
Perform the loglikelihood calculation using SysRem. Based on N. Gibson 2021. |
|
Return the loglikelihood given the observed flux, Keplerian velocity, and centered system velocity. |
|
Get rotational kernel given V sin(i) and wavelength grid of the forward model. |
|
|
|
|
|
Module Contents
- POSEIDON.high_res.airtovac(wlum)
- POSEIDON.high_res.vactoair(wlum)
- POSEIDON.high_res.read_hdf5(file_path)
- POSEIDON.high_res.read_high_res_data(data_dir, names=None)
- POSEIDON.high_res.fit_uncertainties(flux, n_components=5, initial_guess=[0.1, 200], Print=True)
- POSEIDON.high_res.blaze_correction(flux, filter_size, Print=True)
- POSEIDON.high_res.prepare_high_res_data(data_dir, name, spectrum_type, method, flux, wl_grid, phi, uncertainties=None, transit_weight=None, V_bary=None, pca_ncomp=4, sysrem_niter=15)
- POSEIDON.high_res.sysrem(data_array, uncertainties, niter=15)
SYSREM procedure adapted from https://github.com/stephtdouglas/PySysRem, originally used for detrending light curves.
Use this function in a high resolutional rerieval. nord: number of spectral order. nphi: number of time-resolved phases. npix: number of wavelengths per spectral order.
- Parameters:
data_array (2D np.array of float) – Blaze-corrected data of a single order. Shape: (nphi x npix)
uncertainties (np.array of float) – Time and wavelength dependent uncertainties obtained from fit_uncertainties. Shape: (nphi x npix)
Niter (int) – Number of basis vectors to consider.
- Returns:
- 2D Array representing the residuals data of a single order after filtering.
Shape: (nphi x npix)
- U (2D np.array of float):
Basis vectors obtained from SYSREM of a single vector. Shape: (nphi x N_iter + 1)
- Return type:
residuals (np.array of float)
- POSEIDON.high_res.fast_filter(flux, uncertainties, niter=15, Print=True)
TODO: Add docstrings. Use this function in a high resolutional rerieval.
Args:
- Returns:
- The residuals data of a single order after filtering.
Shape: (nord x nphi x npix)
- Us (3D np.array of float):
Basis vectors obtained from SYSREM of a single vector. Shape: (nord x nphi x N_iter+1)
- Return type:
residuals (3D np.array of float)
- POSEIDON.high_res.make_data_cube(data, n_components=4)
- POSEIDON.high_res.PCA_rebuild(flux, n_components=5)
- POSEIDON.high_res.fit_out_transit_spec(flux, transit_weight, degree=2, spec='median', Print=True)
- POSEIDON.high_res.get_RV_range(Kp_range, Vsys_range, phi)
- POSEIDON.high_res.cross_correlate(Kp_range, Vsys_range, RV_range, wl, planet_spectrum, data, Print=True)
- POSEIDON.high_res.plot_CCF_phase_RV(phi, RV_range, CCF_phase_RV, label=None, save_file_path=None, cmap=cmr.ember)
- POSEIDON.high_res.find_nearest_idx(array, value)
Function that will find the index of the value in the array nearest a given value
Input: array, number
Output: index of value in array closest to that number
- POSEIDON.high_res.plot_CCF_Kp_Vsys(Kp_range, Vsys_range, CCF_Kp_Vsys, label=None, Kp_expected=None, Vsys_expected=None, RM_mask_size=10, plot_slice=False, save_file_path=None, cmap=cmr.ember)
- POSEIDON.high_res.loglikelihood_PCA(V_sys, K_p, d_phi, a, wl, planet_spectrum, star_spectrum, data)
Perform the loglikelihood calculation using Principal Component Analysis (PCA). Based on M. Line 2019. nord: number of spectral order. nphi: number of time-resolved phases. npix: number of wavelengths per spectral order.
- Parameters:
V_sys (float) – The system velocity (km/s) at which we do the loglikelihood calculation.
K_p (float) – The Keplerian velocity (km/s) at which we do the loglikelihood calculation.
d_phi (float) – Phase offset.
a (float) – Scale parameter a.
wl (np.array of float) – Wavelength at which the model is defined.
planet_spectrum (np.array of float) – Observed flux of the planet (at distance = 1 pc). Should be broadened in the same way as the star_spectrum.
star_spectrum (np.array of float) – Observed flux of the star (at distance = 1 pc). Should be broadened in the same way as the star_spectrum.
data (dict) –
Data dictionary read using utility.read_high_res_data. All values should be prepared beforehand. Has the following key-value pairss:
- reasiduals (3D np.array of float):
3D Array representing the top principal components removed data. Shape: (nord x nphi x npix)
- flux (3D np.array of float):
3D Array representing the raw flux of data. Shape: (nord x nphi x npix)
- V_bary (np.array of float):
Array of time-resolved Earth-star velocity. We have absorbed V_sys into V_bary, so V_sys = V_sys_literature + d_V_sys. Shape: (nphi, )
- phi (np.array of float):
Array of time-resolved phases. Shpae (nphi, )
- Returns:
Log-likelihood value. CCF_sum (float):
Cross-correlation value.
- Return type:
loglikelihood_sum (float)
- POSEIDON.high_res.loglikelihood_sysrem(V_sys, K_p, d_phi, a, b, wl, planet_spectrum, data, star_spectrum=None)
Perform the loglikelihood calculation using SysRem. Based on N. Gibson 2021. nord: number of spectral order. nphi: number of time-resolved phases. npix: number of wavelengths per spectral order.
- Parameters:
V_sys (float) – The system velocity (km/s) at which we do the loglikelihood calculation.
K_p (float) – The Keplerian velocity (km/s) at which we do the loglikelihood calculation.
d_phi (float) – Phase offset.
a (float) – Scale parameter for spectrum.
b (float or None) – Scale parameter for noise. If None, calculate loglikelihood using nulled b (b that maximizes logL).
wl (np.array of float) – Wavelength at which the model is defined.
planet_spectrum (np.array of float) – Observed flux of the planet (at distance = 1 pc). Should be broadened in the same way as the star_spectrum.
data (dict) –
Data dictionary read using utility.read_high_res_data. All values should be prepared beforehand. Has the following key-value pairs:
- residuals (3D np.array of float):
3D Array representing the residuals data after filtering. Shape: (nord x nphi x npix)
- Bs (list of 2D np.array of float):
A list of basis vectors returned by fast_filter. Shape: (nord x nphi x npix)
- phi (np.array of float):
Array of time-resolved phases. Shape (nphi, )
- transit_weight (np.array of float):
Transit model of the planet. A value of 1 is out of transit, and 0 is full transit. Shape (nphi, )
- uncertainties (None or 3D np.array of float):
Time and wavelength dependent uncertainties obtained from fit_uncertainties. Can be None only if b is also None. Shape: (nord x nphi x npix)
- Returns:
Loglikelihood value.
- Return type:
Loglikelihood (float)
- POSEIDON.high_res.loglikelihood_high_res(wl, planet_spectrum, star_spectrum, data, spectrum_type, method, high_res_params, high_res_param_names)
Return the loglikelihood given the observed flux, Keplerian velocity, and centered system velocity. Should only use this function in a high resolutional rerieval.
- Parameters:
wl (np.array of float) – Wavelength at which the model is defined.
planet_spectrum (np.array of float) – Observed flux of the planet (at distance = 1 pc). Should be broadened in the same way as the star_spectrum.
star_spectrum (np.array of float) – Observed flux of the star (at distance = 1 pc). Should be broadened in the same way as the star_spectrum.
data (dict) – Data dictionary read using utility.read_high_res_data. All values should be prepared beforehand. For more information, see code spec for loglikelihood_PCA or loglikelihood_sysrem.
model (dict) – Dictionary containing properties of the model.
- Returns:
Loglikelihood calculated based on which filtering method (specified in data[‘method’]).
- Return type:
loglikelihood (float)
- POSEIDON.high_res.get_rot_kernel(V_sin_i, wl, W_conv)
Get rotational kernel given V sin(i) and wavelength grid of the forward model.
- Parameters:
V_sin_i (float) – Projected rotational velocity of a star. The component of the rotational velocity along the line of sight, which is esponsible for broadening.
wl (np.array of float) – Wavelength grid of the forward model.
W_conv (int) – Width of the rotational kernel.
- POSEIDON.high_res.remove_outliers(wl_grid, flux)
- POSEIDON.high_res.transit_model(R_p, R_s, a, phi)
- POSEIDON.high_res.make_injection_data(data, data_dir, name, wl, planet_spectrum, K_p, V_sys, method, a=None, continuum=None, W_conv=None, star_spectrum=None)