POSEIDON.clouds
Functions that are used to incorporate aerosols into POSEIDON
Attributes
Functions
|
Create a wavelength array with constant spectral resolution (R = wl/dwl). |
|
|
|
Plots the effective extinction cross section of an aerosol in the database |
|
Plots the number density of an aerosol above a fuzzy deck |
|
Loads in the refractive indices from a text file (columns : wl n k) |
|
Plots the refractive indices from a txt file (columns : wl n k) |
Plots the effective cross sections from a txt file (columns : wl n k) |
|
Plots the effective cross sections for a constant (with wavelength) refractive index |
|
|
Plots how the aerosols look like in the forward model atmosphere. |
|
Plots the lognormal distribution (which points are computed and integrated over) |
|
Plots the refractive index and aerosol properties in the aerosol database (same format as aerosol-database.pdf) |
|
This function is utilized in tutorial noteooks to show how turning a knob on a parameter changes a resultant spectrum |
|
|
|
Load a aerosol cross section grid (similar to load_chemistry_grid in chemistry.py) |
|
Interpolate a pre-computed grid of aerosol cross sections |
|
Calculates the number density n(P) and cross section sigma(wavelength) for different aerosol cloud models |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calculates the number density n(P) and cross section sigma(wavelength) for different aerosol cloud models |
|
Calculates .npy files from a refractive index txt file (lab data) |
Calculates .npy files from a refractive index txt file (lab data) |
|
Calculates and returns the effective cross section from an input wl grid, real and imaginary indices array |
|
|
|
|
Same as precompute_cross_sections_one_aerosol_custom except it uses miepython instead of LX-MIE (much faster) |
Calculates and returns the effective cross section from an input wl grid, real and imaginary indices array |
|
Regenerates the aerosol_database from all npy files in input/aerosol_Mie_properties/ |
|
|
Module Contents
- POSEIDON.clouds.wl_grid_constant_R(wl_min, wl_max, R)
Create a wavelength array with constant spectral resolution (R = wl/dwl).
- Parameters:
wl_min (float) – Minimum wavelength of grid (μm).
wl_max (float) – Maximum wavelength of grid (μm).
R (int or float) – Spectral resolution of desired wavelength grid.
- Returns:
Model wavelength grid (μm).
- Return type:
wl (np.array of float)
- POSEIDON.clouds.find_nearest(array, value)
- POSEIDON.clouds.plot_effective_cross_section_aerosol(aerosol, wl, r_m)
Plots the effective extinction cross section of an aerosol in the database for visualization purposes
- Parameters:
aerosol (string) – Aerosol name
wl (np.array of float) – Model wavelength grid (μm)
r_m (float) – Mean particle sizes (in um)
- Returns:
Outputs a plot of wl (x) vs log effective extincrion cross section (y)
- POSEIDON.clouds.plot_aerosol_number_density_fuzzy_deck(atmosphere, log_P_cloud, log_n_max, fractional_scale_height)
Plots the number density of an aerosol above a fuzzy deck
- Parameters:
atmosphere (dict) – Collection of atmospheric properties.
Arguments (Fuzzy Deck)
log_P_cloud (float) – Cloud Top Pressure (everything below P_cloud is opaque). If cloud coverage is complete, P_cloud is located at R_p
log_n_max (array of float) – Logorithm of maximum number density (at the cloud top)
fractional_scale_height (array of float) – fractional scale height of aerosol
- Returns:
Outputs a plot of pressure (y) versus number density of aerosol (x)
- POSEIDON.clouds.load_refractive_indices_from_file(wl, file_name)
Loads in the refractive indices from a text file (columns : wl n k) Either the first two rows are skipped, or the header is assumed to be comments (‘#’)
- Parameters:
wl (np.array of float) – Model wavelength grid (μm).
file_name (string) – File name (with directory included)
- Returns:
- r_i_real (np.array of float)
Array with the loaded in real indices interpolated onto wl_Mie
- r_i_complex (np.array of float)
Array with the loaded in imaginary indices interpolated onto wl_Mie
- POSEIDON.clouds.plot_refractive_indices_from_file(wl, file_name, species=None)
Plots the refractive indices from a txt file (columns : wl n k) Either the first two rows are skipped, or the header is assumed to be comments (‘#’)
- Parameters:
wl (np.array of float) – Model wavelength grid (μm).
file_name (string) – File name (with directory included)
species (string, optional) – Species name for the title of the plot.
- Returns:
Outputs a plot of wl (x) vs refractive indices (y)
- POSEIDON.clouds.compute_and_plot_aerosol_cross_section_from_file(wl, r_m, file_name, species=None)
Plots the effective cross sections from a txt file (columns : wl n k) Either the first two rows are skipped, or the header is assumed to be comments (‘#’)
This function precomputes the cross sections directly, and plots them
- Parameters:
wl (np.array of float) – Model wavelength grid (μm).
r_m (float) – Mean particle size (um).
file_name (string) – File name (with directory included).
species (string, optional) – Species name for the title of the plot.
- Returns:
Outputs a plot of wl (x) vs different cross sections, asymmetry parameter, and single scattering albedo (y)
- POSEIDON.clouds.compute_and_plot_effective_cross_section_constant(wl, r_m, r_i_real, r_i_complex)
Plots the effective cross sections for a constant (with wavelength) refractive index
This function precomputes the cross sections directly, and plots them
- Parameters:
wl (np.array of float) – Model wavelength grid (μm).
r_m (float) – Mean particle size (um)
r_i_real (float) – Real refractive index (only used for constant, free refractive index)
r_i_complex (float) – Complex refractive index (only used for constant, free refractive index)
- Returns:
Outputs a plot of wl (x) vs effective extinction cross section (y)
- POSEIDON.clouds.plot_clouds(planet, model, atmosphere, colour_list=[])
Plots how the aerosols look like in the forward model atmosphere. Very similar to how plot_PT or plot_chem work
This function precomputes the cross sections directly, and plots them
- Parameters:
planet (dict) – Collection of planetary properties used by POSEIDON.
model (dict) – A specific description of a given POSEIDON model.
atmosphere (dict) – Collection of atmospheric properties.
colour_list (list, optional) – List of colours for each retrieved chemical profile.
- Returns:
Outputs a plot of mixing ratio (x) vs pressure (y)
- POSEIDON.clouds.plot_lognormal_distribution(r_m_std_dev=0.5)
Plots the lognormal distribution (which points are computed and integrated over)
- Parameters:
r_m_std_dev (float) – Width of the lognormal distribution
- Returns:
Outputs a plot particle size distributions
- POSEIDON.clouds.database_properties_plot(file_name)
Plots the refractive index and aerosol properties in the aerosol database (same format as aerosol-database.pdf)
- Parameters:
file_name (string) – Name of refractive index file, with file path included
- Returns:
Outputs a plot of refractive index, sigma_ext,eff, g, and w for an aerosol in the database
- POSEIDON.clouds.vary_one_parameter(model, planet, star, param_name, vary_list, wl, opac, P, P_ref, R_p_ref, PT_params_og, log_X_params_og, cloud_params_og, spectrum_type='transmission', y_min=None, y_max=None, y_unit='transit_depth', wl_max=None)
This function is utilized in tutorial noteooks to show how turning a knob on a parameter changes a resultant spectrum
- Parameters:
model (dict) – A specific description of a given POSEIDON model.
planet (dict) – Collection of planetary properties used by POSEIDON.
star (dict) – Collection of stellar properties used by POSEIDON.
param_name (string) – Name of the parameter to vary
vary_list (array of float) – Array containing values to test
wl (np.array of float) – Model wavelength grid (μm).
opac (dict) – Collection of cross sections and other opacity sources.
P (np.array of float) – Model pressure grid (bar).
P_ref (float) – Reference pressure (bar).
R_p_ref (float) – Planet radius corresponding to reference pressure (m).
PT_params_og (np.array of float) – Original parameters defining the pressure-temperature field.
log_X_params_og (np.array of float) – Original parameters defining the log-mixing ratio field.
cloud_params_og (np.array of float) – Original parameters defining atmospheric aerosols.
spectrum_type (str) –
The type of spectrum for POSEIDON to compute (Options: transmission / emission / direct_emission /
transmission_time_average).
y_min (float) – Minimum value for the y-axis.
y_max (float) – Maximum value for the y-axis.
y_unit (str) – The unit of the y-axis (Options: ‘transit_depth’, ‘eclipse_depth’, ‘(Rp/Rs)^2’, ‘(Rp/R*)^2’, ‘Fp/Fs’, ‘Fp/F*’, ‘Fp’).
- Returns:
Outputs a plot of resultant spectra with the param_name at the vary_list values.
- POSEIDON.clouds.compute_relevant_Mie_properties(model, aerosol_species, aerosol_stored, P, wl, r, H, n, r_m, r_i_real, r_i_complex, P_cloud, P_cloud_bottom, log_X_Mie, log_n_max, fractional_scale_height, lognormal_logwidth_free, log_r_m_std_dev)
- POSEIDON.clouds.load_aerosol_grid(aerosol_species, grid='aerosol', comm=MPI.COMM_WORLD, rank=0, lognormal_logwith_free=False, sigma_Mie_grid=[], wl_grid=[], r_m_grid=[], log_r_m_std_dev_array=[], loading_opac=False)
Load a aerosol cross section grid (similar to load_chemistry_grid in chemistry.py)
- Parameters:
aerosol_species (list or np.array of str) – List of aerosol species to load mixing ratios from grid.
grid (str) – Name of the pre-computed aerosol cross section grid. The file should be located in the POSEIDON input directory (specified in your .bashrc file) with a name format like ‘GRID_database.hdf5’ (e.g. ‘aerosol_database.hdf5’). By default, POSEIDON ships with an aerosol grid computed from the LX-MIE algorithm: (Options: aerosol).
comm (MPI communicator) – Communicator used to allocate shared memory on multiple cores.
rank (MPI rank) – Rank used to allocate shared memory on multiple cores.
lognormal_logwidth_free (bool) – If log_r_m_std_dev is a free parameter in the grid being used
sigme_Mie_grid (array) – Array to store aerosol properties. Is empty in forward models, or passed by opacity_tables
wl_grid (array) – Array to store aerosol wavelength grid. Is empty in forward models, or passed by opacity_tables
rm_grid (array) – Array to store aerosol radii grid. Is empty in forward models, or passed by opacity_tables
log_r_m_std_dev_array (array) – Array to store aerosol log width grid. Is empty in forward models, or passed by opacity_tables
loading_opac (bool) – If true, is being called in opacity_tables and is just loading in sigma_Mie_grid
- Returns:
Dictionary containing the loaded in aerosol properties.
- Return type:
aerosol_grid (dict)
- POSEIDON.clouds.interpolate_sigma_Mie_grid(aerosol_grid, wl, r_m_array, aerosol_species, return_dict=True, lognormal_logwith_free=False, log_r_m_std_dev=0.5)
Interpolate a pre-computed grid of aerosol cross sections onto a model wl range, and mean particle size.
- Parameters:
aerosol_grid (dict) – Dictionary containing the aerosol cross section database.
wl (np.array of float) – Model wavelength grid (μm).
r_m_array (float) – Mean particle size (in um) (for each aerosol_species)
chemical_species (str or np.array of str) – List of chemical species to interpolate mixing ratios for.
return_dict (bool) – If False, return an array of shape (len(species), len(P_array)). If True, will return a dictionary
- Returns:
- A dictionary of effective cross sections with keys being the same names as
specified in aerosol_species.
- sigma_Mie_interp_array (np.array of float) —> if return_dict=False:
An array containing the effective cross sections for the species specified in aerosol_species.
- Return type:
sigma_Mie_interp_dict (dict) —> if return_dict = True
- POSEIDON.clouds.Mie_cloud(P, wl, r, H, n, r_m, aerosol_species, cloud_type, aerosol_grid=None, P_cloud=0, log_n_max=0, fractional_scale_height=0, log_X_Mie=0, P_cloud_bottom=0, log_r_m_std_dev=0.5, lognormal_logwidth_free=False)
Calculates the number density n(P) and cross section sigma(wavelength) for different aerosol cloud models Also pulls the asymmetry parameter and single scattering albedo Utilized the precomputed, aerosol database Outputs from this function are then utilized to generated extinction coefficients in core.py
- Parameters:
P (np.array of float) – Model pressure grid (bar). (From atmosphere[‘P’])
wl (np.array of float) – Model wavelength grid (μm).
r (3D np.array of float) – Radial distant profile (m). (From atmosphere[‘P’])
H (np.array of float) – gas scale height
n (np.array of float) – total number density array
r_m (np.array of float) – Mean particle sizes (in um)
aerosol_species (np.array of string) – Array with aerosol species in it
cloud_type (string) – uniform_X, fuzzy_deck, slab, opaque_deck_with_slab, fuzzy_deck_with_slab
aerosol_grid (dict) – Precomputed aerosol cross section dictionary If = None, loads it in
------- (-------- Optional Arguments)
Arguments (Slab)
P_cloud (float) – Cloud Top Pressure (everything below P_cloud is opaque). If cloud coverage is complete, P_cloud is located at R_p
log_n_max (array of float) – Logorithm of maximum number density (at the cloud top)
fractional_scale_height (array of float) – fractional scale height of aerosol
Arguments
log_X_Mie (array of float) – Mixing ratio for a mie aerosol (either specified or free, only for uniform haze models)
Arguments
P_cloud – Cloud Top Pressure (everything between P_cloud and P_cloud_bottom is uniform X).
P_cloud_bottom (array of float) – Pressure of the bottom of the slab
-------
log_r_m_std_dev (float) – Geometric standard deviation for particle size
lognormal_logwidth_free (bool) – If True, has log_r_m_std_dev be a free parameter for aerosols. Only applicable for certain aerosols with precomputed grids.
Returns: n_aerosol, sigma_Mie
- POSEIDON.clouds.all_etas = []
- POSEIDON.clouds.all_xs = []
- POSEIDON.clouds.all_Qexts = []
- POSEIDON.clouds.all_Qscats = []
- POSEIDON.clouds.all_Qbacks = []
- POSEIDON.clouds.all_gs = []
- POSEIDON.clouds.wl_Mie_empty
- POSEIDON.clouds.free_or_file = ''
- POSEIDON.clouds.get_iterations_required(xs, c=4.3)
- POSEIDON.clouds.get_An(zs, n)
- POSEIDON.clouds.get_As(max_n, zs)
- POSEIDON.clouds.get_extinctions(m, xs)
- POSEIDON.clouds.get_from_cache(eta, xs, max_frac_error=0.05)
- POSEIDON.clouds.add(eta, xs, Qexts, Qscats, Qbacks, g, size_limit=1000000)
- POSEIDON.clouds.get_and_update(eta, xs)
- POSEIDON.clouds.Mie_cloud_free(P, wl, wl_Mie_in, r, H, n, r_m, r_i_real, r_i_complex, cloud_type, P_cloud=0, log_n_max=0, fractional_scale_height=0, log_X_Mie=0, P_cloud_bottom=-100, r_m_std_dev=0.5, z_max=5, num_integral_points=100, algorithm='miepython')
Calculates the number density n(P) and cross section sigma(wavelength) for different aerosol cloud models Also pulls the asymmetry parameter and single scattering albedo Utilized the LX-Mie algorithm to compute constant refractive index or file_read refractive index files Outputs from this function are then utilized to generated extinction coefficients in core.py
- Parameters:
P (np.array of float) – Model pressure grid (bar). (From atmosphere[‘P’])
wl (np.array of float) – Model wavelength grid (μm).
r (3D np.array of float) – Radial distant profile (m). (From atmosphere[‘P’])
H (np.array of float) – gas scale height
n (np.array of float) – total number density array
r_m (float) – Mean particle sizes (in um)
cloud_type (string) – uniform_X, fuzzy_deck, slab, opaque_deck_with_slab, fuzzy_deck_with_slab
------- (-------- Optional Arguments)
Arguments (Slab)
P_cloud (float) – Cloud Top Pressure (everything below P_cloud is opaque). If cloud coverage is complete, P_cloud is located at R_p
log_n_max (float) – Logorithm of maximum number density (at the cloud top)
fractional_scale_height (float) – fractional scale height of aerosol
Arguments
log_X_Mie (float) – Mixing ratio for a mie aerosol (either specified or free, only for uniform haze models)
r_i_complex (float)
r_i_real (float) – Real refractive index (only used for constant, free refractive index)
r_i_complex – Complex refractive index (only used for constant, free refractive index)
Arguments
P_cloud – Cloud Top Pressure (everything between P_cloud and P_cloud_bottom is uniform X).
P_cloud_bottom (array of float) – Pressure of the bottom of the slab
-------
r_m_std_dev (float) – Geometric standard deviation for particle size
z_max (float) – Maximum z that you want the effective cross section integral carried out over z = [ln(r) - ln(r_m)] / [r_m_std_dev^2], where r is the particle size Integral carried out from -z to z with more density around 0 (size ~ mean size)
num_integral_points (int) – Number of points in the z array
R_Mie (int) – Optional wavelength resolution used to calculate ETA
algorithm (str) – Either ‘LX-MIE’ or ‘miepython’. The second is faster, and therefore the default.
Returns: n_aerosol, sigma_Mie
- POSEIDON.clouds.precompute_cross_sections_one_aerosol_LXMIE(file_name, aerosol_name, saveall=False)
Calculates .npy files from a refractive index txt file (lab data) Takes ~ a day to generate the npy file that then can be easily added to the aerosol database Please ensure that the first two rows are skippable, or that the header is commented out (#) and that the columns are Wavelength (microns) | Real Index | Imaginary Index
For better commented code on how the LX-MIE/PLATON algorithm works, see Mie_cloud_free()
INPUTS
- file_name (txt):
file name of the txt file with the directory included
- aerosol_name (txt):
name that you want the npy file saved with
- saveall (bool):
saves all auxiliary arrays to precomputed_Mie_properties directory
- POSEIDON.clouds.precompute_cross_sections_one_aerosol_custom_LXMIE(file_name, aerosol_name, log_r_m_std_dev=0.5, log_r_m_min=-3, log_r_m_max=1, saveall=False)
Calculates .npy files from a refractive index txt file (lab data) Takes ~ a day to generate the npy file that then can be easily added to the aerosol database Please ensure that the first two rows are skippable, or that the header is commented out (#) and that the columns are Wavelength (microns) | Real Index | Imaginary Index Same as precompute_cross_sections_one_aerosol but allows for customization
For better commented code on how the LX-MIE/PLATON algorithm works, see Mie_cloud_free()
INPUTS
- file_name (txt):
file name of the txt file with the directory included
- aerosol_name (txt):
name that you want the npy file saved with
- r_m_std_dev (float, optional):
standard deviations of the lognormal distributions
- log_r_m_min (float, optional):
mininum radii to be computed
- log_r_m_max (float, optional):
maximum radii to be computed
- POSEIDON.clouds.precompute_cross_sections_from_indices_LXMIE(wl, real_indices_array, imaginary_indices_array, r_m)
Calculates and returns the effective cross section from an input wl grid, real and imaginary indices array And the particle size in um
Allows the user to directly quirey the LX_MIE algorithm with their refractive index data Before running the full precompute cross sections one aerosol function
INPUTS
- wl (np.array of float):
Model wavelength grid (μm).
- real_indices_array (np.array of float):
Real indices
- imaginary_indices_array (np.array of float):
Imaginary indices
- r_m (float) :
Mean particle size (in um)
- POSEIDON.clouds.compute_mie_properties(r_m, wl_Mie, eta_array, r_m_array, ext_array, scat_array, abs_array, back_array, w_array, g_array, z_max, num_integral_points, log_r_m_std_dev, idx_start, idx_end)
- POSEIDON.clouds.precompute_cross_sections_one_aerosol_miepython(file_name, aerosol_name, log_r_m_std_dev=0.5, number_cores=1, log_r_m_min=-3, log_r_m_max=1, saveall=False)
Same as precompute_cross_sections_one_aerosol_custom except it uses miepython instead of LX-MIE (much faster) It also can be run on multiple cores and solve for different particle size distributions
INPUTS
- file_name (txt):
file name of the txt file with the directory included
- aerosol_name (txt):
name that you want the npy file saved with
- log_r_m_std_dev (float, optional):
standard deviations of the lognormal distributions
- number_cores (int, optional):
Number of cores to run things on (makes precomputation much faster)
- log_r_m_min (float, optional):
mininum radii to be computed
- log_r_m_max (float, optional):
maximum radii to be computed
- saveall (bool, optional):
saves all the extra arrays
- POSEIDON.clouds.precompute_cross_sections_from_indices_miepython(wl, real_indices_array, imaginary_indices_array, r_m)
Calculates and returns the effective cross section from an input wl grid, real and imaginary indices array And the particle size in um
Allows the user to directly quirey the miepython algorithm with their refractive index data Before running the full precompute cross sections one aerosol function
INPUTS
- wl (np.array of float):
Model wavelength grid (μm).
- real_indices_array (np.array of float):
Real indices
- imaginary_indices_array (np.array of float):
Imaginary indices
- r_m (float) :
Mean particle size (in um)
- POSEIDON.clouds.make_aerosol_database()
Regenerates the aerosol_database from all npy files in input/aerosol_Mie_properties/ This functionality allows for users to create new eff cross section arrays using precompute_cross_sections_one_aerosol() With their own lab data and add it to the database Assumes the nominal wl_Mie and r_m_array used in the functions above (not custom particle sizes) Takes into account lognormal logwidth used to generate cross sections
- POSEIDON.clouds.switch_aerosol_in_opac(model, opac)