radis.misc.warning module

Define warnings for radiation code, and how to deal with them


Main warning classes : - AccuracyWarning - PerformanceWarning - default UserWarning

exception AccuracyError[source]

Bases: ValueError

Output spectrum is not valid

exception AccuracyWarning[source]

Bases: UserWarning

Warning triggered when it seems accuracy is low.

exception CollisionalBroadeningWarning[source]

Bases: radis.misc.warning.AccuracyWarning

exception DatabaseAlreadyExists[source]

Bases: KeyError

exception DatabaseNotFoundError[source]

Bases: FileNotFoundError

Warning triggered when path does not exist

exception DeprecatedFileWarning[source]

Bases: DeprecationWarning

Warning triggered when the cached file was generated in a previous version of radis

exception EmptyDatabaseError[source]

Bases: ValueError

exception EmptyDatabaseWarning[source]

Bases: UserWarning

Trigger a warning if Line database is empty in the range considered.

exception GaussianBroadeningWarning[source]

Bases: radis.misc.warning.AccuracyWarning

exception HighTemperatureWarning[source]

Bases: UserWarning

Warning triggered when the Line database seems inappropriate for the temperatures considered.

exception InputConditionsWarning[source]

Bases: UserWarning

Warning triggered when Spectrum input conditions are suspicious.

exception IrrelevantFileWarning[source]

Bases: radis.misc.warning.PerformanceWarning

Warning triggered when the cached file is irrelevant for the current calcul

exception LinestrengthCutoffWarning[source]

Bases: radis.misc.warning.AccuracyWarning

Warning triggered when the cumulated linestrength after intensity cutoff has changed too much.

exception MemoryUsageWarning[source]

Bases: radis.misc.warning.PerformanceWarning

exception MissingPressureShiftWarning[source]

Bases: UserWarning

Pressure-shift coefficient is missing in Line Database.

exception MissingReferenceWarning[source]

Bases: UserWarning

Warning triggered when some algorithm / database is missing the bibliographic data used by cite()

exception MissingSelfBroadeningTdepWarning[source]

Bases: UserWarning

Self broadening temperature dependance coefficient is missing in Line Database.

Usually, use Air broadening temperature dependance coefficient instead. See _add_collisional_broadening_HWHM()

exception MissingSelfBroadeningWarning[source]

Bases: UserWarning

Self broadening tabulated width is missing in Line Database.

Usually, use Air broadening tabulated width instead. See _add_collisional_broadening_HWHM()

exception NegativeEnergiesWarning[source]

Bases: UserWarning

exception OutOfBoundError[source]

Bases: ValueError

exception OutOfBoundWarning[source]

Bases: UserWarning

Out of bound (for partition functions)

exception OutOfRangeLinesWarning[source]

Bases: UserWarning

Trigger a warning if out of range neighbouring lines, that could have an effect on the spectrume due to their broadening, cannot be found in the database.

exception PerformanceWarning[source]

Bases: UserWarning

Warning triggered when it seems computation parameters are not optimized.

exception SlitDispersionWarning[source]

Bases: UserWarning

Warning trigger if Slit dispersion is too large.

exception VoigtBroadeningWarning[source]

Bases: radis.misc.warning.AccuracyWarning

WarningClasses = {'AccuracyError': <class 'radis.misc.warning.AccuracyError'>, 'AccuracyWarning': <class 'radis.misc.warning.AccuracyWarning'>, 'CollisionalBroadeningWarning': <class 'radis.misc.warning.CollisionalBroadeningWarning'>, 'DatabaseAlreadyExists': <class 'radis.misc.warning.DatabaseAlreadyExists'>, 'DatabaseNotFoundError': <class 'radis.misc.warning.DatabaseNotFoundError'>, 'DeprecatedFileWarning': <class 'radis.misc.warning.DeprecatedFileWarning'>, 'EmptyDatabaseWarning': <class 'radis.misc.warning.EmptyDatabaseWarning'>, 'GaussianBroadeningWarning': <class 'radis.misc.warning.GaussianBroadeningWarning'>, 'HighTemperatureWarning': <class 'radis.misc.warning.HighTemperatureWarning'>, 'InputConditionsWarning': <class 'radis.misc.warning.InputConditionsWarning'>, 'IrrelevantFileWarning': <class 'radis.misc.warning.IrrelevantFileWarning'>, 'LinestrengthCutoffWarning': <class 'radis.misc.warning.LinestrengthCutoffWarning'>, 'MemoryUsageWarning': <class 'radis.misc.warning.MemoryUsageWarning'>, 'MissingPressureShiftWarning': <class 'radis.misc.warning.MissingPressureShiftWarning'>, 'MissingReferenceWarning': <class 'radis.misc.warning.MissingReferenceWarning'>, 'MissingSelfBroadeningTdepWarning': <class 'radis.misc.warning.MissingSelfBroadeningTdepWarning'>, 'MissingSelfBroadeningWarning': <class 'radis.misc.warning.MissingSelfBroadeningWarning'>, 'NegativeEnergiesWarning': <class 'radis.misc.warning.NegativeEnergiesWarning'>, 'OutOfBoundWarning': <class 'radis.misc.warning.OutOfBoundWarning'>, 'OutOfRangeLinesWarning': <class 'radis.misc.warning.OutOfRangeLinesWarning'>, 'PerformanceWarning': <class 'radis.misc.warning.PerformanceWarning'>, 'SlitDispersionWarning': <class 'radis.misc.warning.SlitDispersionWarning'>, 'VoigtBroadeningWarning': <class 'radis.misc.warning.VoigtBroadeningWarning'>, 'default': <class 'UserWarning'>}[source]

warnings used in RADIS Spectrum calculations.

Setup individual warnings. Value of keys can be: - ‘warning’ (default: just trigger a warning) - ‘error’ (raises an error on this warning) - ‘ignore’ (do nothing)

The key self.warnings[‘default’] will set the warning behavior for all other warnings

You can selectively activate them at runtime by setting the warnings attribute of radis.lbl.factory.SpectrumFactory

Type

dict

default_warning_status = {'AccuracyError': 'error', 'AccuracyWarning': 'warn', 'CollisionalBroadeningWarning': 'once', 'DatabaseAlreadyExists': 'error', 'DatabaseNotFoundError': 'error', 'DeprecatedFileWarning': 'warn', 'EmptyDatabaseWarning': 'warn', 'GaussianBroadeningWarning': 'once', 'HighTemperatureWarning': 'warn', 'InputConditionsWarning': 'warn', 'IrrelevantFileWarning': 'warn', 'LinestrengthCutoffWarning': 'warn', 'MemoryUsageWarning': 'warn', 'MissingPressureShiftWarning': 'warn', 'MissingReferenceWarning': 'warn', 'MissingSelfBroadeningTdepWarning': 'warn', 'MissingSelfBroadeningWarning': 'warn', 'NegativeEnergiesWarning': 'warn', 'OutOfBoundWarning': 'warn', 'OutOfRangeLinesWarning': 'warn', 'PerformanceWarning': 'warn', 'SlitDispersionWarning': 'warn', 'VoigtBroadeningWarning': 'once', 'default': 'warn'}[source]

default status of warnings used in RADIS Spectrum calculations.

Value of keys can be:

  • 'warning' (default: just trigger a warning)

  • 'error' (raises an error on this warning)

  • 'ignore' (do nothing)

The key self.warnings[‘default’] will set the warning behavior for all other warnings. All warnings can be disabled by setting the SpectrumFactory warnings attribute to False.

Type

dict

reset_warnings(status)[source]

Reactivate warnings that are set ‘once’ per session in the Factory (unless all warnings have been set to False)

Parameters

status (dict) – dictionary of Warnings with associated status

warn(message, category='default', status={})[source]

Trigger a warning, an error or just ignore based on the value defined in the warnings dictionary.

The warnings can thus be deactivated selectively by setting the SpectrumFactory warnings attribute. All warnings can be disabled by setting it to False.

Parameters
  • message (str) – what to print

  • category (str) – one of the keys of self.warnings.

  • status (dict) – status for all warning categories. Can be one of 'warn', 'ignore', 'print', 'error'

Examples

if not ((df.Erotu > tol).all() and (df.Erotl > tol).all()):
    warn(
        "There are negative rotational energies in the database",
        "NegativeEnergiesWarning",
    )