POSEIDON.absorption =================== .. py:module:: POSEIDON.absorption .. autoapi-nested-parse:: Functions for cross section and extinction coefficient calculations. Attributes ---------- .. autoapisummary:: POSEIDON.absorption.cp Functions --------- .. autoapisummary:: POSEIDON.absorption.P_interpolate_wl_initialise_sigma POSEIDON.absorption.wl_initialise_cia POSEIDON.absorption.T_interpolation_init POSEIDON.absorption.T_interpolate_sigma POSEIDON.absorption.T_interpolate_cia POSEIDON.absorption.refractive_index POSEIDON.absorption.King_correction POSEIDON.absorption.Rayleigh_cross_section POSEIDON.absorption.H_minus_bound_free POSEIDON.absorption.H_minus_free_free POSEIDON.absorption.opacity_tables POSEIDON.absorption.extinction POSEIDON.absorption.extinction_GPU POSEIDON.absorption.interpolate_cia_LBL POSEIDON.absorption.interpolate_sigma_LBL POSEIDON.absorption.store_Rayleigh_eta_LBL POSEIDON.absorption.compute_kappa_LBL POSEIDON.absorption.extinction_LBL Module Contents --------------- .. py:data:: cp .. py:function:: P_interpolate_wl_initialise_sigma(N_P_fine, N_T, N_P, N_wl, log_sigma, x, nu_model, b1, b2, nu_opac, N_nu, wl_interp='sample') Interpolates raw cross section onto the desired P and wl grids. Input sigma has format log10(cross_sec)[log(P)_grid, T_grid, nu_grid], whilst output has format cross_sec[log(P)_pre, T_grid, wl_model]. The input is in wavenumber to take advantage of fast prior index location on a uniform grid, which wouldn't work for the (non-uniform) wavelength grid. Array reversal to output in increasing wavelength is handled by indexing by a factor of (N_wl-1)-k throughout . If N_P_fine = N_layer, then pressure interpolation is onto the model P grid. However, the low sensitivity to small pressure variations means that empirical tests have shown that pre-interpolation to N_P_fine >= 0.28*N_layer and simply choosing the nearest element in log(P)_pre results in minimal errors. This has the advantage of lowering memory usage. Wavelength initialisation is handled via opacity sampling (i.e. setting the cross section to the nearest pre-computed wavelength point) or linear interpolation over wavenumber. .. py:function:: wl_initialise_cia(N_T_cia, N_wl, log_cia, nu_model, nu_cia, N_nu, wl_interp='sample') Interpolates raw collisionally-induced absorption (CIA) binary cross section onto the desired model wl grid. Input cia has format log10(alpha)[T_grid, nu_grid], whilst output has format alpha[T_grid, wl_model]. The input is in wavenumber to take advantage of fast prior index location on a uniform grid, which wouldn't work for the (non-uniform) wavelength grid. Array reversal to output in increasing wavelength is handled by indexing by a factor of (N_wl-1)-k throughout . Wavelength initialisation is handled via either opacity sampling (choosing nearest pre-computed wavelength point) or linear interpolation over wavenumber. .. py:function:: T_interpolation_init(N_T_fine, T_grid, T_fine, y) Precomputes the T interpolation weight factors, so this does not need to be done multiple times across all species. .. py:function:: T_interpolate_sigma(N_P_fine, N_T_fine, N_T, N_wl, sigma_pre_inp, T_grid, T_fine, y, w_T) Interpolates pre-processed cross section onto the fine T grid. Note: input sigma has format cross_sec[log(P)_pre, T_grid, wl_model], whilst output has format cross_sec[log(P)_pre, T_fine, wl_model]. Output is the interpolated cross section as a 3D array. .. py:function:: T_interpolate_cia(N_T_fine, N_T_cia, N_wl, cia_pre_inp, T_grid_cia, T_fine, y, w_T) Interpolates pre-processed collisionally-induced absorption (CIA) binary cross section onto the fine T grid. Note: input sigma has format alpha[T_grid, wl_model], whilst output has format alpha[T_fine, wl_model]. Output is the interpolated cia cross section as a 2D array. .. py:function:: refractive_index(wl, n_ref, species) Computes the refractive index of a molecule / atom at a set of wavelengths for standard conditions (T = 273.15K / P = 1 atm). 'eta' is refractive index, as 'n' is reserved for number density. Inputs: wl => array of wavelength values (um) n_ref => number density at standard reference conditions (cm^-3) species => string specifying chosen chemical species Outputs: eta => refractive index array as a function of wavelength .. py:function:: King_correction(wl, species) Computes the King correction factor of a molecule / atom at a set of wavelengths. This accounts for depolarisation effects in Rayleigh scattering due to the non-spherical nature of atoms / molecules. Inputs: wl => array of wavelength values (um) species => string specifying chosen chemical species Outputs: F => King correction factor array as a function of wavelength .. py:function:: Rayleigh_cross_section(wl, species) Compute Rayleigh scattering cross section of a molecule / atom at a set of wavelengths, accounting for depolarisation effects where available. Note: 'eta' is used for refractive index, as 'n' is reserved for number density. Inputs: wl => array of wavelength values in spectral model (um) species => string specifying chosen chemical species Outputs: sigma_Rayleigh => refractive index array as function of wavelength eta => refractive index array as function of wavelength .. py:function:: H_minus_bound_free(wl_um) Computes the bound-free cross section (alpha_bf) of the H- ion as a function of wavelength. The fitting function is taken from "Continuous absorption by the negative hydrogen ion reconsidered" (John, 1988). The extinction coefficient (in m^-1) can then be calculated via: alpha_bf * n_(H-) [i.e. multiply by the H- number density (in m^-3) ]. Inputs: wl_um => array of wavelength values (um) Outputs: alpha_bf => bound-free H- cross section (m^2 / n_(H-) ) at each input wavelength .. py:function:: H_minus_free_free(wl_um, T_arr) Computes the free-free cross section (alpha_ff) of the H- ion as a function of wavelength. The fitting function is taken from "Continuous absorption by the negative hydrogen ion reconsidered" (John, 1988). The extinction coefficient (in m^-1) can then be calculated via: alpha_ff * n_H * n_(e-) [i.e. multiply by the H and e- number densities (both in in m^-3) ]. Inputs: wl_um => array of wavelength values (um) T_arr => array of temperatures (K) Outputs: alpha_ff => free-free H- cross section (m^5 / n_H / n_e-) for each input wavelength and temperature .. py:function:: opacity_tables(rank, comm, wl_model, chemical_species, active_species, cia_pairs, ff_pairs, bf_species, aerosol_species, cloud_model, T_fine, log_P_fine, opacity_database='High-T', wl_interp='sample', testing=False, database_version='1.3', lognormal_logwidth_free=False) Initialisation function to read in and pre-interpolate all opacities. TBD: write up to date docstring. .. py:function:: extinction(chemical_species, active_species, cia_pairs, ff_pairs, bf_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) 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. .. py:function:: extinction_GPU(kappa_gas, kappa_Ray, kappa_cloud, i_bot, N_species, N_species_active, N_cia_pairs, N_ff_pairs, N_bf_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, P_deep=1000.0) 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. .. py:function:: interpolate_cia_LBL(P, log_cia, nu_model, nu_cia, T, T_grid_cia, N_T_cia, N_wl, N_nu, y, w_T) Interpolates a collisionally-induced absorption (CIA) binary cross section onto the T value in each layer of the model atmosphere. Special function optimised for line-by-line case. .. py:function:: interpolate_sigma_LBL(log_sigma, nu_model, nu_opac, P, T, log_P_grid, T_grid, N_T, N_P, N_wl, N_nu, y, w_T) Interpolates a cross section onto the (P,T) values in each layer of the model atmosphere. Special function optimised for line-by-line case. .. py:function:: store_Rayleigh_eta_LBL(wl_model, chemical_species) In line-by-line case, output refractive index array (eta) and Rayleigh scattering separately from main extinction calculation. This is simply to pass eta to profiles.py, where it is needed. .. py:function:: compute_kappa_LBL(j, k, wl_model, X, X_active, X_cia, X_ff, X_bf, n, P, a, gamma, P_cloud, kappa_cloud_0, N_species, N_species_active, N_cia_pairs, N_ff_pairs, N_bf_species, sigma_interp, cia_interp, Rayleigh_stored, ff_stored, bf_stored, enable_haze, enable_deck, enable_surface, kappa_gas, kappa_Ray, kappa_cloud, P_surf, disable_continuum) Computes extinction coefficients for given sector and zone. Special function optimised for line-by-line case. .. py:function:: extinction_LBL(chemical_species, active_species, cia_pairs, ff_pairs, bf_species, n, T, P, wl_model, X, X_active, X_cia, X_ff, X_bf, a, gamma, P_cloud, kappa_cloud_0, Rayleigh_stored, enable_haze, enable_deck, enable_surface, N_sectors, N_zones, P_surf, opacity_database='High-T', disable_continuum=False, suppress_print=False, database_version='1.3') Evaluate extinction coefficients for molecules / atoms, Rayleigh scattering, hazes, and clouds. Special function optimised for line-by-line case. Here, kappa = n[layer] * sigma[P_layer, T_layer, wl], where the cross sections are all evaluated on their native (line-by-line) wavenumber resolution with interpolation to the T and P in each layer. The output extinction coefficient arrays are given as a function of layer number (indexed from low to high altitude), atmospheric sector, atmospheric zone, and wavelength.