diff --git a/.mailmap b/.mailmap index ed00506c00f..b238be626b3 100644 --- a/.mailmap +++ b/.mailmap @@ -215,6 +215,8 @@ Stuart Sim ssim Stuart Sim Stuart Sim Stuart Sim Stuart Sim +Swayam Shah Sonu0305 + TARDIS Bot TARDIS Bot tardis-bot TARDIS Bot TARDIS Bot diff --git a/tardis/io/model/parse_radiation_field_configuration.py b/tardis/io/model/parse_radiation_field_configuration.py index d0ff62badc9..11b878ed2e8 100644 --- a/tardis/io/model/parse_radiation_field_configuration.py +++ b/tardis/io/model/parse_radiation_field_configuration.py @@ -8,6 +8,7 @@ parse_structure_from_config, ) from tardis.plasma.radiation_field import DilutePlanckianRadiationField +from tardis.radiation_field.validate_radiation_field import validate_radiative_temperature logger = logging.getLogger(__name__) @@ -113,12 +114,7 @@ def parse_radiation_field_state_from_csvy( geometry, packet_source ) - if np.any(t_radiative < 1000 * u.K): - logging.critical( - "Radiative temperature is too low in some of the shells, temperatures below 1000K " - f"(e.g., T_rad = {t_radiative[np.argmin(t_radiative)]} in shell {np.argmin(t_radiative)} in your model) " - "are not accurately handled by TARDIS.", - ) + validate_radiative_temperature(t_radiative) if hasattr(csvy_model_data, "columns") and ( "dilution_factor" in csvy_model_data.columns diff --git a/tardis/radiation_field/validate_radiation_field.py b/tardis/radiation_field/validate_radiation_field.py new file mode 100644 index 00000000000..3d0a71f9b08 --- /dev/null +++ b/tardis/radiation_field/validate_radiation_field.py @@ -0,0 +1,31 @@ +import logging +import numpy as np +from astropy import units as u + +logger = logging.getLogger(__name__) + +def validate_radiative_temperature(t_radiative): + """ + Validates the radiative temperature to ensure it is physically reasonable. + + Parameters + ---------- + t_radiative : Quantity + The radiative temperature array. + + Raises + ------ + ValueError + If any radiative temperature is below 1000 K. + """ + if np.any(t_radiative < 1000 * u.K): + min_t_rad = t_radiative[np.argmin(t_radiative)] + min_shell = np.argmin(t_radiative) + logging.critical( + "Radiative temperature is too low in some of the shells, temperatures below 1000K " + f"(e.g., T_rad = {min_t_rad} in shell {min_shell} in your model) " + "are not accurately handled by TARDIS." + ) + raise ValueError( + f"Radiative temperature below 1000 K detected: T_rad = {min_t_rad} in shell {min_shell}." + )