pyROX.line_by_line.lbl
======================

.. py:module:: pyROX.line_by_line.lbl


Classes
-------

.. autoapisummary::

   pyROX.line_by_line.lbl.LineProfileHelper
   pyROX.line_by_line.lbl.LineByLine


Module Contents
---------------

.. py:class:: LineProfileHelper

   Helper class for line profile calculations.


   .. py:method:: compute_line_strength(T, S_0, E_low, nu_0)

      Calculates the line strength for a given temperature.

      :param T: Temperature in Kelvin.
      :type T: float
      :param S_0: Line strength at reference temperature.
      :type S_0: float
      :param E_low: Lower state energy in Joules.
      :type E_low: float
      :param nu_0: Transition frequency in s^-1.
      :type nu_0: float

      :returns: Line strength in s^-1/(molecule m^-2).
      :rtype: float



   .. py:method:: normalise_wing_cutoff(S, cutoff_distance, gamma_L)

      Normalises the line strength to account for wing cutoff.

      :param S: Line strengths.
      :type S: array
      :param cutoff_distance: Distance for wing cutoff.
      :type cutoff_distance: float
      :param gamma_L: Lorentzian widths.
      :type gamma_L: array

      :returns: Normalised line strengths.
      :rtype: array



   .. py:method:: pressure_shift(P, T, nu_0, delta=None)

      Applies pressure shift to the transition frequency.

      :param P: Pressure in Pa.
      :type P: float
      :param T: Temperature in Kelvin.
      :type T: float
      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param delta: Pressure shift coefficient.
      :type delta: float, optional

      :returns: Pressure-shifted frequencies.
      :rtype: array



   .. py:method:: compute_vdw_broadening(P, T, E_low, **kwargs)

      Calculates Van der Waals broadening.

      :param P: Pressure in Pa.
      :type P: float
      :param T: Temperature in Kelvin.
      :type T: float
      :param E_low: Lower state energy in Joules.
      :type E_low: float
      :param \*\*kwargs: Additional parameters.

      :returns: Van der Waals broadening in s^-1.
      :rtype: float



   .. py:method:: compute_natural_broadening(A)

      Calculates natural broadening.

      :param A: Einstein A-coefficient in s^-1.
      :type A: float

      :returns: Natural broadening in s^-1.
      :rtype: float



   .. py:method:: compute_doppler_broadening(T, nu_0)

      Calculates Doppler broadening.

      :param T: Temperature in Kelvin.
      :type T: float
      :param nu_0: Transition frequency in s^-1.
      :type nu_0: float

      :returns: Doppler broadening in s^-1.
      :rtype: float



   .. py:method:: compute_lorentz_width(gamma_vdW, gamma_N)

      Calculates Lorentzian width.

      :param gamma_vdW: Van der Waals broadening in s^-1.
      :type gamma_vdW: float
      :param gamma_N: Natural broadening in s^-1.
      :type gamma_N: float

      :returns: Lorentzian width in s^-1.
      :rtype: float



   .. py:method:: compute_voigt_width(gamma_G, gamma_L)

      Calculates Voigt width.

      :param gamma_G: Gaussian width in s^-1.
      :type gamma_G: float
      :param gamma_L: Lorentzian width in s^-1.
      :type gamma_L: float

      :returns: Voigt width in s^-1.
      :rtype: float



   .. py:method:: _bin_transitions_for_local_cutoff(nu_0)

      Bins the transitions to the nearest sub-sampled grid point.

      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array

      :returns: Indices of transitions per bin.
      :rtype: array



   .. py:method:: apply_local_cutoff(S, nu_0, factor)

      Applies local cutoff to line strengths. Retain lines with
      a certain fraction of cumulative strength.

      :param S: Line strengths.
      :type S: array
      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param factor: Fraction of cumulative strength to retain.
      :type factor: float

      :returns: Modified line strengths.
      :rtype: array



   .. py:method:: 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.

      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param S: Line strengths.
      :type S: array
      :param gamma_L: Lorentzian widths.
      :type gamma_L: array
      :param gamma_G: Gaussian widths.
      :type gamma_G: array
      :param nu_grid: Wavenumber grid.
      :type nu_grid: array
      :param wing_cutoff_distance: Wing cutoff distance in s^-1.
      :type wing_cutoff_distance: float
      :param delta_nu: Wavenumber grid spacing in s^-1.
      :type delta_nu: float

      :returns: Opacity cross-section on the grid.
      :rtype: array



   .. py:method:: _calculate_line_profiles_one_by_one(nu_0, strength, y, gamma_G, nu_grid, slice_nu_grid)

      Calculates line profiles one by one.

      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param strength: Line strengths.
      :type strength: array
      :param y: Complex part of Faddeeva coordinate.
      :type y: array
      :param gamma_G: Gaussian widths.
      :type gamma_G: array
      :param nu_grid: Wavenumber grid.
      :type nu_grid: array
      :param slice_nu_grid: Slices of the wavenumber grid.
      :type slice_nu_grid: array

      :returns: Opacity cross-section on the grid.
      :rtype: array



   .. py:method:: _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.

      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param S: Line strengths.
      :type S: array
      :param gamma_L: Lorentzian widths.
      :type gamma_L: array
      :param gamma_G: Gaussian widths.
      :type gamma_G: array
      :param nu_grid: Wavenumber grid.
      :type nu_grid: array
      :param wing_cutoff_distance: Wing cutoff distance in s^-1.
      :type wing_cutoff_distance: float
      :param delta_nu: Wavenumber grid spacing in s^-1.
      :type delta_nu: float
      :param N_lines_in_chunk: Number of lines to process in each chunk.
      :type N_lines_in_chunk: int

      :returns: Opacity cross-section on the grid.
      :rtype: array



   .. py:method:: _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().

      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param S: Line strengths.
      :type S: array
      :param gamma_L: Lorentzian widths.
      :type gamma_L: array
      :param gamma_G: Gaussian widths.
      :type gamma_G: array
      :param nu_grid: Wavenumber grid.
      :type nu_grid: array
      :param wing_cutoff_distance: Wing cutoff distance in s^-1.
      :type wing_cutoff_distance: float
      :param delta_nu: Wavenumber grid spacing in s^-1.
      :type delta_nu: float
      :param N_lines_in_chunk: Number of lines to process in each chunk.
      :type N_lines_in_chunk: int

      :returns: Opacity cross-section on the grid.
      :rtype: array



.. py:class:: LineByLine(config, **kwargs)

   Bases: :py:obj:`pyROX.CrossSections`, :py:obj:`LineProfileHelper`


   Base class for line-by-line cross-sections.


   .. py:method:: _read_configuration_parameters(config)

      Reads parameters specific to line-by-line calculations from the configuration.

      :param config: Configuration object containing parameters.
      :type config: object



   .. py:method:: _read_equation_of_state()

      Reads the equation of state for the gas mixture.



   .. py:method:: _read_mass()

      Reads the mass of the species from the configuration or database.



   .. py:method:: _read_pressure_broadening_info()

      Reads the pressure broadening parameters from the configuration.



   .. py:method:: _read_partition_function()

      Reads the partition function from the configuration file.



   .. py:method:: iterate_over_PT_grid(function, progress_bar=True, **kwargs)

      Iterates over the pressure-temperature grid and apply a function.

      :param function: Function to apply at each grid point.
      :type function: callable
      :param progress_bar: Whether to show a progress bar.
      :type progress_bar: bool
      :param \*\*kwargs: Additional arguments for the function.



   .. py:method:: calculate_cross_sections(P, T, nu_0, S_0, E_low, A, delta=None, **kwargs)

      Computes the cross-sections for given parameters.

      :param P: Pressure in Pa.
      :type P: float
      :param T: Temperature in Kelvin.
      :type T: float
      :param nu_0: Transition frequencies in s^-1.
      :type nu_0: array
      :param S_0: Line strengths at reference temperature.
      :type S_0: array
      :param E_low: Lower state energies in Joules.
      :type E_low: array
      :param A: Einstein A-coefficients in s^-1.
      :type A: array
      :param delta: Pressure shift coefficients.
      :type delta: array, optional
      :param \*\*kwargs: Additional arguments.



   .. py:method:: calculate_temporary_outputs(overwrite=False, save_in_one_file=False, files_range=None, **kwargs)

      Calculates temporary outputs for cross-sections.

      :param overwrite: Whether to overwrite existing files.
      :type overwrite: bool
      :param save_in_one_file: Whether to save all outputs in one file.
      :type save_in_one_file: bool
      :param files_range: Range of files to process.
      :type files_range: tuple, optional
      :param \*\*kwargs: Additional arguments.



   .. py:method:: save_combined_outputs(**kwargs)

      Saves the merged outputs to a file.

      :param \*\*kwargs: Additional arguments for saving.



   .. py:method:: 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.

      :param fig: Figure object for plotting.
      :type fig: matplotlib.figure.Figure
      :param ax: Axes object for plotting.
      :type ax: matplotlib.axes.Axes
      :param return_fig_ax: Whether to return the figure and axes.
      :type return_fig_ax: bool
      :param cmaps: List of colormaps for plotting.
      :type cmaps: list
      :param xscale: Scale for the x-axis.
      :type xscale: str
      :param yscale: Scale for the y-axis.
      :type yscale: str
      :param xlim: Limits for the x-axis.
      :type xlim: tuple, optional
      :param ylim: Limits for the y-axis.
      :type ylim: tuple, optional
      :param ls: Line style for plotting.
      :type ls: str
      :param \*\*kwargs: Additional arguments for plotting.



   .. py:method:: convert_to_pRT3(contributor=None, **kwargs)

      Converts the cross-sections to petitRADTRANS v3.0 format.

      :param contributor: Name of the contributor for these data.
      :type contributor: str
      :param \*\*kwargs: Additional arguments for conversion.

      :raises ValueError: If required metadata is missing in the configuration.
      :raises KeyError: If required keys are missing in the metadata.



