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: 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 GPUInitWarning[source]¶

Bases: PerformanceWarning

Triggered when GPU isn’t initialized

exception GaussianBroadeningWarning[source]¶

Bases: AccuracyWarning

exception HighTemperatureWarning[source]¶

Bases: UserWarning

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

exception InconsistentDatabaseError[source]¶

Bases: ValueError

exception InputConditionsWarning[source]¶

Bases: UserWarning

Warning triggered when Spectrum input conditions are suspicious.

exception IrrelevantFileWarning[source]¶

Bases: PerformanceWarning

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

exception LinestrengthCutoffWarning[source]¶

Bases: AccuracyWarning

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

exception MemoryUsageWarning[source]¶

Bases: PerformanceWarning

exception MissingDiluentBroadeningTdepWarning[source]¶

Bases: UserWarning

Diluent broadening temperature-dependance-coefficient is missing in Line Database.

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

exception MissingDiluentBroadeningWarning[source]¶

Bases: UserWarning

Diluent broadening tabulated width is missing in Line Database.

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

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 MoleFractionError[source]¶

Bases: ValueError

exception NegativeEnergiesWarning[source]¶

Bases: UserWarning

exception NoGPUWarning[source]¶

Bases: PerformanceWarning

Triggered when GPU doesn’t work

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 spectrum 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 UnevenWaverangeWarning[source]¶

Bases: UserWarning

Warning triggered when Spectrum has unevenly distributed waverange

exception VoigtBroadeningWarning[source]¶

Bases: 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'>, 'GPUInitWarning': <class 'radis.misc.warning.GPUInitWarning'>, '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'>, 'MissingDiluentBroadeningTdepWarning': <class 'radis.misc.warning.MissingDiluentBroadeningTdepWarning'>, 'MissingDiluentBroadeningWarning': <class 'radis.misc.warning.MissingDiluentBroadeningWarning'>, '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'>, 'NoGPUWarning': <class 'radis.misc.warning.NoGPUWarning'>, 'OutOfBoundWarning': <class 'radis.misc.warning.OutOfBoundWarning'>, 'OutOfRangeLinesWarning': <class 'radis.misc.warning.OutOfRangeLinesWarning'>, 'PerformanceWarning': <class 'radis.misc.warning.PerformanceWarning'>, 'SlitDispersionWarning': <class 'radis.misc.warning.SlitDispersionWarning'>, 'UnevenWaverangeWarning': <class 'radis.misc.warning.UnevenWaverangeWarning'>, 'VoigtBroadeningWarning': <class 'radis.misc.warning.VoigtBroadeningWarning'>, 'ZeroBroadeningWarning': <class 'radis.misc.warning.ZeroBroadeningWarning'>, '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

exception ZeroBroadeningWarning[source]¶

Bases: UserWarning

At least one line has a calculated broadening of 0

See _calc_lineshape_LDM()

default_warning_status = {'AccuracyError': 'error', 'AccuracyWarning': 'warn', 'CollisionalBroadeningWarning': 'once', 'DatabaseAlreadyExists': 'error', 'DatabaseNotFoundError': 'error', 'DeprecatedFileWarning': 'warn', 'EmptyDatabaseWarning': 'warn', 'GPUInitWarning': 'warn', 'GaussianBroadeningWarning': 'once', 'HighTemperatureWarning': 'warn', 'InputConditionsWarning': 'warn', 'IrrelevantFileWarning': 'warn', 'LinestrengthCutoffWarning': 'warn', 'MemoryUsageWarning': 'warn', 'MissingDiluentBroadeningTdepWarning': 'warn', 'MissingDiluentBroadeningWarning': 'warn', 'MissingPressureShiftWarning': 'warn', 'MissingReferenceWarning': 'warn', 'MissingSelfBroadeningTdepWarning': 'warn', 'MissingSelfBroadeningWarning': 'warn', 'NegativeEnergiesWarning': 'warn', 'NoGPUWarning': 'warn', 'OutOfBoundWarning': 'warn', 'OutOfRangeLinesWarning': 'warn', 'PerformanceWarning': 'warn', 'SlitDispersionWarning': 'warn', 'UnevenWaverangeWarning': 'warn', 'VoigtBroadeningWarning': 'once', 'ZeroBroadeningWarning': 'warn', '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",
    )