pyROX.cross_sections
====================

.. py:module:: pyROX.cross_sections


Classes
-------

.. autoapisummary::

   pyROX.cross_sections.CrossSections


Functions
---------

.. autoapisummary::

   pyROX.cross_sections.load_data_object


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

.. py:function:: load_data_object(config, **kwargs)

   Load the data object based on the given configuration.

   :param config: Configuration object containing database information.
   :type config: object
   :param \*\*kwargs: Additional arguments to pass to the data object.

   :returns: An instance of the appropriate data object based on the database type.
   :rtype: object

   :raises NotImplementedError: If the specified database is not implemented.


.. py:class:: CrossSections(config, download=False)

   Base class for handling cross-sections.


   .. py:method:: _mask_arrays(arrays, mask, **kwargs)
      :staticmethod:


      Apply a mask to the given arrays.

      :param arrays: List of arrays to mask.
      :type arrays: list
      :param mask: Boolean mask to apply.
      :type mask: array-like
      :param \*\*kwargs: Additional arguments for numpy.compress.

      :returns: List of masked arrays.
      :rtype: list



   .. py:attribute:: database


   .. py:method:: download_data(*args, **kwargs)
      :abstractmethod:


      Download data required for cross-section calculations.

      :raises NotImplementedError: This method should be implemented in a subclass.



   .. py:method:: calculate_temporary_outputs(*args, **kwargs)
      :abstractmethod:


      Calculate temporary outputs for cross-sections.

      :raises NotImplementedError: This method should be implemented in a subclass.



   .. py:method:: plot_combined_outputs(*args, **kwargs)
      :abstractmethod:


      Plot merged outputs for cross-sections.

      :raises NotImplementedError: This method should be implemented in a subclass.



   .. py:method:: save_combined_outputs(keys_to_merge, progress_bar=False, overwrite=False, **kwargs)

      Combine temporary files and save the final output.

      :param keys_to_merge: List of keys to combine.
      :type keys_to_merge: list
      :param progress_bar: Whether to show a progress bar. Defaults to False.
      :type progress_bar: bool, optional
      :param overwrite: Whether to overwrite the final output file if it exists. Defaults to False.
      :type overwrite: bool, optional
      :param \*\*kwargs: Additional arguments for merging.



   .. py:method:: combine_temporary_outputs(keys_to_merge, progress_bar=False, **kwargs)

      Combine temporary output-files into a single dataset.

      :param keys_to_merge: List of keys to read from the temporary files.
      :type keys_to_merge: list
      :param progress_bar: Whether to show a progress bar. Defaults to False.
      :type progress_bar: bool, optional
      :param \*\*kwargs: Additional arguments for merging.

      :raises FileNotFoundError: If no temporary cross-section files are found.
      :raises ValueError: If the temperature grid is not found in a temporary file.



   .. py:method:: _combine_PT_grids(tmp_files, sum_outputs)

      Combine the PT-grids of the temporary files.

      :param tmp_files: List of temporary files to combine.
      :type tmp_files: list
      :param sum_outputs: Whether to sum the outputs.
      :type sum_outputs: bool

      :returns: A tuple containing the main wavelength grid, pressure grid, temperature grid,
                and a list of booleans indicating if the wavelength axis was flipped.
      :rtype: tuple

      :raises ValueError: If the PT grid is not rectangular or grids are incompatible.



   .. py:method:: _check_if_sum_outputs()

      Check if the cross-sections should be summed.

      :returns: True if the outputs should be summed, False otherwise.
      :rtype: bool



   .. py:method:: _check_existing_output_files(input_files=[''], overwrite_all=False, final_output_file=None)

      Check if the output files already exist.

      :param input_files: List of input file paths.
      :type input_files: list
      :param overwrite_all: Whether to overwrite all existing files.
      :type overwrite_all: bool
      :param final_output_file: Expected output file name.
      :type final_output_file: str

      :returns: List of output file paths.
      :rtype: list



   .. py:method:: _read_configuration_parameters(config)

      Read parameters from the configuration object.

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

      :raises ValueError: If no input-data files are specified in the configuration.



   .. py:method:: _setup_nu_grid()

      Configure the wavenumber grid based on the configuration parameters.



   .. py:method:: _setup_coarse_nu_grid(adaptive_delta_nu)

      Configure a coarse wavenumber grid for adaptive calculations.

      :param adaptive_delta_nu: Desired resolution for the coarse grid.
      :type adaptive_delta_nu: float

      :returns: Coarse wavenumber grid.
      :rtype: numpy.ndarray



