From 62615e21484e4f408bbe22dd2e33adfb8ce994da Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 09:13:08 +0200 Subject: [PATCH 01/14] Initial commit for the rules of EFIT++ --- .../assets/codes/efit++/__init__.py | 1 + .../assets/codes/efit++/equilibrium.py | 25 +++++++++ .../assets/codes/efit++/magnetics.py | 52 +++++++++++++++++++ .../assets/codes/efit++/pf_active.py | 31 +++++++++++ .../assets/codes/efit++/pf_passive.py | 20 +++++++ imas_validator/assets/codes/efit++/tf.py | 13 +++++ imas_validator/assets/codes/efit++/wall.py | 12 +++++ 7 files changed, 154 insertions(+) create mode 100644 imas_validator/assets/codes/efit++/__init__.py create mode 100644 imas_validator/assets/codes/efit++/equilibrium.py create mode 100644 imas_validator/assets/codes/efit++/magnetics.py create mode 100644 imas_validator/assets/codes/efit++/pf_active.py create mode 100644 imas_validator/assets/codes/efit++/pf_passive.py create mode 100644 imas_validator/assets/codes/efit++/tf.py create mode 100644 imas_validator/assets/codes/efit++/wall.py diff --git a/imas_validator/assets/codes/efit++/__init__.py b/imas_validator/assets/codes/efit++/__init__.py new file mode 100644 index 0000000..91f4ebd --- /dev/null +++ b/imas_validator/assets/codes/efit++/__init__.py @@ -0,0 +1 @@ +"""Folder for bundled generic IMAS-Validator tests""" diff --git a/imas_validator/assets/codes/efit++/equilibrium.py b/imas_validator/assets/codes/efit++/equilibrium.py new file mode 100644 index 0000000..2d0c2a9 --- /dev/null +++ b/imas_validator/assets/codes/efit++/equilibrium.py @@ -0,0 +1,25 @@ +"""Required fields of EFIT++ in the equilibrium IDS""" + +@validator("equilibrium") +def validate_required_fields(ids): + """ + Validate that the equilibrium IDS has required fields. + """ + + # Equilibrium constraints + for time_slice in ids.time_slice: + assert time_slice.constraints.ip.weight.has_value + assert time_slice.constraints.diamagnetic_flux.weight.has_value + + for pf_current in time_slice.constraints.pf_current: + assert pf_current.source.has_value + assert pf_current.weight.has_value + + for pf_passive_current in time_slice.constraints.pf_passive_current: + assert pf_passive_current.source.has_value + + for bpol_probe in time_slice.constraints.bpol_probe: + assert bpol_probe.weight.has_value + + for flux_loop in time_slice.constraints.flux_loop: + assert flux_loop.weight.has_value diff --git a/imas_validator/assets/codes/efit++/magnetics.py b/imas_validator/assets/codes/efit++/magnetics.py new file mode 100644 index 0000000..579e612 --- /dev/null +++ b/imas_validator/assets/codes/efit++/magnetics.py @@ -0,0 +1,52 @@ +"""Required fields of EFIT++ in the magnetics IDS""" + +@validator("magnetics") +def validate_required_fields(ids): + """Validate that the magnetics IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Magnetic field probes + for b_field_pol_probe in ids.b_field_pol_probe: + # machine description + assert b_field_pol_probe.name.has_value + assert b_field_pol_probe.identifier.has_value + assert b_field_pol_probe.position.r.has_value + assert b_field_pol_probe.position.z.has_value + assert b_field_pol_probe.position.phi.has_value + assert b_field_pol_probe.poloidal_angle.has_value + assert b_field_pol_probe.toroidal_angle.has_value + assert b_field_pol_probe.area.has_value + assert b_field_pol_probe.length.has_value + assert b_field_pol_probe.turns.has_value + # diagnostic data + assert b_field_pol_probe.field.data.has_value + assert b_field_pol_probe.field.data_error_upper.has_value + if homogeneous_time == 0: + assert b_field_pol_probe.field.time.has_value + + # Flux loops + for flux_loop in ids.flux_loop: + # machine description + assert flux_loop.name.has_value + assert flux_loop.identifier.has_value + assert flux_loop.position.r.has_value + assert flux_loop.position.z.has_value + assert flux_loop.position.phi.has_value + # diagnostic data + assert flux_loop.flux.data.has_value + assert flux_loop.flux.data_error_upper.has_value + if homogeneous_time == 0: + assert flux_loop.flux.time.has_value + + # Plasma current (reconstructed data) + assert ids.ip.data.has_value + assert ids.ip.data_error_upper.has_value + if homogeneous_time == 0: + assert ids.ip.time.has_value + + # Diamagnetic flux (reconstructed data) + assert ids.diamagnetic_flux.data.has_value + assert ids.diamagnetic_flux.data_error_upper.has_value + if homogeneous_time == 0: + assert ids.diamagnetic_flux.time.has_value diff --git a/imas_validator/assets/codes/efit++/pf_active.py b/imas_validator/assets/codes/efit++/pf_active.py new file mode 100644 index 0000000..b458694 --- /dev/null +++ b/imas_validator/assets/codes/efit++/pf_active.py @@ -0,0 +1,31 @@ +"""Required fields of EFIT++ in the pf_active IDS""" + +@validator("pf_active") +def validate_required_fields(ids): + """Validate that the pf_active IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Axisymmetric poloidal field coils + for coil in ids.coil: + # machine description + assert coil.name.has_value + assert coil.identifier.has_value + for element in coil: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + + # data + assert coil.current.data.has_value + assert coil.current.data_error_upper.has_value + if homogeneous_time == 0: + assert coil.current.time.has_value + + # PF power supplies + for supply in ids.supply: + assert supply.name.has_value + assert supply.identifier.has_value + + # Circuits + for circuit in ids.scircuit: + assert circuit.connections.has_value diff --git a/imas_validator/assets/codes/efit++/pf_passive.py b/imas_validator/assets/codes/efit++/pf_passive.py new file mode 100644 index 0000000..de78460 --- /dev/null +++ b/imas_validator/assets/codes/efit++/pf_passive.py @@ -0,0 +1,20 @@ +"""Required fields of EFIT++ in the pf_passive IDS""" + +@validator("pf_passive") +def validate_required_fields(ids): + """Validate that the pf_passive IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Axisymmetric passive conductors + for loop in ids.loop: + # machine description + assert loop.name.has_value + for element in loop: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + # data + assert loop.current.has_value + assert loop.current_error_upper.has_value + if homogeneous_time == 0: + assert loop.time.has_value diff --git a/imas_validator/assets/codes/efit++/tf.py b/imas_validator/assets/codes/efit++/tf.py new file mode 100644 index 0000000..788b5f8 --- /dev/null +++ b/imas_validator/assets/codes/efit++/tf.py @@ -0,0 +1,13 @@ +"""Required fields of EFIT++ in the tf IDS""" + +@validator("tf") +def validate_required_fields(ids): + """Validate that the tf IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Vacuume field times major radius in the toroidal field magnet. + # b_field_tor_vacuum_r is obsolete. + assert ids.b_field_phi_vacuum_r.data.has_value + if homogeneous_time == 0: + assert ids.b_field_phi_vacuum_r.time.has_value diff --git a/imas_validator/assets/codes/efit++/wall.py b/imas_validator/assets/codes/efit++/wall.py new file mode 100644 index 0000000..7c80c67 --- /dev/null +++ b/imas_validator/assets/codes/efit++/wall.py @@ -0,0 +1,12 @@ +"""Required fields of EFIT++ in the wall IDS""" + +@validator("wall") +def validate_required_fields(ids): + """Validate that the wall IDS has required fields.""" + + # Wall limiter 2d + for description_2d in ids.description_2d: + # machine description + for unit in description_2d.limiter.unit: + assert unit.outline.r.has_value + assert unit.outline.z.has_value From ae5ca616967b99c7080ef842f81847b546a866c7 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 16:39:09 +0200 Subject: [PATCH 02/14] removing equilibrium.py --- .../assets/codes/efit++/equilibrium.py | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 imas_validator/assets/codes/efit++/equilibrium.py diff --git a/imas_validator/assets/codes/efit++/equilibrium.py b/imas_validator/assets/codes/efit++/equilibrium.py deleted file mode 100644 index 2d0c2a9..0000000 --- a/imas_validator/assets/codes/efit++/equilibrium.py +++ /dev/null @@ -1,25 +0,0 @@ -"""Required fields of EFIT++ in the equilibrium IDS""" - -@validator("equilibrium") -def validate_required_fields(ids): - """ - Validate that the equilibrium IDS has required fields. - """ - - # Equilibrium constraints - for time_slice in ids.time_slice: - assert time_slice.constraints.ip.weight.has_value - assert time_slice.constraints.diamagnetic_flux.weight.has_value - - for pf_current in time_slice.constraints.pf_current: - assert pf_current.source.has_value - assert pf_current.weight.has_value - - for pf_passive_current in time_slice.constraints.pf_passive_current: - assert pf_passive_current.source.has_value - - for bpol_probe in time_slice.constraints.bpol_probe: - assert bpol_probe.weight.has_value - - for flux_loop in time_slice.constraints.flux_loop: - assert flux_loop.weight.has_value From bd2b1fda3e9903c63f94b9bca0a268d182ebfda4 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 16:57:29 +0200 Subject: [PATCH 03/14] validate for multiple DD versions on IDS/tf --- imas_validator/assets/codes/efit++/tf.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/imas_validator/assets/codes/efit++/tf.py b/imas_validator/assets/codes/efit++/tf.py index 788b5f8..422e84c 100644 --- a/imas_validator/assets/codes/efit++/tf.py +++ b/imas_validator/assets/codes/efit++/tf.py @@ -1,6 +1,18 @@ """Required fields of EFIT++ in the tf IDS""" -@validator("tf") +@validator("tf", version="<3.42.0") +def validate_required_fields(ids): + """Validate that the tf IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Vacuume field times major radius in the toroidal field magnet. + # b_field_tor_vacuum_r is obsolete. + assert ids.b_field_tor_vacuum_r.data.has_value + if homogeneous_time == 0: + assert ids.b_field_tor_vacuum_r.time.has_value + +@validator("tf", version=">=3.42.0") def validate_required_fields(ids): """Validate that the tf IDS has required fields.""" From 9281091ddb34e00ace6779a8394c34290e717398 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 17:13:42 +0200 Subject: [PATCH 04/14] fixing typos --- imas_validator/assets/codes/efit++/pf_active.py | 4 ++-- imas_validator/assets/codes/efit++/pf_passive.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/imas_validator/assets/codes/efit++/pf_active.py b/imas_validator/assets/codes/efit++/pf_active.py index b458694..ac4022f 100644 --- a/imas_validator/assets/codes/efit++/pf_active.py +++ b/imas_validator/assets/codes/efit++/pf_active.py @@ -11,7 +11,7 @@ def validate_required_fields(ids): # machine description assert coil.name.has_value assert coil.identifier.has_value - for element in coil: + for element in coil.element: assert element.geometry.geometry_type in [2, 3, 5, 6] assert element.turns_with_sign.has_value @@ -27,5 +27,5 @@ def validate_required_fields(ids): assert supply.identifier.has_value # Circuits - for circuit in ids.scircuit: + for circuit in ids.circuit: assert circuit.connections.has_value diff --git a/imas_validator/assets/codes/efit++/pf_passive.py b/imas_validator/assets/codes/efit++/pf_passive.py index de78460..57696c1 100644 --- a/imas_validator/assets/codes/efit++/pf_passive.py +++ b/imas_validator/assets/codes/efit++/pf_passive.py @@ -10,7 +10,7 @@ def validate_required_fields(ids): for loop in ids.loop: # machine description assert loop.name.has_value - for element in loop: + for element in loop.element: assert element.geometry.geometry_type in [2, 3, 5, 6] assert element.turns_with_sign.has_value # data From 6ee35cece6c103ccd4de4b49f6f325f5ad627190 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 17:30:04 +0200 Subject: [PATCH 05/14] fixing issues --- .../assets/codes/efit++/magnetics.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/imas_validator/assets/codes/efit++/magnetics.py b/imas_validator/assets/codes/efit++/magnetics.py index 579e612..6290568 100644 --- a/imas_validator/assets/codes/efit++/magnetics.py +++ b/imas_validator/assets/codes/efit++/magnetics.py @@ -30,9 +30,11 @@ def validate_required_fields(ids): # machine description assert flux_loop.name.has_value assert flux_loop.identifier.has_value - assert flux_loop.position.r.has_value - assert flux_loop.position.z.has_value - assert flux_loop.position.phi.has_value + # position + for position in flux_loop.position: + assert position.r.has_value + assert position.z.has_value + assert position.phi.has_value # diagnostic data assert flux_loop.flux.data.has_value assert flux_loop.flux.data_error_upper.has_value @@ -40,13 +42,15 @@ def validate_required_fields(ids): assert flux_loop.flux.time.has_value # Plasma current (reconstructed data) - assert ids.ip.data.has_value - assert ids.ip.data_error_upper.has_value - if homogeneous_time == 0: - assert ids.ip.time.has_value + for ip in ids.ip: + assert ip.data.has_value + assert ip.data_error_upper.has_value + if homogeneous_time == 0: + assert ip.time.has_value # Diamagnetic flux (reconstructed data) - assert ids.diamagnetic_flux.data.has_value - assert ids.diamagnetic_flux.data_error_upper.has_value - if homogeneous_time == 0: - assert ids.diamagnetic_flux.time.has_value + for diamagnetic_flux in ids.diamagnetic_flux: + assert diamagnetic_flux.data.has_value + assert diamagnetic_flux.data_error_upper.has_value + if homogeneous_time == 0: + assert diamagnetic_flux.time.has_value From 0767d5ec39f89a00c4362a1408572f98dc3b4b3e Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Mon, 7 Jul 2025 17:43:36 +0200 Subject: [PATCH 06/14] comment out the rule b_field_pol_probe/toroidal_angle --- imas_validator/assets/codes/efit++/magnetics.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imas_validator/assets/codes/efit++/magnetics.py b/imas_validator/assets/codes/efit++/magnetics.py index 6290568..e894a4a 100644 --- a/imas_validator/assets/codes/efit++/magnetics.py +++ b/imas_validator/assets/codes/efit++/magnetics.py @@ -15,7 +15,8 @@ def validate_required_fields(ids): assert b_field_pol_probe.position.z.has_value assert b_field_pol_probe.position.phi.has_value assert b_field_pol_probe.poloidal_angle.has_value - assert b_field_pol_probe.toroidal_angle.has_value + # toroidal angle is not read by EFIT++? + # assert b_field_pol_probe.toroidal_angle.has_value assert b_field_pol_probe.area.has_value assert b_field_pol_probe.length.has_value assert b_field_pol_probe.turns.has_value From 7df266058bdb1ff2681f381447b03866601a8762 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 08:38:30 +0200 Subject: [PATCH 07/14] fixing a function name for linting --- imas_validator/assets/codes/efit++/tf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imas_validator/assets/codes/efit++/tf.py b/imas_validator/assets/codes/efit++/tf.py index 422e84c..2de9762 100644 --- a/imas_validator/assets/codes/efit++/tf.py +++ b/imas_validator/assets/codes/efit++/tf.py @@ -1,7 +1,7 @@ """Required fields of EFIT++ in the tf IDS""" @validator("tf", version="<3.42.0") -def validate_required_fields(ids): +def validate_required_fields_exDD(ids): """Validate that the tf IDS has required fields.""" homogeneous_time = ids.ids_properties.homogeneous_time From deda005d57948bf8c832b78bdac2a674a2f56bdd Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 09:12:03 +0200 Subject: [PATCH 08/14] type checking for b_field_pol_probe --- imas_validator/assets/codes/efit++/magnetics.py | 7 ++++--- imas_validator/assets/codes/efit++/tf.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/imas_validator/assets/codes/efit++/magnetics.py b/imas_validator/assets/codes/efit++/magnetics.py index e894a4a..2f9b93a 100644 --- a/imas_validator/assets/codes/efit++/magnetics.py +++ b/imas_validator/assets/codes/efit++/magnetics.py @@ -17,9 +17,10 @@ def validate_required_fields(ids): assert b_field_pol_probe.poloidal_angle.has_value # toroidal angle is not read by EFIT++? # assert b_field_pol_probe.toroidal_angle.has_value - assert b_field_pol_probe.area.has_value - assert b_field_pol_probe.length.has_value - assert b_field_pol_probe.turns.has_value + if b_field_pol_probe.type.index == 2: # 'Mirnov probe' + assert b_field_pol_probe.area.has_value + assert b_field_pol_probe.length.has_value + assert b_field_pol_probe.turns.has_value # diagnostic data assert b_field_pol_probe.field.data.has_value assert b_field_pol_probe.field.data_error_upper.has_value diff --git a/imas_validator/assets/codes/efit++/tf.py b/imas_validator/assets/codes/efit++/tf.py index 2de9762..8063a49 100644 --- a/imas_validator/assets/codes/efit++/tf.py +++ b/imas_validator/assets/codes/efit++/tf.py @@ -12,6 +12,7 @@ def validate_required_fields_exDD(ids): if homogeneous_time == 0: assert ids.b_field_tor_vacuum_r.time.has_value + @validator("tf", version=">=3.42.0") def validate_required_fields(ids): """Validate that the tf IDS has required fields.""" From 083990d2b1c6d8e8c85bb8a8239cb13eb16c7b52 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 09:16:22 +0200 Subject: [PATCH 09/14] efit++ -> efitpp --- .../assets/codes/efit++/__init__.py | 1 - .../assets/codes/efit++/magnetics.py | 58 ------------------- .../assets/codes/efit++/pf_active.py | 31 ---------- .../assets/codes/efit++/pf_passive.py | 20 ------- imas_validator/assets/codes/efit++/tf.py | 26 --------- imas_validator/assets/codes/efit++/wall.py | 12 ---- 6 files changed, 148 deletions(-) delete mode 100644 imas_validator/assets/codes/efit++/__init__.py delete mode 100644 imas_validator/assets/codes/efit++/magnetics.py delete mode 100644 imas_validator/assets/codes/efit++/pf_active.py delete mode 100644 imas_validator/assets/codes/efit++/pf_passive.py delete mode 100644 imas_validator/assets/codes/efit++/tf.py delete mode 100644 imas_validator/assets/codes/efit++/wall.py diff --git a/imas_validator/assets/codes/efit++/__init__.py b/imas_validator/assets/codes/efit++/__init__.py deleted file mode 100644 index 91f4ebd..0000000 --- a/imas_validator/assets/codes/efit++/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Folder for bundled generic IMAS-Validator tests""" diff --git a/imas_validator/assets/codes/efit++/magnetics.py b/imas_validator/assets/codes/efit++/magnetics.py deleted file mode 100644 index 2f9b93a..0000000 --- a/imas_validator/assets/codes/efit++/magnetics.py +++ /dev/null @@ -1,58 +0,0 @@ -"""Required fields of EFIT++ in the magnetics IDS""" - -@validator("magnetics") -def validate_required_fields(ids): - """Validate that the magnetics IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Magnetic field probes - for b_field_pol_probe in ids.b_field_pol_probe: - # machine description - assert b_field_pol_probe.name.has_value - assert b_field_pol_probe.identifier.has_value - assert b_field_pol_probe.position.r.has_value - assert b_field_pol_probe.position.z.has_value - assert b_field_pol_probe.position.phi.has_value - assert b_field_pol_probe.poloidal_angle.has_value - # toroidal angle is not read by EFIT++? - # assert b_field_pol_probe.toroidal_angle.has_value - if b_field_pol_probe.type.index == 2: # 'Mirnov probe' - assert b_field_pol_probe.area.has_value - assert b_field_pol_probe.length.has_value - assert b_field_pol_probe.turns.has_value - # diagnostic data - assert b_field_pol_probe.field.data.has_value - assert b_field_pol_probe.field.data_error_upper.has_value - if homogeneous_time == 0: - assert b_field_pol_probe.field.time.has_value - - # Flux loops - for flux_loop in ids.flux_loop: - # machine description - assert flux_loop.name.has_value - assert flux_loop.identifier.has_value - # position - for position in flux_loop.position: - assert position.r.has_value - assert position.z.has_value - assert position.phi.has_value - # diagnostic data - assert flux_loop.flux.data.has_value - assert flux_loop.flux.data_error_upper.has_value - if homogeneous_time == 0: - assert flux_loop.flux.time.has_value - - # Plasma current (reconstructed data) - for ip in ids.ip: - assert ip.data.has_value - assert ip.data_error_upper.has_value - if homogeneous_time == 0: - assert ip.time.has_value - - # Diamagnetic flux (reconstructed data) - for diamagnetic_flux in ids.diamagnetic_flux: - assert diamagnetic_flux.data.has_value - assert diamagnetic_flux.data_error_upper.has_value - if homogeneous_time == 0: - assert diamagnetic_flux.time.has_value diff --git a/imas_validator/assets/codes/efit++/pf_active.py b/imas_validator/assets/codes/efit++/pf_active.py deleted file mode 100644 index ac4022f..0000000 --- a/imas_validator/assets/codes/efit++/pf_active.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Required fields of EFIT++ in the pf_active IDS""" - -@validator("pf_active") -def validate_required_fields(ids): - """Validate that the pf_active IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Axisymmetric poloidal field coils - for coil in ids.coil: - # machine description - assert coil.name.has_value - assert coil.identifier.has_value - for element in coil.element: - assert element.geometry.geometry_type in [2, 3, 5, 6] - assert element.turns_with_sign.has_value - - # data - assert coil.current.data.has_value - assert coil.current.data_error_upper.has_value - if homogeneous_time == 0: - assert coil.current.time.has_value - - # PF power supplies - for supply in ids.supply: - assert supply.name.has_value - assert supply.identifier.has_value - - # Circuits - for circuit in ids.circuit: - assert circuit.connections.has_value diff --git a/imas_validator/assets/codes/efit++/pf_passive.py b/imas_validator/assets/codes/efit++/pf_passive.py deleted file mode 100644 index 57696c1..0000000 --- a/imas_validator/assets/codes/efit++/pf_passive.py +++ /dev/null @@ -1,20 +0,0 @@ -"""Required fields of EFIT++ in the pf_passive IDS""" - -@validator("pf_passive") -def validate_required_fields(ids): - """Validate that the pf_passive IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Axisymmetric passive conductors - for loop in ids.loop: - # machine description - assert loop.name.has_value - for element in loop.element: - assert element.geometry.geometry_type in [2, 3, 5, 6] - assert element.turns_with_sign.has_value - # data - assert loop.current.has_value - assert loop.current_error_upper.has_value - if homogeneous_time == 0: - assert loop.time.has_value diff --git a/imas_validator/assets/codes/efit++/tf.py b/imas_validator/assets/codes/efit++/tf.py deleted file mode 100644 index 8063a49..0000000 --- a/imas_validator/assets/codes/efit++/tf.py +++ /dev/null @@ -1,26 +0,0 @@ -"""Required fields of EFIT++ in the tf IDS""" - -@validator("tf", version="<3.42.0") -def validate_required_fields_exDD(ids): - """Validate that the tf IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Vacuume field times major radius in the toroidal field magnet. - # b_field_tor_vacuum_r is obsolete. - assert ids.b_field_tor_vacuum_r.data.has_value - if homogeneous_time == 0: - assert ids.b_field_tor_vacuum_r.time.has_value - - -@validator("tf", version=">=3.42.0") -def validate_required_fields(ids): - """Validate that the tf IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Vacuume field times major radius in the toroidal field magnet. - # b_field_tor_vacuum_r is obsolete. - assert ids.b_field_phi_vacuum_r.data.has_value - if homogeneous_time == 0: - assert ids.b_field_phi_vacuum_r.time.has_value diff --git a/imas_validator/assets/codes/efit++/wall.py b/imas_validator/assets/codes/efit++/wall.py deleted file mode 100644 index 7c80c67..0000000 --- a/imas_validator/assets/codes/efit++/wall.py +++ /dev/null @@ -1,12 +0,0 @@ -"""Required fields of EFIT++ in the wall IDS""" - -@validator("wall") -def validate_required_fields(ids): - """Validate that the wall IDS has required fields.""" - - # Wall limiter 2d - for description_2d in ids.description_2d: - # machine description - for unit in description_2d.limiter.unit: - assert unit.outline.r.has_value - assert unit.outline.z.has_value From 701e0e54339385223125e8a2580d3ce006e968b3 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 10:00:37 +0200 Subject: [PATCH 10/14] change for folder structure --- .../assets/rulesets/efitpp-code/__init__.py | 1 + .../assets/rulesets/efitpp-code/magnetics.py | 58 +++++++++++++++++++ .../assets/rulesets/efitpp-code/pf_active.py | 31 ++++++++++ .../assets/rulesets/efitpp-code/pf_passive.py | 20 +++++++ .../assets/rulesets/efitpp-code/tf.py | 26 +++++++++ .../assets/rulesets/efitpp-code/wall.py | 12 ++++ 6 files changed, 148 insertions(+) create mode 100644 imas_validator/assets/rulesets/efitpp-code/__init__.py create mode 100644 imas_validator/assets/rulesets/efitpp-code/magnetics.py create mode 100644 imas_validator/assets/rulesets/efitpp-code/pf_active.py create mode 100644 imas_validator/assets/rulesets/efitpp-code/pf_passive.py create mode 100644 imas_validator/assets/rulesets/efitpp-code/tf.py create mode 100644 imas_validator/assets/rulesets/efitpp-code/wall.py diff --git a/imas_validator/assets/rulesets/efitpp-code/__init__.py b/imas_validator/assets/rulesets/efitpp-code/__init__.py new file mode 100644 index 0000000..91f4ebd --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/__init__.py @@ -0,0 +1 @@ +"""Folder for bundled generic IMAS-Validator tests""" diff --git a/imas_validator/assets/rulesets/efitpp-code/magnetics.py b/imas_validator/assets/rulesets/efitpp-code/magnetics.py new file mode 100644 index 0000000..2f9b93a --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/magnetics.py @@ -0,0 +1,58 @@ +"""Required fields of EFIT++ in the magnetics IDS""" + +@validator("magnetics") +def validate_required_fields(ids): + """Validate that the magnetics IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Magnetic field probes + for b_field_pol_probe in ids.b_field_pol_probe: + # machine description + assert b_field_pol_probe.name.has_value + assert b_field_pol_probe.identifier.has_value + assert b_field_pol_probe.position.r.has_value + assert b_field_pol_probe.position.z.has_value + assert b_field_pol_probe.position.phi.has_value + assert b_field_pol_probe.poloidal_angle.has_value + # toroidal angle is not read by EFIT++? + # assert b_field_pol_probe.toroidal_angle.has_value + if b_field_pol_probe.type.index == 2: # 'Mirnov probe' + assert b_field_pol_probe.area.has_value + assert b_field_pol_probe.length.has_value + assert b_field_pol_probe.turns.has_value + # diagnostic data + assert b_field_pol_probe.field.data.has_value + assert b_field_pol_probe.field.data_error_upper.has_value + if homogeneous_time == 0: + assert b_field_pol_probe.field.time.has_value + + # Flux loops + for flux_loop in ids.flux_loop: + # machine description + assert flux_loop.name.has_value + assert flux_loop.identifier.has_value + # position + for position in flux_loop.position: + assert position.r.has_value + assert position.z.has_value + assert position.phi.has_value + # diagnostic data + assert flux_loop.flux.data.has_value + assert flux_loop.flux.data_error_upper.has_value + if homogeneous_time == 0: + assert flux_loop.flux.time.has_value + + # Plasma current (reconstructed data) + for ip in ids.ip: + assert ip.data.has_value + assert ip.data_error_upper.has_value + if homogeneous_time == 0: + assert ip.time.has_value + + # Diamagnetic flux (reconstructed data) + for diamagnetic_flux in ids.diamagnetic_flux: + assert diamagnetic_flux.data.has_value + assert diamagnetic_flux.data_error_upper.has_value + if homogeneous_time == 0: + assert diamagnetic_flux.time.has_value diff --git a/imas_validator/assets/rulesets/efitpp-code/pf_active.py b/imas_validator/assets/rulesets/efitpp-code/pf_active.py new file mode 100644 index 0000000..ac4022f --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/pf_active.py @@ -0,0 +1,31 @@ +"""Required fields of EFIT++ in the pf_active IDS""" + +@validator("pf_active") +def validate_required_fields(ids): + """Validate that the pf_active IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Axisymmetric poloidal field coils + for coil in ids.coil: + # machine description + assert coil.name.has_value + assert coil.identifier.has_value + for element in coil.element: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + + # data + assert coil.current.data.has_value + assert coil.current.data_error_upper.has_value + if homogeneous_time == 0: + assert coil.current.time.has_value + + # PF power supplies + for supply in ids.supply: + assert supply.name.has_value + assert supply.identifier.has_value + + # Circuits + for circuit in ids.circuit: + assert circuit.connections.has_value diff --git a/imas_validator/assets/rulesets/efitpp-code/pf_passive.py b/imas_validator/assets/rulesets/efitpp-code/pf_passive.py new file mode 100644 index 0000000..57696c1 --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/pf_passive.py @@ -0,0 +1,20 @@ +"""Required fields of EFIT++ in the pf_passive IDS""" + +@validator("pf_passive") +def validate_required_fields(ids): + """Validate that the pf_passive IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Axisymmetric passive conductors + for loop in ids.loop: + # machine description + assert loop.name.has_value + for element in loop.element: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + # data + assert loop.current.has_value + assert loop.current_error_upper.has_value + if homogeneous_time == 0: + assert loop.time.has_value diff --git a/imas_validator/assets/rulesets/efitpp-code/tf.py b/imas_validator/assets/rulesets/efitpp-code/tf.py new file mode 100644 index 0000000..8063a49 --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/tf.py @@ -0,0 +1,26 @@ +"""Required fields of EFIT++ in the tf IDS""" + +@validator("tf", version="<3.42.0") +def validate_required_fields_exDD(ids): + """Validate that the tf IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Vacuume field times major radius in the toroidal field magnet. + # b_field_tor_vacuum_r is obsolete. + assert ids.b_field_tor_vacuum_r.data.has_value + if homogeneous_time == 0: + assert ids.b_field_tor_vacuum_r.time.has_value + + +@validator("tf", version=">=3.42.0") +def validate_required_fields(ids): + """Validate that the tf IDS has required fields.""" + + homogeneous_time = ids.ids_properties.homogeneous_time + + # Vacuume field times major radius in the toroidal field magnet. + # b_field_tor_vacuum_r is obsolete. + assert ids.b_field_phi_vacuum_r.data.has_value + if homogeneous_time == 0: + assert ids.b_field_phi_vacuum_r.time.has_value diff --git a/imas_validator/assets/rulesets/efitpp-code/wall.py b/imas_validator/assets/rulesets/efitpp-code/wall.py new file mode 100644 index 0000000..7c80c67 --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp-code/wall.py @@ -0,0 +1,12 @@ +"""Required fields of EFIT++ in the wall IDS""" + +@validator("wall") +def validate_required_fields(ids): + """Validate that the wall IDS has required fields.""" + + # Wall limiter 2d + for description_2d in ids.description_2d: + # machine description + for unit in description_2d.limiter.unit: + assert unit.outline.r.has_value + assert unit.outline.z.has_value From 8c6c39aa0d60015e02c15b695806813200858ebb Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 10:04:36 +0200 Subject: [PATCH 11/14] minor change --- imas_validator/assets/rulesets/efitpp-code/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imas_validator/assets/rulesets/efitpp-code/__init__.py b/imas_validator/assets/rulesets/efitpp-code/__init__.py index 91f4ebd..df8b10b 100644 --- a/imas_validator/assets/rulesets/efitpp-code/__init__.py +++ b/imas_validator/assets/rulesets/efitpp-code/__init__.py @@ -1 +1 @@ -"""Folder for bundled generic IMAS-Validator tests""" +"""Folder for bundled code-specific IMAS-Validator tests""" From 5e4d6149fa2c3473af6b031309560ba599e6eaec Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Tue, 8 Jul 2025 10:10:23 +0200 Subject: [PATCH 12/14] efitpp-code -> efitpp_code --- .../assets/rulesets/{efitpp-code => efitpp_code}/__init__.py | 0 .../assets/rulesets/{efitpp-code => efitpp_code}/magnetics.py | 0 .../assets/rulesets/{efitpp-code => efitpp_code}/pf_active.py | 0 .../assets/rulesets/{efitpp-code => efitpp_code}/pf_passive.py | 0 imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/tf.py | 0 .../assets/rulesets/{efitpp-code => efitpp_code}/wall.py | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/__init__.py (100%) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/magnetics.py (100%) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/pf_active.py (100%) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/pf_passive.py (100%) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/tf.py (100%) rename imas_validator/assets/rulesets/{efitpp-code => efitpp_code}/wall.py (100%) diff --git a/imas_validator/assets/rulesets/efitpp-code/__init__.py b/imas_validator/assets/rulesets/efitpp_code/__init__.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/__init__.py rename to imas_validator/assets/rulesets/efitpp_code/__init__.py diff --git a/imas_validator/assets/rulesets/efitpp-code/magnetics.py b/imas_validator/assets/rulesets/efitpp_code/magnetics.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/magnetics.py rename to imas_validator/assets/rulesets/efitpp_code/magnetics.py diff --git a/imas_validator/assets/rulesets/efitpp-code/pf_active.py b/imas_validator/assets/rulesets/efitpp_code/pf_active.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/pf_active.py rename to imas_validator/assets/rulesets/efitpp_code/pf_active.py diff --git a/imas_validator/assets/rulesets/efitpp-code/pf_passive.py b/imas_validator/assets/rulesets/efitpp_code/pf_passive.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/pf_passive.py rename to imas_validator/assets/rulesets/efitpp_code/pf_passive.py diff --git a/imas_validator/assets/rulesets/efitpp-code/tf.py b/imas_validator/assets/rulesets/efitpp_code/tf.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/tf.py rename to imas_validator/assets/rulesets/efitpp_code/tf.py diff --git a/imas_validator/assets/rulesets/efitpp-code/wall.py b/imas_validator/assets/rulesets/efitpp_code/wall.py similarity index 100% rename from imas_validator/assets/rulesets/efitpp-code/wall.py rename to imas_validator/assets/rulesets/efitpp_code/wall.py From 630f014b7f552877b4a14ca5615b5f370d033576 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Wed, 9 Jul 2025 13:14:55 +0200 Subject: [PATCH 13/14] timebase checks with coordinates method and merging two functions for DDs to one --- .../assets/rulesets/efitpp_code/magnetics.py | 15 +++++-------- .../assets/rulesets/efitpp_code/pf_active.py | 5 +---- .../assets/rulesets/efitpp_code/pf_passive.py | 5 +---- .../assets/rulesets/efitpp_code/tf.py | 21 +++---------------- 4 files changed, 10 insertions(+), 36 deletions(-) diff --git a/imas_validator/assets/rulesets/efitpp_code/magnetics.py b/imas_validator/assets/rulesets/efitpp_code/magnetics.py index 2f9b93a..93a0718 100644 --- a/imas_validator/assets/rulesets/efitpp_code/magnetics.py +++ b/imas_validator/assets/rulesets/efitpp_code/magnetics.py @@ -4,8 +4,6 @@ def validate_required_fields(ids): """Validate that the magnetics IDS has required fields.""" - homogeneous_time = ids.ids_properties.homogeneous_time - # Magnetic field probes for b_field_pol_probe in ids.b_field_pol_probe: # machine description @@ -24,8 +22,7 @@ def validate_required_fields(ids): # diagnostic data assert b_field_pol_probe.field.data.has_value assert b_field_pol_probe.field.data_error_upper.has_value - if homogeneous_time == 0: - assert b_field_pol_probe.field.time.has_value + assert b_field_pol_probe.field.data.coordinates[0].has_value # Flux loops for flux_loop in ids.flux_loop: @@ -40,19 +37,17 @@ def validate_required_fields(ids): # diagnostic data assert flux_loop.flux.data.has_value assert flux_loop.flux.data_error_upper.has_value - if homogeneous_time == 0: - assert flux_loop.flux.time.has_value + assert flux_loop.flux.data.coordinates[0].has_value # Plasma current (reconstructed data) for ip in ids.ip: assert ip.data.has_value assert ip.data_error_upper.has_value - if homogeneous_time == 0: - assert ip.time.has_value + assert ip.data.coordinates[0].has_value # Diamagnetic flux (reconstructed data) for diamagnetic_flux in ids.diamagnetic_flux: assert diamagnetic_flux.data.has_value assert diamagnetic_flux.data_error_upper.has_value - if homogeneous_time == 0: - assert diamagnetic_flux.time.has_value + assert diamagnetic_flux.data.coordinates[0].has_value + diff --git a/imas_validator/assets/rulesets/efitpp_code/pf_active.py b/imas_validator/assets/rulesets/efitpp_code/pf_active.py index ac4022f..bb8d907 100644 --- a/imas_validator/assets/rulesets/efitpp_code/pf_active.py +++ b/imas_validator/assets/rulesets/efitpp_code/pf_active.py @@ -4,8 +4,6 @@ def validate_required_fields(ids): """Validate that the pf_active IDS has required fields.""" - homogeneous_time = ids.ids_properties.homogeneous_time - # Axisymmetric poloidal field coils for coil in ids.coil: # machine description @@ -18,8 +16,7 @@ def validate_required_fields(ids): # data assert coil.current.data.has_value assert coil.current.data_error_upper.has_value - if homogeneous_time == 0: - assert coil.current.time.has_value + assert coil.current.data.coordinates[0].has_value # PF power supplies for supply in ids.supply: diff --git a/imas_validator/assets/rulesets/efitpp_code/pf_passive.py b/imas_validator/assets/rulesets/efitpp_code/pf_passive.py index 57696c1..b0c398f 100644 --- a/imas_validator/assets/rulesets/efitpp_code/pf_passive.py +++ b/imas_validator/assets/rulesets/efitpp_code/pf_passive.py @@ -4,8 +4,6 @@ def validate_required_fields(ids): """Validate that the pf_passive IDS has required fields.""" - homogeneous_time = ids.ids_properties.homogeneous_time - # Axisymmetric passive conductors for loop in ids.loop: # machine description @@ -16,5 +14,4 @@ def validate_required_fields(ids): # data assert loop.current.has_value assert loop.current_error_upper.has_value - if homogeneous_time == 0: - assert loop.time.has_value + assert loop.current.coordinates[0].has_value diff --git a/imas_validator/assets/rulesets/efitpp_code/tf.py b/imas_validator/assets/rulesets/efitpp_code/tf.py index 8063a49..cf2174c 100644 --- a/imas_validator/assets/rulesets/efitpp_code/tf.py +++ b/imas_validator/assets/rulesets/efitpp_code/tf.py @@ -1,26 +1,11 @@ """Required fields of EFIT++ in the tf IDS""" -@validator("tf", version="<3.42.0") -def validate_required_fields_exDD(ids): +@validator("tf") +def validate_required_fields(ids): """Validate that the tf IDS has required fields.""" - homogeneous_time = ids.ids_properties.homogeneous_time - # Vacuume field times major radius in the toroidal field magnet. # b_field_tor_vacuum_r is obsolete. assert ids.b_field_tor_vacuum_r.data.has_value - if homogeneous_time == 0: - assert ids.b_field_tor_vacuum_r.time.has_value - + assert ids.b_field_tor_vacuum_r.data.coordinates[0].has_value -@validator("tf", version=">=3.42.0") -def validate_required_fields(ids): - """Validate that the tf IDS has required fields.""" - - homogeneous_time = ids.ids_properties.homogeneous_time - - # Vacuume field times major radius in the toroidal field magnet. - # b_field_tor_vacuum_r is obsolete. - assert ids.b_field_phi_vacuum_r.data.has_value - if homogeneous_time == 0: - assert ids.b_field_phi_vacuum_r.time.has_value From 1a2b74b15bc2b8338e29e86c95a8a9ffd1596451 Mon Sep 17 00:00:00 2001 From: MasanariHosokawa Date: Wed, 9 Jul 2025 13:23:34 +0200 Subject: [PATCH 14/14] black --- imas_validator/assets/rulesets/efitpp_code/magnetics.py | 1 - imas_validator/assets/rulesets/efitpp_code/tf.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/imas_validator/assets/rulesets/efitpp_code/magnetics.py b/imas_validator/assets/rulesets/efitpp_code/magnetics.py index 93a0718..86531cb 100644 --- a/imas_validator/assets/rulesets/efitpp_code/magnetics.py +++ b/imas_validator/assets/rulesets/efitpp_code/magnetics.py @@ -50,4 +50,3 @@ def validate_required_fields(ids): assert diamagnetic_flux.data.has_value assert diamagnetic_flux.data_error_upper.has_value assert diamagnetic_flux.data.coordinates[0].has_value - diff --git a/imas_validator/assets/rulesets/efitpp_code/tf.py b/imas_validator/assets/rulesets/efitpp_code/tf.py index cf2174c..c66824a 100644 --- a/imas_validator/assets/rulesets/efitpp_code/tf.py +++ b/imas_validator/assets/rulesets/efitpp_code/tf.py @@ -5,7 +5,5 @@ def validate_required_fields(ids): """Validate that the tf IDS has required fields.""" # Vacuume field times major radius in the toroidal field magnet. - # b_field_tor_vacuum_r is obsolete. assert ids.b_field_tor_vacuum_r.data.has_value assert ids.b_field_tor_vacuum_r.data.coordinates[0].has_value -