-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves non-physical input check outsode I/O module (#2923)
* moves non-physical input check * fixes codespell failure as in #2908 * updated mailmap * fixes codespell failure as in #2908 * made necessary changes to path * Revert "fixes codespell failure as in #2908" This reverts commit aa7a3ed. * Revert "fixes codespell failure as in #2908" This reverts commit 1a1d8b9. * Rename test_radiation_field.py to validate_radiation_field.py * Update parse_radiation_field_configuration.py
- Loading branch information
Showing
3 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}." | ||
) |