petitRADTRANS.validation#

This module provides sanity checks on inputs for the Radtrans class.

Attributes#

Functions#

_warn_deprecated_cloud_particle_argument(...)

_resolve_deprecated_cloud_particle_argument(*, ...[, ...])

_normalize_deprecated_cloud_particle_arguments(*, ...)

_normalize_deprecated_cloud_particle_parameter_keys(...)

_warn_scattering_in_emission_without_cloud_species(...)

_warn_partial_cloud_coverage_without_patchy_clouds(...)

_check_anisotropic_cloud_scattering(mode)

Check if the anisotropic cloud scattering mode is valid.

_check_line_opacity_mode(mode)

Check if the line opacity mode is valid.

_check_input_data_file_existence(path)

Check if an input data file exists.

_check_path_input_data(path)

Check if the input data path exists.

_check_pressures(pressures)

Check if the pressures are in increasing order.

_check_return_clear_spectrum_relevance(...)

Check if returning a clear spectrum is relevant and issue warnings if not.

_check_wavelength_boundaries(boundaries)

Check if the wavelength boundaries are valid.

_sanitize_frequency_surface_input(values, frequencies, ...)

_sanitize_emission_surface_inputs(frequencies, ...)

_normalize_optional_mapping(mapping[, dtype])

_normalize_optional_scalar(value, missing_value[, dtype])

_normalize_optional_mapping_or_scalar(value, missing_value)

_normalize_cloud_species_selection(selection, ...)

_sanitize_flux_opacity_inputs(patchy_clouds, ...)

_handle_grid_misalignment(→ numpy.typing.NDArray[bool])

Handle frequency grid misalignment by extending the selection of indices.

Module Contents#

petitRADTRANS.validation._UNSET#
petitRADTRANS.validation._DEPRECATED_CLOUD_PARTICLE_ARGUMENTS#
petitRADTRANS.validation._warn_deprecated_cloud_particle_argument(deprecated_name: str, canonical_name: str)#
petitRADTRANS.validation._resolve_deprecated_cloud_particle_argument(*, deprecated_name: str, canonical_name: str, deprecated_value: Any, canonical_value: Any, canonical_default: Any = _UNSET)#
petitRADTRANS.validation._normalize_deprecated_cloud_particle_arguments(*, cloud_particle_mean_radii, cloud_particle_radius_distribution_std, cloud_particle_radius_distribution, cloud_particle_number_density_grid, cloud_particles_mean_radii=_UNSET, cloud_particles_radius_distribution_std=_UNSET, cloud_particles_radius_distribution=_UNSET, cloud_particles_number_density_grid=_UNSET)#
petitRADTRANS.validation._normalize_deprecated_cloud_particle_parameter_keys(cloud_parameters: dict[str, Any]) dict[str, Any]#
petitRADTRANS.validation._warn_scattering_in_emission_without_cloud_species(scattering_in_emission: bool, cloud_species: list[str] | tuple[str] | None)#
petitRADTRANS.validation._warn_partial_cloud_coverage_without_patchy_clouds(cloud_fraction: float, patchy_clouds: tuple[str, Ellipsis], has_partial_coverage_background_cloud: bool = False)#
petitRADTRANS.validation._check_anisotropic_cloud_scattering(mode: str | bool)#

Check if the anisotropic cloud scattering mode is valid.

Args:

mode: The anisotropic cloud scattering mode.

petitRADTRANS.validation._check_line_opacity_mode(mode: str)#

Check if the line opacity mode is valid.

Args:

mode: The line opacity mode.

petitRADTRANS.validation._check_input_data_file_existence(path: str)#

Check if an input data file exists.

Args:

path: The path to the input data file.

petitRADTRANS.validation._check_path_input_data(path: str)#

Check if the input data path exists.

Args:

path: The path to the input data directory.

petitRADTRANS.validation._check_pressures(pressures: jax.typing.ArrayLike)#

Check if the pressures are in increasing order.

Args:

pressures: The array of pressures.

petitRADTRANS.validation._check_return_clear_spectrum_relevance(return_clear_spectrum: bool, clouds_have_effect: bool, opaque_cloud_top_pressure: float | None, cloud_fraction: float)#

Check if returning a clear spectrum is relevant and issue warnings if not.

Args:

return_clear_spectrum: If True, a clear spectrum will be returned in addition to the cloudy one. clouds_have_effect: If True, clouds have an effect on the spectrum. opaque_cloud_top_pressure: The pressure of the opaque cloud top. cloud_fraction: The cloud fraction.

petitRADTRANS.validation._check_wavelength_boundaries(boundaries: jax.typing.ArrayLike)#

Check if the wavelength boundaries are valid.

Args:

boundaries: The wavelength boundaries.

petitRADTRANS.validation._sanitize_frequency_surface_input(values, frequencies, default_value, quantity_name)#
petitRADTRANS.validation._sanitize_emission_surface_inputs(frequencies, scattering_in_emission, star_irradiation_angle, stellar_intensities, star_effective_temperature, star_radius, orbit_semi_major_axis, reflectances, emissivities)#
petitRADTRANS.validation._normalize_optional_mapping(mapping, dtype=WORKING_JAX_DTYPE)#
petitRADTRANS.validation._normalize_optional_scalar(value, missing_value, dtype=WORKING_JAX_DTYPE)#
petitRADTRANS.validation._normalize_optional_mapping_or_scalar(value, missing_value, dtype=WORKING_JAX_DTYPE)#
petitRADTRANS.validation._normalize_cloud_species_selection(selection, default_species)#
petitRADTRANS.validation._sanitize_flux_opacity_inputs(patchy_clouds, cloud_particle_mean_radii, cloud_hansen_a, cloud_hansen_b, clouds_particle_porosity_factor, cloud_f_sed, eddy_diffusion_coefficients, opaque_cloud_top_pressure, cloud_particle_radius_distribution_std, power_law_opacity_350nm, power_law_opacity_coefficient, gray_opacity, cloud_photosphere_median_optical_depth, cloud_particle_number_density_grid, additional_absorption_opacities_function, additional_scattering_opacities_function, target_particle_radii, target_pressure, cloud_species, missing_float, missing_neg_inf, noop_opacity_fn: Callable)#
petitRADTRANS.validation._handle_grid_misalignment(indices: numpy.typing.NDArray[bool], frequencies_reference: jax.typing.ArrayLike, frequencies_test: jax.typing.ArrayLike) numpy.typing.NDArray[bool]#

Handle frequency grid misalignment by extending the selection of indices.

This function is a workaround for cases where the frequency grid of the model does not perfectly align with the frequency grid of the opacity data, even after selecting the closest frequencies. It extends the selection of indices to include one more frequency to the left or right to ensure that the model’s frequency range is fully covered by the opacity data.

Args:

indices: The boolean array of indices selecting the frequencies from the opacity data. frequencies_reference: The frequency grid of the model. frequencies_test: The frequency grid of the opacity data.

Returns:

The updated boolean array of indices.