pyROX.utils#

Attributes#

Exceptions#

pyROXWarning

Base class for warning categories.

Classes#

Broaden_Gharib_Nezhad_ea_2021

Broadening parameterisation from Gharib-Nezhad et al. (2021).

Functions#

_custom_showwarning(message, category, filename, ...)

download(url, out_dir[, out_name])

Downloads a file from a URL if it does not already exist.

save_to_hdf5(file, data, attrs[, compression])

Saves data to an HDF5 file.

read_from_hdf5(file, keys_to_read[, return_attrs])

Reads data from an HDF5 file.

log10_round(array[, decimals])

Computes the base-10 logarithm of an array and rounds the result.

display_welcome_message()

Displays a welcome message.

display_finish_message(time_start)

Displays a finish message and the elapsed time.

update_config_with_args([config])

Updates the configuration object with command-line arguments.

warn_about_units(config)

Displays a warning message about expected units for specific parameters.

find_closest_indices(a, b)

Finds the indices of the closest elements in arrays a and b.

fixed_resolution_wavelength_grid(wave_min, wave_max, ...)

Returns a fixed resolution wavelength grid.

Module Contents#

exception pyROX.utils.pyROXWarning#

Bases: Warning

Base class for warning categories.

pyROX.utils._original_showwarning#
pyROX.utils._custom_showwarning(message, category, filename, lineno, *args)#
pyROX.utils.download(url, out_dir, out_name=None)#

Downloads a file from a URL if it does not already exist.

Parameters:
  • url (str) – URL of the file to download.

  • out_dir (str) – Output directory.

  • out_name (str, optional) – Output file name. Defaults to None.

Returns:

Path to the downloaded file.

Return type:

str

pyROX.utils.save_to_hdf5(file, data, attrs, compression='gzip', **kwargs)#

Saves data to an HDF5 file.

Parameters:
  • file (str) – Path to the output file.

  • data (dict) – Dictionary containing the data to save.

  • attrs (dict) – Dictionary containing the attributes to save.

  • compression (str, optional) – Compression type. Defaults to ‘gzip’.

  • **kwargs – Additional arguments for dataset creation.

pyROX.utils.read_from_hdf5(file, keys_to_read, return_attrs=False)#

Reads data from an HDF5 file.

Parameters:
  • file (str) – Path to the input file.

  • keys_to_read (list) – List of keys to read from the file.

  • return_attrs (bool, optional) – Whether to return attributes. Defaults to False.

Returns:

Dictionary containing the data. dict (optional): Dictionary containing the attributes if return_attrs is True.

Return type:

dict

pyROX.utils.log10_round(array, decimals=3)#

Computes the base-10 logarithm of an array and rounds the result.

Parameters:
  • array (array-like) – Input array.

  • decimals (int, optional) – Number of decimal places to round to. Defaults to 3.

Returns:

Array with rounded base-10 logarithm values.

Return type:

numpy.ndarray

pyROX.utils.display_welcome_message()#

Displays a welcome message.

Returns:

Start time of the process.

Return type:

float

pyROX.utils.display_finish_message(time_start)#

Displays a finish message and the elapsed time.

Parameters:

time_start (float) – Start time of the process.

pyROX.utils.update_config_with_args(config=None, **kwargs)#

Updates the configuration object with command-line arguments.

Parameters:
  • config (object, optional) – Configuration object to update. Defaults to None.

  • **kwargs – Keyword arguments representing the parameters to update.

Returns:

Updated configuration object.

Return type:

object

pyROX.utils.warn_about_units(config)#

Displays a warning message about expected units for specific parameters.

Parameters:

config (object) – Configuration object containing parameter definitions.

pyROX.utils.find_closest_indices(a, b)#

Finds the indices of the closest elements in arrays a and b.

Parameters:
  • a (array-like) – First array.

  • b (array-like) – Second array.

Returns:

Indices of the closest elements in a and b.

Return type:

tuple

pyROX.utils.fixed_resolution_wavelength_grid(wave_min, wave_max, resolution)#

Returns a fixed resolution wavelength grid.

Parameters:
  • wave_min (float) – Minimum wavelength.

  • wave_max (float) – Maximum wavelength.

  • resolution (float) – Desired resolution.

Returns:

Wavelength grid.

Return type:

numpy.ndarray

class pyROX.utils.Broaden_Gharib_Nezhad_ea_2021(species='AlH')#

Broadening parameterisation from Gharib-Nezhad et al. (2021).

_pade_equation(J, a, b)#

Computes the Pade approximation for the broadening coefficient.

Parameters:
  • J (float) – Rotational quantum number.

  • a (array-like) – Coefficients for the numerator.

  • b (array-like) – Coefficients for the denominator.

Returns:

Broadening coefficient.

Return type:

float

gamma_H2(J)#

Calculates the broadening coefficient for H2.

Parameters:

J (float) – Rotational quantum number.

Returns:

Broadening coefficient.

Return type:

float

gamma_He(J)#

Calculates the broadening coefficient for He.

Parameters:

J (float) – Rotational quantum number.

Returns:

Broadening coefficient.

Return type:

float