@@ -169,8 +169,8 @@ def plasma_composition_from_IMAS(
169169 main_ions_symbols = constants .HYDROGENIC_IONS
170170 # main_ions_symbols explicitly provided: validate ions presence in IDS.
171171 else :
172- _validate_main_ions_presence (parsed_ions , main_ions_symbols )
173- _validate_ids_ions (parsed_ions )
172+ validation . validate_main_ions_presence (parsed_ions , main_ions_symbols )
173+ validation . validate_core_profiles_ions (parsed_ions )
174174
175175 Z_eff = (
176176 time_array ,
@@ -220,41 +220,3 @@ def plasma_composition_from_IMAS(
220220 "species" : impurity_species ,
221221 },
222222 }
223-
224-
225- def _validate_ids_ions (
226- parsed_ions : list [str ],
227- ) -> None :
228- """Checks if all parsed ions are recognized."""
229- for ion in parsed_ions :
230- # ion is casted to str to avoid issues with imas string types.
231- if str (ion ) not in constants .ION_PROPERTIES_DICT .keys ():
232- raise (
233- KeyError (
234- f"{ ion } is present in the IDS but not a valid TORAX ion. Check"
235- "typing or add the ion to the excluded_impurities."
236- )
237- )
238-
239-
240- def _validate_main_ions_presence (
241- parsed_ions : list [str ],
242- main_ion_symbols : Collection [str ],
243- ) -> None :
244- """Checks that items in main_ion_symbols are present in the IDS."""
245- for ion in main_ion_symbols :
246- if ion not in constants .ION_PROPERTIES_DICT .keys ():
247- raise (
248- KeyError (
249- f"{ ion } is not a valid symbol of a TORAX valid ion. Please"
250- " check typing of main_ion_symbols."
251- )
252- )
253- if ion not in parsed_ions :
254- raise (
255- ValueError (
256- f"The expected main ion { ion } cannot be found in the input"
257- " IDS or has no valid data. \n Please check that the IDS is"
258- " properly filled"
259- )
260- )
0 commit comments