POSEIDON.contributions ====================== .. py:module:: POSEIDON.contributions Attributes ---------- .. autoapisummary:: POSEIDON.contributions.cp POSEIDON.contributions.comm POSEIDON.contributions.rank POSEIDON.contributions.block POSEIDON.contributions.thread Functions --------- .. autoapisummary:: POSEIDON.contributions.wl_grid_constant_R POSEIDON.contributions.check_atmosphere_physical POSEIDON.contributions.extinction_spectral_contribution POSEIDON.contributions.spectral_contribution POSEIDON.contributions.plot_spectral_contribution POSEIDON.contributions.extinction_pressure_contribution POSEIDON.contributions.pressure_contribution_compute_spectrum POSEIDON.contributions.pressure_contribution POSEIDON.contributions.plot_pressure_contribution POSEIDON.contributions.photometric_contribution_function POSEIDON.contributions.plot_photometric_contribution Module Contents --------------- .. py:data:: cp .. py:data:: comm .. py:data:: rank .. py:data:: block .. py:data:: thread .. py:function:: wl_grid_constant_R(wl_min, wl_max, R) Create a wavelength array with constant spectral resolution (R = wl/dwl). :param wl_min: Minimum wavelength of grid (μm). :type wl_min: float :param wl_max: Maximum wavelength of grid (μm). :type wl_max: float :param R: Spectral resolution of desired wavelength grid. :type R: int or float :returns: Model wavelength grid (μm). :rtype: wl (np.array of float) .. py:function:: check_atmosphere_physical(atmosphere, opac) Checks that a specific model atmosphere is physical. :param atmosphere: Collection of atmospheric properties. :type atmosphere: dict :param opac: Collection of cross sections and other opacity sources. :type opac: dict :returns: True if atmosphere physical, otherwise False. :rtype: Bool .. py:function:: extinction_spectral_contribution(chemical_species, active_species, cia_pairs, ff_pairs, bf_species, aerosol_species, n, T, P, wl, X, X_active, X_cia, X_ff, X_bf, a, gamma, P_cloud, kappa_cloud_0, sigma_stored, cia_stored, Rayleigh_stored, ff_stored, bf_stored, enable_haze, enable_deck, enable_surface, N_sectors, N_zones, T_fine, log_P_fine, P_surf, enable_Mie, n_aerosol_array, sigma_Mie_array, P_deep=1000.0, contribution_species='', bulk_species=False, cloud_contribution=False, cloud_species='', cloud_total_contribution=False) Main function to evaluate extinction coefficients for molecules / atoms, Rayleigh scattering, hazes, and clouds for parameter combination chosen in retrieval step. Takes in cross sections pre-interpolated to 'fine' P and T grids before retrieval run (so no interpolation is required at each step). Instead, for each atmospheric layer the extinction coefficient is simply kappa = n * sigma[log_P_nearest, T_nearest, wl], where the 'nearest' values are the closest P_fine, T_fine points to the actual P, T values in each layer. This results in a large speed gain. The output extinction coefficient arrays are given as a function of layer number (indexed from low to high altitude), terminator sector, and wavelength. In the spectral contribution plots, each extinction coefficient is turned off except for the one being analysed. .. py:function:: spectral_contribution(planet, star, model, atmosphere, opac, wl, spectrum_type='transmission', save_spectrum=False, disable_continuum=False, suppress_print=False, Gauss_quad=2, use_photosphere_radius=True, device='cpu', y_p=np.array([0.0]), contribution_species_list=[], bulk_species=True, cloud_contribution=False, cloud_species_list=[], cloud_total_contribution=False) Calculate extinction coefficients, then solve the radiative transfer equation to compute the spectrum of the model atmosphere in order to get the spectral contribution of each species. :param planet: Collection of planetary properties used by POSEIDON. :type planet: dict :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param model: A specific description of a given POSEIDON model. :type model: dict :param atmosphere: Collection of atmospheric properties. :type atmosphere: dict :param opac: Collection of cross sections and other opacity sources. :type opac: dict :param wl: Model wavelength grid (μm). :type wl: np.array of float :param spectrum_type: The type of spectrum for POSEIDON to compute (Options: transmission / emission / direct_emission / transmission_time_average). :type spectrum_type: str :param save_spectrum: If True, writes the spectrum to './POSEIDON_output/PLANET/spectra/'. :type save_spectrum: bool :param disable_continuum: If True, turns off CIA and Rayleigh scattering opacities. :type disable_continuum: bool :param suppress_print: if True, turn off opacity print statements (in line-by-line mode). :type suppress_print: bool :param Gauss_quad: Gaussian quadrature order for integration over emitting surface * Only for emission spectra * (Options: 2 / 3). :type Gauss_quad: int :param use_photosphere_radius: If True, use R_p at tau = 2/3 for emission spectra prefactor. :type use_photosphere_radius: bool :param device: Experimental: use CPU or GPU (only for emission spectra) (Options: cpu / gpu) :type device: str :param y_p: Coordinate of planet centre along orbit at the time the spectrum is computed (y_p = 0, the default, corresponds to mid-transit). For non-grazing transits of uniform stellar disks, the spectrum is identical at all times due to translational symmetry, so y_p = 0 is good for all times post second contact and pre third contact. Units are in m, not in stellar radii. :type y_p: np.array of float :param contribution_species_list: List of gas species to analyze the spectral contribution of :type contribution_species_list: np.array of string :param bulk_species: If true, will compute the spectral contribution of the bulk species :type bulk_species: bool :param cloud_contribution: If true, will compute the spectral contribution of clouds (either parameterized or aerosols) :type cloud_contribution: bool :param cloud_species_list: List of aerosols to analyze the spectral contribution of. Cloud_contribution must be True :type cloud_species_list: np.array of string :param cloud_total_contribution: If true, will compute spectral contribution of combined clouds If using parameterized clouds, this bool will need to be true (to show deck + haze, for example) If using aerosols, will compute combined aerosol spectral contribution :type cloud_total_contribution: bool :returns: The spectrum of the atmosphere (transmission or emission). spectrum_contribution_list_names (np.array of string): Array used for plotting (contains names and order of spectral contribution spectra) spectrum_contribution_list (np.array of float): Array of spectra, each corresponding to the spectral contribution of a species in the list_names array. :rtype: spectrum (np.array of float) .. py:function:: plot_spectral_contribution(planet, wl, spectrum, spectrum_contribution_list_names, spectrum_contribution_list, full_spectrum_first=True, y_unit='transit_depth', brightness_temperature=False, star=None, y_min=None, y_max=None, figure_shape='wide', save_fig=False, line_width_list=[], colour_list=[], return_fig=False, ax=None, file_label=None, fill_between=[], fill_between_alpha=0.5, fill_to_spectrum=[], data=None, spectra_labels=[], dark_mode=False, **kwargs) Plot the spectral contributions directly from the spectral_contribution() outputs :param planet: Collection of planetary properties used by POSEIDON. :type planet: dict :param wl: Model wavelength grid (μm). :type wl: np.array of float :param spectrum: The spectrum of the atmosphere (transmission or emission). :type spectrum: np.array of float :param spectrum_contribution_list_names: Array used for plotting (contains names and order of spectral contribution spectra) :type spectrum_contribution_list_names: np.array of string :param spectrum_contribution_list: Array of spectra, each corresponding to the spectral contribution of a species in the list_names array. :type spectrum_contribution_list: np.array of float :param full_spectrum_first: If True, the full spectrum will be plotted first (behind all other spectra) :type full_spectrum_first: bool :param y_unit: The unit of the y-axis (Options: 'transit_depth', 'eclipse_depth', '(Rp/Rs)^2', '(Rp/R*)^2', 'Fp/Fs', 'Fp/F*', 'Fp'). :type y_unit: str, optional :param brightness_temperature: If True, will convert spectrum and spectrum_contribution_list_names to brightness temperature :type brightness_temperature: bool, optional :param star: Collection of stellar properties used by POSEIDON. For converting secondary eclipse spectra into brightness temperature :type star: dict, optional :param y_min: The minimum value for the y-axis. :type y_min: float, optional :param y_max: The maximum value for the y-axis. :type y_max: float, optional :param figure_shape: The shape of the figure ('default' or 'wide' - the latter is 16:9). :type figure_shape: str, optional :param save_fig: If True, saves a PDF in the POSEIDON output folder. :type save_fig: bool, optional :param line_width_list: Optional line widths. We recommend the full spectra be larger than the contributing ones :type line_width_list: array of floats, optional :param colour_list: A list of colours for the model spectra :type colour_list: list, optional :param return_fig: Returns the fig object, in case you want it in the notebook to manipulate :type return_fig: bool, optional :param ax: Matplotlib axis provided externally. :type ax: matplotlib axis object, optional :param file_label: Optional label to append to end of the output file name. :type file_label: str, optional :param dark_mode: If True, uses a dark background with white text and axes. Defaults to False (light mode). :type dark_mode: bool, optional .. py:function:: extinction_pressure_contribution(chemical_species, active_species, cia_pairs, ff_pairs, bf_species, aerosol_species, n, T, P, wl, X, X_active, X_cia, X_ff, X_bf, a, gamma, P_cloud, kappa_cloud_0, sigma_stored, cia_stored, Rayleigh_stored, ff_stored, bf_stored, enable_haze, enable_deck, enable_surface, N_sectors, N_zones, T_fine, log_P_fine, P_surf, enable_Mie, n_aerosol_array, sigma_Mie_array, P_deep=1000.0, contribution_species='', bulk_species=False, cloud_contribution=False, cloud_species='', cloud_total_contribution=False, layer_to_ignore=0, total_pressure_contribution=False) Main function to evaluate extinction coefficients for molecules / atoms, Rayleigh scattering, hazes, and clouds for parameter combination chosen in retrieval step. Takes in cross sections pre-interpolated to 'fine' P and T grids before retrieval run (so no interpolation is required at each step). Instead, for each atmospheric layer the extinction coefficient is simply kappa = n * sigma[log_P_nearest, T_nearest, wl], where the 'nearest' values are the closest P_fine, T_fine points to the actual P, T values in each layer. This results in a large speed gain. The output extinction coefficient arrays are given as a function of layer number (indexed from low to high altitude), terminator sector, and wavelength. For pressure contribution, it goes row by row And removes the opacity (either total or individual species) from that row .. py:function:: pressure_contribution_compute_spectrum(planet, star, model, atmosphere, opac, wl, spectrum_type='transmission', save_spectrum=False, disable_continuum=False, suppress_print=False, Gauss_quad=2, use_photosphere_radius=True, device='cpu', y_p=np.array([0.0]), contribution_species_list=[], bulk_species=True, cloud_contribution=False, cloud_species_list=[], cloud_total_contribution=False, total_pressure_contribution=False, layer_to_ignore=0) Calculate extinction coefficients, then solve the radiative transfer equation to compute the spectrum of the model atmosphere. In the pressure contribution plots, the extinction coefficient in one pressure layer (either total or individual species) is turned off and the spectrum is recomputed Note that this function is called by pressure_contribution, which loops over all pressure layers Though it can be called by a user, to calculate the contribution for a single pressure layer :param planet: Collection of planetary properties used by POSEIDON. :type planet: dict :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param model: A specific description of a given POSEIDON model. :type model: dict :param atmosphere: Collection of atmospheric properties. :type atmosphere: dict :param opac: Collection of cross sections and other opacity sources. :type opac: dict :param wl: Model wavelength grid (μm). :type wl: np.array of float :param spectrum_type: The type of spectrum for POSEIDON to compute (Options: transmission / emission / direct_emission / transmission_time_average). :type spectrum_type: str :param save_spectrum: If True, writes the spectrum to './POSEIDON_output/PLANET/spectra/'. :type save_spectrum: bool :param disable_continuum: If True, turns off CIA and Rayleigh scattering opacities. :type disable_continuum: bool :param suppress_print: if True, turn off opacity print statements (in line-by-line mode). :type suppress_print: bool :param Gauss_quad: Gaussian quadrature order for integration over emitting surface * Only for emission spectra * (Options: 2 / 3). :type Gauss_quad: int :param use_photosphere_radius: If True, use R_p at tau = 2/3 for emission spectra prefactor. :type use_photosphere_radius: bool :param device: Experimental: use CPU or GPU (only for emission spectra) (Options: cpu / gpu) :type device: str :param y_p: Coordinate of planet centre along orbit at the time the spectrum is computed (y_p = 0, the default, corresponds to mid-transit). For non-grazing transits of uniform stellar disks, the spectrum is identical at all times due to translational symmetry, so y_p = 0 is good for all times post second contact and pre third contact. Units are in m, not in stellar radii. :type y_p: np.array of float :param contribution_species_list: List of gas species to analyze the pressure contribution of :type contribution_species_list: np.array of string :param bulk_species: If true, will compute the pressure contribution of the bulk species :type bulk_species: bool :param cloud_contribution: If true, will compute the pressure contribution of clouds (either parameterized or aerosols) :type cloud_contribution: bool :param cloud_species_list: List of aerosols to analyze the pressure contribution of. Cloud_contribution must be True :type cloud_species_list: np.array of string :param cloud_total_contribution: If true, will compute pressure contribution of combined clouds If using parameterized clouds, this bool will need to be true (to show deck + haze, for example) If using aerosols, will compute combined aerosol pressure contribution :type cloud_total_contribution: bool :param total_pressure_contribution: If true, will compute the pressure contribution by removing all opacity from each layer :type total_pressure_contribution: bool :param layer_to_ignore: The pressure layer whose opacity will be turned off. Looped over in pressure_contribution() :type layer_to_ignore: int :returns: The spectrum of the atmosphere (transmission or emission). spectrum_contribution_list_names (np.array of string): Array used for plotting (contains names and order of pressure contribution spectra) spectrum_contribution_list (np.array of float): Array of spectra, each corresponding to the pressure contribution of a species in the list_names array. :rtype: spectrum (np.array of float) .. py:function:: pressure_contribution(planet, star, model, atmosphere, opac, wl, spectrum_type='transmission', save_spectrum=False, disable_continuum=False, suppress_print=False, Gauss_quad=2, use_photosphere_radius=True, device='cpu', y_p=np.array([0.0]), contribution_species_list=[], bulk_species=True, cloud_contribution=False, cloud_species_list=[], cloud_total_contribution=False, total_pressure_contribution=False, verbose=False) Computes the pressure contribution function by looping over each layer in the Pressure array :param planet: Collection of planetary properties used by POSEIDON. :type planet: dict :param star: Collection of stellar properties used by POSEIDON. :type star: dict :param model: A specific description of a given POSEIDON model. :type model: dict :param atmosphere: Collection of atmospheric properties. :type atmosphere: dict :param opac: Collection of cross sections and other opacity sources. :type opac: dict :param wl: Model wavelength grid (μm). :type wl: np.array of float :param spectrum_type: The type of spectrum for POSEIDON to compute (Options: transmission / emission / direct_emission / transmission_time_average). :type spectrum_type: str :param save_spectrum: If True, writes the spectrum to './POSEIDON_output/PLANET/spectra/'. :type save_spectrum: bool :param disable_continuum: If True, turns off CIA and Rayleigh scattering opacities. :type disable_continuum: bool :param suppress_print: if True, turn off opacity print statements (in line-by-line mode). :type suppress_print: bool :param Gauss_quad: Gaussian quadrature order for integration over emitting surface * Only for emission spectra * (Options: 2 / 3). :type Gauss_quad: int :param use_photosphere_radius: If True, use R_p at tau = 2/3 for emission spectra prefactor. :type use_photosphere_radius: bool :param device: Experimental: use CPU or GPU (only for emission spectra) (Options: cpu / gpu) :type device: str :param y_p: Coordinate of planet centre along orbit at the time the spectrum is computed (y_p = 0, the default, corresponds to mid-transit). For non-grazing transits of uniform stellar disks, the spectrum is identical at all times due to translational symmetry, so y_p = 0 is good for all times post second contact and pre third contact. Units are in m, not in stellar radii. :type y_p: np.array of float :param contribution_species_list: List of gas species to analyze the pressure contribution of :type contribution_species_list: np.array of string :param bulk_species: If true, will compute the pressure contribution of the bulk species :type bulk_species: bool :param cloud_contribution: If true, will compute the pressure contribution of clouds (either parameterized or aerosols) :type cloud_contribution: bool :param cloud_species_list: List of aerosols to analyze the pressure contribution of. Cloud_contribution must be True :type cloud_species_list: np.array of string :param cloud_total_contribution: If true, will compute pressure contribution of combined clouds If using parameterized clouds, this bool will need to be true (to show deck + haze, for example) If using aerosols, will compute combined aerosol pressure contribution :type cloud_total_contribution: bool :param total_pressure_contribution: If true, will compute the pressure contribution by removing all opacity from each layer :type total_pressure_contribution: bool :returns: Contribution (np.array) Array. [i,j,k] i = molecule number (or total if total = True), j = Pressure layer, k = Wavelength norm (np.array) Array [i,j] where i = molecule number and j = wavelength. If user wants to normalize them (not used in our code) spectrum_contribution_list_names (np.array of string): Array used for plotting (contains names and order of spectral contribution spectra) .. py:function:: plot_pressure_contribution(wl, P, planet, Contribution, spectrum_contribution_list_names, R=100, return_fig=False, save_fig=False, show_log_plot=False, file_label=None, dark_mode=False) Plot the pressure contributions directly from the pressure_contribution() outputs :param wl: Model wavelength grid (μm). :type wl: np.array of float :param P: Model pressure grid (bar). (From atmosphere['P']) :type P: np.array of float :param Contribution: Array. [i,j,k] i = molecule number (or total if total = True), j = Pressure layer, k = Wavelength :type Contribution: np.array :param spectrum_contribution_list_names: Array used for plotting (contains names and order of spectral contribution spectra) :type spectrum_contribution_list_names: np.array of string :param R: Spectral resolution (R = wl/dwl) to bin the model spectra to. :type R: int, optional :param return_fig: Returns the fig object, in case you want it in the notebook to manipulate :type return_fig: bool, optional :param save_fig: If True, saves a PDF in the POSEIDON output folder. :type save_fig: bool, optional :param show_log_plot: If True, will also show the log plot of the contribution function. :type show_log_plot: bool, optional :param file_label: Optional label to append to end of the output file name. :type file_label: str, optional :param dark_mode: If True, uses a dark background with white text and axes. Defaults to False (light mode). :type dark_mode: bool, optional .. py:function:: photometric_contribution_function(wl, P, Contribution, spectrum_contribution_list_names, binsize=1, treat_wlmin_as_zero=False) Computes the photometric contribution directly from the pressure_contribution() outputs (a photometric contribution is just the integral average over wavelengths, i.e. the mean) :param wl: Model wavelength grid (μm). :type wl: np.array of float :param P: Model pressure grid (bar). (From atmosphere['P']) :type P: np.array of float :param Contribution: Array. [i,j,k] i = molecule number (or total if total = True), j = Pressure layer, k = Wavelength :type Contribution: np.array :param spectrum_contribution_list_names: Array used for plotting (contains names and order of spectral contribution spectra) :type spectrum_contribution_list_names: np.array of string :param binsize: The size of the wavelength bin :type binsize: float :param treat_wlmin_as_zero: If True, will set wl_min as 0 before binning (makes bins look nicer than 0.2 to 1.2 um) :type treat_wlmin_as_zero: bool, optional :returns: Array of each photometric contribution function, corresponding to the wavelength bins photometric_all_wavelengths (np.array of floats): Array containing photometric contributions across all wavelengths bins (np.array of floats): Wavelength bins (wl_min and wl_max for each bin) (for plotting) :rtype: photometric_contribution (np.array of floats) .. py:function:: plot_photometric_contribution(P, planet, photometric_contribution, photometric_all_wavelengths, spectrum_contribution_list_names, bins=[], return_fig=False, save_fig=False, file_label=None, dark_mode=False) Plots the photometric contributions directly from outputs of photometric_contribution_function() :param wl: Model wavelength grid (μm). :type wl: np.array of float :param P: Model pressure grid (bar). (From atmosphere['P']) :type P: np.array of float :param photometric_contribution: Array of each photometric contribution function, corresponding to the wavelength bins :type photometric_contribution: np.array of floats :param photometric_all_wavelengths: Array containing photometric contributions across all wavelengths :type photometric_all_wavelengths: np.array of floats :param spectrum_contribution_list_names: Array used for plotting (contains names and order of spectral contribution spectra) :type spectrum_contribution_list_names: np.array of string :param bins: Wavelength bins (wl_min and wl_max for each bin) (for plotting and the legend) :type bins: np.array of floats :param return_fig: Returns the fig object, in case you want it in the notebook to manipulate. :type return_fig: bool, optional :param save_fig: If True, saves a PDF in the POSEIDON output folder. :type save_fig: bool, optional :param file_label: Optional label to append to end of the output file name. :type file_label: str, optional :param dark_mode: If True, uses a dark background with white text and axes. Defaults to False (light mode). :type dark_mode: bool, optional