1313# limitations under the License.
1414"""Useful functions to load IMAS core_profiles or plasma_profiles IDSs."""
1515from collections .abc import Collection , Mapping
16+ import logging
1617from typing import Any
1718
1819from imas import ids_toplevel
1920import numpy as np
2021from torax ._src import constants
2122
2223
24+ def _validate_profiles_conditions (ids : ids_toplevel .IDSToplevel ):
25+ """Validates the profiles_conditions IDS."""
26+ grid = ids .grid
27+ if not grid .rho_tor_norm .has_value :
28+ raise ValueError ("The IDS is missing the grid.rho_tor_norm quantity." )
29+ if not grid .psi .has_value :
30+ logging .warning ("The IDS is missing the grid.psi quantity." )
31+
32+ global_quantities = ids .global_quantities
33+ if not global_quantities .v_loop .has_value :
34+ logging .warning ("The IDS is missing the v_loop quantity." )
35+ if not global_quantities .ip .has_value :
36+ logging .warning ("The IDS is missing the ip quantity." )
37+
38+ if not ids .time .has_value :
39+ logging .warning ("The IDS is missing the time quantity." )
40+
41+ electrons_ids = ids .electrons
42+ if not electrons_ids .temperature .has_value :
43+ logging .warning ("The IDS is missing the electrons.temperature quantity." )
44+ if not electrons_ids .density .has_value :
45+ logging .warning ("The IDS is missing the electrons.density quantity." )
46+
47+ if not ids .t_i_average .has_value :
48+ logging .warning ("The IDS is missing the t_i_average quantity." )
49+
50+
2351# pylint: disable=invalid-name
2452def profile_conditions_from_IMAS (
2553 ids : ids_toplevel .IDSToplevel ,
@@ -38,6 +66,7 @@ def profile_conditions_from_IMAS(
3866 The updated fields read from the IDS that can be used to completely or
3967 partially fill the `profile_conditions` section of a TORAX `CONFIG`.
4068 """
69+ _validate_profiles_conditions (ids )
4170 profiles_1d , rhon_array , time_array = _get_time_and_radial_arrays (
4271 ids , t_initial
4372 )
0 commit comments