Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves non-physical input check outsode I/O module #2923

Merged
merged 10 commits into from
Jan 8, 2025
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ Stuart Sim <[email protected]> ssim <[email protected]>
Stuart Sim <[email protected]> Stuart Sim <[email protected]>
Stuart Sim <[email protected]> Stuart Sim <[email protected]>

Swayam Shah <[email protected]> Sonu0305 <[email protected]>

TARDIS Bot <[email protected]>
TARDIS Bot <[email protected]> tardis-bot <[email protected]>
TARDIS Bot <[email protected]> TARDIS Bot <[email protected]>
Expand Down
8 changes: 2 additions & 6 deletions tardis/io/model/parse_radiation_field_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions tardis/radiation_field/validate_radiation_field.py
Original file line number Diff line number Diff line change
@@ -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}."
)
Loading