pyROX.line_by_line.lbl#
Classes#
Helper class for line profile calculations. |
|
Base class for line-by-line cross-sections. |
Module Contents#
- class pyROX.line_by_line.lbl.LineProfileHelper#
Helper class for line profile calculations.
- compute_line_strength(T, S_0, E_low, nu_0)#
Calculates the line strength for a given temperature.
- Parameters:
T (float) – Temperature in Kelvin.
S_0 (float) – Line strength at reference temperature.
E_low (float) – Lower state energy in Joules.
nu_0 (float) – Transition frequency in s^-1.
- Returns:
Line strength in s^-1/(molecule m^-2).
- Return type:
float
- normalise_wing_cutoff(S, cutoff_distance, gamma_L)#
Normalises the line strength to account for wing cutoff.
- Parameters:
S (array) – Line strengths.
cutoff_distance (float) – Distance for wing cutoff.
gamma_L (array) – Lorentzian widths.
- Returns:
Normalised line strengths.
- Return type:
array
- pressure_shift(P, T, nu_0, delta=None)#
Applies pressure shift to the transition frequency.
- Parameters:
P (float) – Pressure in Pa.
T (float) – Temperature in Kelvin.
nu_0 (array) – Transition frequencies in s^-1.
delta (float, optional) – Pressure shift coefficient.
- Returns:
Pressure-shifted frequencies.
- Return type:
array
- compute_vdw_broadening(P, T, E_low, **kwargs)#
Calculates Van der Waals broadening.
- Parameters:
P (float) – Pressure in Pa.
T (float) – Temperature in Kelvin.
E_low (float) – Lower state energy in Joules.
**kwargs – Additional parameters.
- Returns:
Van der Waals broadening in s^-1.
- Return type:
float
- compute_natural_broadening(A)#
Calculates natural broadening.
- Parameters:
A (float) – Einstein A-coefficient in s^-1.
- Returns:
Natural broadening in s^-1.
- Return type:
float
- compute_doppler_broadening(T, nu_0)#
Calculates Doppler broadening.
- Parameters:
T (float) – Temperature in Kelvin.
nu_0 (float) – Transition frequency in s^-1.
- Returns:
Doppler broadening in s^-1.
- Return type:
float
- compute_lorentz_width(gamma_vdW, gamma_N)#
Calculates Lorentzian width.
- Parameters:
gamma_vdW (float) – Van der Waals broadening in s^-1.
gamma_N (float) – Natural broadening in s^-1.
- Returns:
Lorentzian width in s^-1.
- Return type:
float
- compute_voigt_width(gamma_G, gamma_L)#
Calculates Voigt width.
- Parameters:
gamma_G (float) – Gaussian width in s^-1.
gamma_L (float) – Lorentzian width in s^-1.
- Returns:
Voigt width in s^-1.
- Return type:
float
- _bin_transitions_for_local_cutoff(nu_0)#
Bins the transitions to the nearest sub-sampled grid point.
- Parameters:
nu_0 (array) – Transition frequencies in s^-1.
- Returns:
Indices of transitions per bin.
- Return type:
array
- apply_local_cutoff(S, nu_0, factor)#
Applies local cutoff to line strengths. Retain lines with a certain fraction of cumulative strength.
- Parameters:
S (array) – Line strengths.
nu_0 (array) – Transition frequencies in s^-1.
factor (float) – Fraction of cumulative strength to retain.
- Returns:
Modified line strengths.
- Return type:
array
- calculate_line_profiles(nu_0, S, gamma_L, gamma_G, nu_grid, wing_cutoff_distance, delta_nu)#
Calculates line profiles in chunks to optimise speed.
- Parameters:
nu_0 (array) – Transition frequencies in s^-1.
S (array) – Line strengths.
gamma_L (array) – Lorentzian widths.
gamma_G (array) – Gaussian widths.
nu_grid (array) – Wavenumber grid.
wing_cutoff_distance (float) – Wing cutoff distance in s^-1.
delta_nu (float) – Wavenumber grid spacing in s^-1.
- Returns:
Opacity cross-section on the grid.
- Return type:
array
- _calculate_line_profiles_one_by_one(nu_0, strength, y, gamma_G, nu_grid, slice_nu_grid)#
Calculates line profiles one by one.
- Parameters:
nu_0 (array) – Transition frequencies in s^-1.
strength (array) – Line strengths.
y (array) – Complex part of Faddeeva coordinate.
gamma_G (array) – Gaussian widths.
nu_grid (array) – Wavenumber grid.
slice_nu_grid (array) – Slices of the wavenumber grid.
- Returns:
Opacity cross-section on the grid.
- Return type:
array
- _calculate_line_profiles_in_chunks(nu_0, S, gamma_L, gamma_G, nu_grid, wing_cutoff_distance, delta_nu, N_lines_in_chunk=1)#
Calculates line profiles in chunks to optimise speed.
- Parameters:
nu_0 (array) – Transition frequencies in s^-1.
S (array) – Line strengths.
gamma_L (array) – Lorentzian widths.
gamma_G (array) – Gaussian widths.
nu_grid (array) – Wavenumber grid.
wing_cutoff_distance (float) – Wing cutoff distance in s^-1.
delta_nu (float) – Wavenumber grid spacing in s^-1.
N_lines_in_chunk (int) – Number of lines to process in each chunk.
- Returns:
Opacity cross-section on the grid.
- Return type:
array
- _calculate_line_profiles_in_chunks_fixed_delta_nu(nu_0, S, gamma_L, gamma_G, nu_grid, wing_cutoff_distance, delta_nu, N_lines_in_chunk=1)#
Calculates line profiles for a fixed wavenumber spacing. This method is more efficient than calculate_line_profiles_in_chunks().
- Parameters:
nu_0 (array) – Transition frequencies in s^-1.
S (array) – Line strengths.
gamma_L (array) – Lorentzian widths.
gamma_G (array) – Gaussian widths.
nu_grid (array) – Wavenumber grid.
wing_cutoff_distance (float) – Wing cutoff distance in s^-1.
delta_nu (float) – Wavenumber grid spacing in s^-1.
N_lines_in_chunk (int) – Number of lines to process in each chunk.
- Returns:
Opacity cross-section on the grid.
- Return type:
array
- class pyROX.line_by_line.lbl.LineByLine(config, **kwargs)#
Bases:
pyROX.CrossSections,LineProfileHelperBase class for line-by-line cross-sections.
- _read_configuration_parameters(config)#
Reads parameters specific to line-by-line calculations from the configuration.
- Parameters:
config (object) – Configuration object containing parameters.
- _read_equation_of_state()#
Reads the equation of state for the gas mixture.
- _read_mass()#
Reads the mass of the species from the configuration or database.
- _read_pressure_broadening_info()#
Reads the pressure broadening parameters from the configuration.
- _read_partition_function()#
Reads the partition function from the configuration file.
- iterate_over_PT_grid(function, progress_bar=True, **kwargs)#
Iterate over the pressure-temperature grid in parallel and apply a function.
- Parameters:
function (callable) – Function to apply at each grid point.
progress_bar (bool) – Whether to show a progress bar.
**kwargs – Additional arguments for the function.
- calculate_cross_sections(P, T, nu_0, S_0, E_low, A, delta=None, **kwargs)#
Computes the cross-sections for given parameters.
- Parameters:
P (float) – Pressure in Pa.
T (float) – Temperature in Kelvin.
nu_0 (array) – Transition frequencies in s^-1.
S_0 (array) – Line strengths at reference temperature.
E_low (array) – Lower state energies in Joules.
A (array) – Einstein A-coefficients in s^-1.
delta (array, optional) – Pressure shift coefficients.
**kwargs – Additional arguments.
- calculate_temporary_outputs(overwrite=False, save_in_one_file=False, files_range=None, **kwargs)#
Calculates temporary outputs for cross-sections.
- Parameters:
overwrite (bool) – Whether to overwrite existing files.
save_in_one_file (bool) – Whether to save all outputs in one file.
files_range (tuple, optional) – Range of files to process.
**kwargs – Additional arguments.
- save_combined_outputs(**kwargs)#
Saves the merged outputs to a file.
- Parameters:
**kwargs – Additional arguments for saving.
- plot_combined_outputs(fig=None, ax=None, return_fig_ax=False, cmaps=['coolwarm', 'viridis'], xscale='log', yscale='log', xlim=None, ylim=None, ls='-', lw=0.7, **kwargs)#
Plots the merged outputs.
- Parameters:
fig (matplotlib.figure.Figure) – Figure object for plotting.
ax (matplotlib.axes.Axes) – Axes object for plotting.
return_fig_ax (bool) – Whether to return the figure and axes.
cmaps (list) – List of colormaps for plotting.
xscale (str) – Scale for the x-axis.
yscale (str) – Scale for the y-axis.
xlim (tuple, optional) – Limits for the x-axis.
ylim (tuple, optional) – Limits for the y-axis.
ls (str) – Line style for plotting.
**kwargs – Additional arguments for plotting.
- convert_to_pRT3(contributor=None, **kwargs)#
Converts the cross-sections to petitRADTRANS v3.0 format.
- Parameters:
contributor (str) – Name of the contributor for these data.
**kwargs – Additional arguments for conversion.
- Raises:
ValueError – If required metadata is missing in the configuration.
KeyError – If required keys are missing in the metadata.