From e01fc8c7c702314cb44b7c14dc31c3635e6cf2b5 Mon Sep 17 00:00:00 2001 From: Severin Denk Date: Mon, 11 Nov 2024 15:46:35 -0800 Subject: [PATCH 1/2] Add toray bhalf as code parameter --- omas/machine_mappings/d3d.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/omas/machine_mappings/d3d.py b/omas/machine_mappings/d3d.py index a5b503b9..4ff6de3f 100644 --- a/omas/machine_mappings/d3d.py +++ b/omas/machine_mappings/d3d.py @@ -519,7 +519,8 @@ def ec_launcher_active_hardware(ods, pulse): query[f'GYROTRON_{system_no}'] = setup + cur_system + 'GYROTRON.NAME' query[f'FREQUENCY_{system_no}'] = setup + cur_system + 'GYROTRON.FREQUENCY' for field in ['LAUNCH_R', 'LAUNCH_Z', 'PORT']: - query[field + f'_{system_no}'] = setup + cur_system + f'antenna.{field}' + query[field + f'_{system_no}'] = setup + cur_system + f'ANTENNA.{field}' + query["DISPERSION" + f'_{system_no}'] = setup + cur_system + f'ANTENNA.DISPERSION' systems = mdsvalue('d3d', treename='RF', pulse=pulse, TDI=query).raw() query = {} gyrotron_names = [] @@ -539,10 +540,12 @@ def ec_launcher_active_hardware(ods, pulse): query["TIME_" + field + f'_{system_no}'] = "dim_of(" + query[field + f'_{system_no}'] + "+01)" # Final, third query now that we have resolved all the TDIs related to gyrotron names gyrotrons = mdsvalue('d3d', treename='RF', pulse=pulse, TDI=query).raw() + b_half = [] for system_no in range(1, system_max): system_index = system_no - 1 if gyrotrons[f'STAT_{system_no}'] == 0: continue + b_half.append(query["DISPERSION" + f'_{system_no}']) beam = ods['ec_launchers.beam'][system_index] time = np.atleast_1d(gyrotrons[f'TIME_AZIANG_{system_no}']) / 1.0e3 if len(time) == 1: @@ -589,7 +592,10 @@ def ec_launcher_active_hardware(ods, pulse): beam['phase.curvature'] = np.zeros([2, ntime]) beam['spot.angle'] = np.zeros(ntime) beam['spot.size'] = 0.0172 * np.ones([2, ntime]) - + # bhalf is the fake diffration ray divergence that TORAY uses. It is also known as HLWEC in onetwo + # For more info look for hlwec in the TORAY documentation + ods['ec_launchers.code.parameters'] = CodeParameters() + ods['ec_launchers.code.parameters']["toray.bhalf"] = np.array(b_half) # ================================ @machine_mapping_function(__regression_arguments__, pulse=133221) From 2fb89f732647584ad3e70bf247cc8c3103960f97 Mon Sep 17 00:00:00 2001 From: Severin Denk Date: Mon, 11 Nov 2024 18:37:11 -0800 Subject: [PATCH 2/2] Fix missing codeparameter import --- omas/machine_mappings/d3d.json | 3 +++ omas/machine_mappings/d3d.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/omas/machine_mappings/d3d.json b/omas/machine_mappings/d3d.json index 063d9384..adce1da1 100644 --- a/omas/machine_mappings/d3d.json +++ b/omas/machine_mappings/d3d.json @@ -310,6 +310,9 @@ "ec_launchers.beam.:.time": { "PYTHON": "ec_launcher_active_hardware(ods, {pulse})" }, + "ec_launchers.code.parameters.toray.bhalf": { + "PYTHON": "ec_launcher_active_hardware(ods, {pulse})" + }, "ece": { "PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})" }, diff --git a/omas/machine_mappings/d3d.py b/omas/machine_mappings/d3d.py index 4ff6de3f..3814c3c0 100644 --- a/omas/machine_mappings/d3d.py +++ b/omas/machine_mappings/d3d.py @@ -501,6 +501,7 @@ def coils_non_axisymmetric_current_data(ods, pulse): # ================================ @machine_mapping_function(__regression_arguments__, pulse=170325) def ec_launcher_active_hardware(ods, pulse): + from omas.omas_core import CodeParameters setup = '.ECH.' # We need three queries in order to retrieve only the fields we need # First the amount of systems in use @@ -545,7 +546,7 @@ def ec_launcher_active_hardware(ods, pulse): system_index = system_no - 1 if gyrotrons[f'STAT_{system_no}'] == 0: continue - b_half.append(query["DISPERSION" + f'_{system_no}']) + b_half.append(systems["DISPERSION" + f'_{system_no}']) beam = ods['ec_launchers.beam'][system_index] time = np.atleast_1d(gyrotrons[f'TIME_AZIANG_{system_no}']) / 1.0e3 if len(time) == 1: