POSEIDON.stellar ================ .. py:module:: POSEIDON.stellar .. autoapi-nested-parse:: Stellar spectra and star spot/faculae contamination calculations. Attributes ---------- .. autoapisummary:: POSEIDON.stellar.pymsg Functions --------- .. autoapisummary:: POSEIDON.stellar.planck_lambda POSEIDON.stellar.load_stellar_pysynphot POSEIDON.stellar.open_pymsg_grid POSEIDON.stellar.load_stellar_pymsg POSEIDON.stellar.precompute_stellar_spectra POSEIDON.stellar.precompute_stellar_spectra_OLD POSEIDON.stellar.stellar_contamination_single_spot POSEIDON.stellar.stellar_contamination_general POSEIDON.stellar.stellar_contamination Module Contents --------------- .. py:data:: pymsg .. py:function:: planck_lambda(T, wl) Compute the Planck function spectral radiance. :param T: Effective temperature of star (K). :type T: float :param wl: Wavelength grid (μm). :type wl: np.array of float :returns: Planck function spectral radiance in SI units (W/m^2/sr/m). :rtype: B_lambda (np.array of float) .. py:function:: load_stellar_pysynphot(wl_out, T_eff, Met, log_g, stellar_grid='cbk04') Load a stellar model using pysynphot. Pynshot's ICAT function handles interpolation within the model grid to the specified stellar parameters. Note: Pysynphot's PHOENIX model grids have some bugs for non-solar metallicity. So we default to the Castelli-Kurucz 2004 grids. :param wl_out: Wavelength grid on which to output the stellar spectra (μm). :type wl_out: np.array of float :param T_eff: Effective temperature of star (K). :type T_eff: float :param Met: Stellar metallicity [log10(Fe/H_star / Fe/H_solar)]. :type Met: float :param log_g: Stellar log surface gravity (log10(cm/s^2) by convention). :type log_g: float :param stellar_grid: Desired stellar model grid (Options: cbk04 / phoenix). :type stellar_grid: str :returns: Stellar specific intensity spectrum in SI units (W/m^2/sr/m). :rtype: I_out (np.array of float) .. py:function:: open_pymsg_grid(stellar_grid) Check if pymsg is installed, then opens the HDF5 file for the grid. :param stellar_grid: Stellar model grid to use (Options: PHOENIX (or Goettingen-HiRes) / SPHINX). :type stellar_grid: string :returns: Stellar grid object in pymsg format. :rtype: specgrid (pymsg object) .. py:function:: load_stellar_pymsg(wl_out, specgrid, T_eff, Met, log_g, stellar_grid) Load a stellar model using PyMSG. The MSG package (https://msg.readthedocs.io/en/stable/index.html) handles interpolation within the model grid to the specified stellar parameters. :param wl_out: Wavelength grid on which to output the stellar spectra (μm). :type wl_out: np.array of float :param specgrid: Stellar grid object in pymsg format. :type specgrid: pymsg object :param T_eff: Effective temperature of star (K). :type T_eff: float :param Met: Stellar metallicity [log10(Fe/H_star / Fe/H_solar)]. :type Met: float :param log_g: Stellar log surface gravity (log10(cm/s^2) by convention). :type log_g: float :param stellar_grid: Stellar model grid to use (Options: phoenix / sphinx). :type stellar_grid: string :returns: Stellar specific intensity spectrum in SI units (W/m^2/sr/m). :rtype: I_grid (np.array of float) .. py:function:: precompute_stellar_spectra(comm, wl_out, star, prior_types, prior_ranges, stellar_contam, T_step_interp=20, log_g_step_interp=0.1, interp_backend='pysynphot') Precompute a grid of stellar spectra across a range of T_eff and log g. :param wl_out: Wavelength grid on which to output the stellar spectra (μm). :type wl_out: np.array of float :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param prior_types: User-provided dictionary containing the prior type for each free parameter in the retrieval model. :type prior_types: dict :param prior_ranges: User-provided dictionary containing numbers defining the prior range for each free parameter in the retrieval model. :type prior_ranges: dict :param stellar_contam: Chosen prescription for modelling unocculted stellar contamination (Options: one_spot / one_spot_free_log_g / two_spots). :type stellar_contam: str :param stellar_grid: Desired stellar model grid (Options: cbk04 / phoenix / sphinx). :type stellar_grid: str :param T_step_interp: Temperature step for stellar grid interpolation (uniform priors only). :type T_step_interp: float :param log_g_step_interp: log g step for stellar grid interpolation (uniform priors only). :type log_g_step_interp: float :param interp_backend: Stellar grid interpolation package for POSEIDON to use. (Options: pysynphot / pymsg). :type interp_backend: str :param comm: Communicator used to allocate shared memory on multiple cores. :type comm: MPI communicator :returns: Photosphere temperatures corresponding to computed stellar spectra (K). T_het_grid (np.array of float): Heterogeneity temperatures corresponding to computed stellar spectra (K). log_g_phot_grid (np.array of float): Photosphere log g corresponding to computed stellar spectra (log10(cm/s^2)). log_g_het_grid (np.array of float): Heterogeneity log g corresponding to computed stellar spectra (log10(cm/s^2)). I_phot_out (3D np.array of float): Stellar photosphere intensity as a function of T_phot, log_g_phot, and wl (W/m^2/sr/m). I_het_out (3D np.array of float): Stellar heterogeneity intensity as a function of T_het, log_g_het, and wl (W/m^2/sr/m). :rtype: T_phot_grid (np.array of float) .. py:function:: precompute_stellar_spectra_OLD(wl_out, star, prior_types, prior_ranges, stellar_contam, T_step_interp=20, log_g_step_interp=0.1, interp_backend='pysynphot') Precompute a grid of stellar spectra across a range of T_eff and log g. :param wl_out: Wavelength grid on which to output the stellar spectra (μm). :type wl_out: np.array of float :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param prior_types: User-provided dictionary containing the prior type for each free parameter in the retrieval model. :type prior_types: dict :param prior_ranges: User-provided dictionary containing numbers defining the prior range for each free parameter in the retrieval model. :type prior_ranges: dict :param stellar_contam: Chosen prescription for modelling unocculted stellar contamination (Options: one_spot / one_spot_free_log_g / two_spots). :type stellar_contam: str :param stellar_grid: Desired stellar model grid (Options: cbk04 / phoenix). :type stellar_grid: str :param T_step_interp: Temperature step for stellar grid interpolation (uniform priors only). :type T_step_interp: float :param log_g_step_interp: log g step for stellar grid interpolation (uniform priors only). :type log_g_step_interp: float :param interp_backend: Stellar grid interpolation package for POSEIDON to use. (Options: pysynphot / pymsg). :type interp_backend: str :returns: Photosphere temperatures corresponding to computed stellar spectra (K). T_het_grid (np.array of float): Heterogeneity temperatures corresponding to computed stellar spectra (K). log_g_phot_grid (np.array of float): Photosphere log g corresponding to computed stellar spectra (log10(cm/s^2)). log_g_het_grid (np.array of float): Heterogeneity log g corresponding to computed stellar spectra (log10(cm/s^2)). I_phot_out (3D np.array of float): Stellar photosphere intensity as a function of T_phot, log_g_phot, and wl (W/m^2/sr/m). I_het_out (3D np.array of float): Stellar heterogeneity intensity as a function of T_het, log_g_het, and wl (W/m^2/sr/m). :rtype: T_phot_grid (np.array of float) .. py:function:: stellar_contamination_single_spot(f, I_het, I_phot) Computes the multiplicative stellar contamination factor for a transmission spectrum due to an unocculted starspot or facular region. The prescription used is as in Rackham+(2017,2018). :param f: Fraction of the stellar surface covered by the heterogeneity. :type f: float :param I_het: Stellar heterogeneity intensity as a function of wl (W/m^2/sr/m). :type I_het: np.array of float :param I_phot: Stellar photosphere intensity as a function of wl (W/m^2/sr/m). :type I_phot: np.array of float :returns: Stellar contamination factor as a function of wl. :rtype: epsilon (np.array of float) .. py:function:: stellar_contamination_general(f_het, I_het, I_phot) Computes the multiplicative stellar contamination factor for a transmission spectrum due to a collection of unocculted starspot or facular regions, each of which may have their own coverage fraction and specific intensity. :param f_het: Fraction of the stellar surface covered each heterogeneity. :type f_het: np.array of float :param I_het: Stellar heterogeneity intensity as a function of region and wl (W/m^2/sr/m). :type I_het: 2D np.array of float :param I_phot: Stellar photosphere intensity as a function of wl (W/m^2/sr/m). :type I_phot: np.array of float :returns: Stellar contamination factor as a function of wl. :rtype: epsilon (np.array of float) .. py:function:: stellar_contamination(star, wl_out) Computes the multiplicative stellar contamination factor for a transmission spectrum due to an unocculted starspot or facular region. The prescription used is as in Rackham+(2017,2018). This function unpacks the required stellar properties from POSEIDON's 'star' object, interpolates the stellar intensities to the output wavelength grid, then computes the stellar contamination for a single heterogeneous region. Note: this function is only used for forward models, since for retrievals the wavelength interpolation is handled by another function called 'precompute_stellar_spectra'. :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param wl_out: Wavelength grid on which to output the stellar spectra (μm). :type wl_out: np.array of float :returns: Stellar contamination factor as a function of wl. :rtype: epsilon (np.array of float)