Skip to content

Commit

Permalink
Merge branch 'omas_plot_w_new_EFIT_mapping' into mapping_to_from_rho_…
Browse files Browse the repository at this point in the history
…tor_norm
  • Loading branch information
AreWeDreaming committed Dec 12, 2023
2 parents 8f1568a + df0ae53 commit acb609a
Show file tree
Hide file tree
Showing 30 changed files with 1,002 additions and 448 deletions.
10 changes: 6 additions & 4 deletions omas/examples/omas_dynamic_imas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
# set OMAS_DEBUG_TOPIC to see when data is loaded dynamically
os.environ['OMAS_DEBUG_TOPIC'] = 'dynamic'

user = os.environ.get('USER', "default_user")

# generate some data and save it in IMAS
ods = ODS().sample(ntimes=2)
ods.save('imas', os.environ['USER'], 'DIII-D', 1000, 0, new=True, verbose=True)
ods.save('imas', user, 'DIII-D', 1000, 0, new=True, verbose=True)

# ODS.open() will keep the file descriptor open so that OMAS
# can load in memory only the data when it is first requested
# NOTE: one can use the `with` statement or open()/close()
ods = ODS()
with ods.open('imas', os.environ['USER'], 'DIII-D', 1000, 0):
with ods.open('imas', user, 'DIII-D', 1000, 0):
# data gets read from IMAS when first requested
print(ods['equilibrium.time_slice.:.global_quantities.ip'])
# then it is in memory
Expand All @@ -37,10 +39,10 @@
print(ods.flat().keys())

# continue loading more data
with ods.open('imas', os.environ['USER'], 'DIII-D', 1000, 0):
with ods.open('imas', user, 'DIII-D', 1000, 0):
print(ods['equilibrium.time'])

# tell us what IMAS elements have data
with ods.open('imas', os.environ['USER'], 'DIII-D', 1000, 0):
with ods.open('imas', user, 'DIII-D', 1000, 0):
print(ods.keys())
print(ods['equilibrium.time_slice.0.profiles_1d'].keys())
2 changes: 1 addition & 1 deletion omas/examples/omas_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# how to manipulate data that has units
ods.sample()
with omas_environment(ods, unitsio=True):
ne = ods['core_profiles.profiles_1d.0.electrons.density_thermal']
ne = ods['core_profiles.profiles_1d.0.electrons.density']
print(f'Mean density in m^-3: {numpy.mean(ne.to("m^-3").magnitude):3.3g}')
print(f'Mean density in cm^-3: {numpy.mean(ne.to("cm^-3").magnitude):3.3g}')

Expand Down
8 changes: 4 additions & 4 deletions omas/examples/save_load_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def through_omas_suite(ods=None, test_type=None, do_raise=False):
os.environ['OMAS_DEBUG_TOPIC'] = test_type
ods1 = globals()['through_omas_' + test_type](ods)
difference = ods.diff(ods1)
if not chedifferenceck:
print('OMAS data got saved and loaded correctly')
else:
pprint(difference)

print('OMAS data got saved and loaded correctly')
print("Diff:")
pprint(difference)

else:
os.environ['OMAS_DEBUG_TOPIC'] = '*'
Expand Down
17 changes: 11 additions & 6 deletions omas/machine_mappings/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from omas.omas_utils import printd
import os
import glob
from omas.omas_setup import omas_dir
from omas.utilities.omas_mds import mdsvalue, get_pulse_id

__support_files_cache__ = {}

Expand Down Expand Up @@ -45,30 +47,33 @@ def get_support_file(object_type, filename):
__MDS_gEQDSK_COCOS_identify_cache__ = {}


def MDS_gEQDSK_COCOS_identify(machine, pulse, EFIT_tree):
def MDS_gEQDSK_COCOS_identify(machine, pulse, EFIT_tree, EFIT_run_id):
"""
Python function that queries MDS+ EFIT tree to figure
out COCOS convention used for a particular reconstruction
:param machine: machine name
:param pulse: pulse
:param pulse: pulse number
:param EFIT_tree: MDS+ EFIT tree name
:param EFIT_run_id: with id extension for non-standard shot numbers. E.g. 19484401 for EFIT tree
:return: integer cocos convention
"""
if (machine, pulse, EFIT_tree) in __MDS_gEQDSK_COCOS_identify_cache__:
return __MDS_gEQDSK_COCOS_identify_cache__[(machine, pulse, EFIT_tree)]
pulse_id = get_pulse_id(pulse, EFIT_run_id)
if (machine, pulse_id, EFIT_tree) in __MDS_gEQDSK_COCOS_identify_cache__:
return __MDS_gEQDSK_COCOS_identify_cache__[(machine, pulse_id, EFIT_tree)]
TDIs = {'bt': f'mean(\\{EFIT_tree}::TOP.RESULTS.GEQDSK.BCENTR)', 'ip': f'mean(\\{EFIT_tree}::TOP.RESULTS.GEQDSK.CPASMA)'}
res = mdsvalue(machine, EFIT_tree, pulse, TDIs).raw()
res = mdsvalue(machine, EFIT_tree, pulse_id, TDIs).raw()
bt = res['bt']
ip = res['ip']
g_cocos = {(+1, +1): 1, (+1, -1): 3, (-1, +1): 5, (-1, -1): 7, (+1, 0): 1, (-1, 0): 3}
sign_Bt = int(np.sign(bt))
sign_Ip = int(np.sign(ip))
cocosio = g_cocos.get((sign_Bt, sign_Ip), None)
__MDS_gEQDSK_COCOS_identify_cache__[(machine, pulse, EFIT_tree)] = cocosio
__MDS_gEQDSK_COCOS_identify_cache__[(machine, pulse_id, EFIT_tree)] = cocosio
return cocosio


Expand Down
2 changes: 1 addition & 1 deletion omas/machine_mappings/_efit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"__cocos_rules__": {
"EFIT_tree": {
"eval2TDI": "py2tdi(MDS_gEQDSK_COCOS_identify, 'data(\\{EFIT_tree}::TOP.RESULTS.GEQDSK.BCENTR)', 'data(\\{EFIT_tree}::TOP.RESULTS.GEQDSK.CPASMA)')",
"PYTHON": "MDS_gEQDSK_COCOS_identify({machine!r}, {pulse}, {EFIT_tree!r})"
"PYTHON": "MDS_gEQDSK_COCOS_identify({machine!r}, {pulse}, {EFIT_tree!r}, {EFIT_run_id!r})"
}
},
"equilibrium.code.name": {
Expand Down
138 changes: 124 additions & 14 deletions omas/machine_mappings/d3d.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"default_tree": "D3D",
"fast_ece": false,
"nref": 0,
"revision": "BLESSED"
"revision": "BLESSED",
"PROFILES_run_id": null,
"EFIT_run_id": null
},
"bolometer.channel.:": {
"PYTHON": "bolometer_hardware(ods, {pulse})"
Expand Down Expand Up @@ -117,28 +119,124 @@
"COCOSIO": 11,
"PYTHON": "core_profiles_global_quantities_data(ods, {pulse})"
},
"core_profiles.ids_properties.homogeneous_time": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:": {
"TDI": "size(\\{PROFILES_tree}::TOP.PROFILES.EDENSFIT,1)",
"treename": "{PROFILES_tree}"
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.e_field.radial": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.e_field.radial_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.density": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.density_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.density_fit.measured": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.density_thermal": {
"TDI": "\\{PROFILES_tree}::TOP.PROFILES.EDENSFIT",
"treename": "{PROFILES_tree}"
"core_profiles.profiles_1d.:.electrons.density_fit.measured_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.density_fit.psi_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.temperature": {
"TDI": "\\{PROFILES_tree}::TOP.PROFILES.ETEMPFIT",
"treename": "{PROFILES_tree}"
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.temperature_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.temperature_fit.measured": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.temperature_fit.measured_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.electrons.temperature_fit.psi_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.grid.rho_pol_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.grid.rho_tor_norm": {
"eval2TDI": "py2tdi(tile,'dim_of(\\{PROFILES_tree}::TOP.PROFILES.EDENSFIT,0)','size(\\{PROFILES_tree}::TOP.PROFILES.EDENSFIT,1)')",
"treename": "{PROFILES_tree}"
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.density": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.density_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.density_fit.measured": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.density_fit.measured_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.density_fit.psi_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.element.:": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.element.:.a": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.element.:.z_n": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.label": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.time": {
"TDI": "dim_of(\\{PROFILES_tree}::TOP.PROFILES.EDENSFIT,1)/1000.",
"treename": "{PROFILES_tree}"
"core_profiles.profiles_1d.:.ion.:.temperature": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.temperature_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.temperature_fit.measured": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.temperature_fit.measured_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.temperature_fit.psi_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.velocity.toroidal": {
"COCOSIO": 11,
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.velocity.toroidal_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.velocity.toroidal_fit.measured": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.velocity.toroidal_fit.measured_error_upper": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.ion.:.velocity.toroidal_fit.psi_norm": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.j_total": {
"COCOSIO": 11,
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.profiles_1d.:.pressure_perpendicular": {
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"core_profiles.time": {
"PYTHON": "core_profiles_global_quantities_data(ods, {pulse})"
"PYTHON": "core_profiles_profile_1d(ods, {pulse}, {PROFILES_tree!r}, {PROFILES_run_id!r})"
},
"ec_launchers.beam.:": {
"PYTHON": "ec_launcher_active_hardware(ods, {pulse})"
Expand Down Expand Up @@ -199,6 +297,9 @@
"ec_launchers.beam.:.time": {
"PYTHON": "ec_launcher_active_hardware(ods, {pulse})"
},
"ece": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
"ece.channel.:": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
Expand All @@ -208,6 +309,9 @@
"ece.channel.:.identifier": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
"ece.channel.:.if_bandwidth": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
"ece.channel.:.name": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
Expand All @@ -217,6 +321,9 @@
"ece.channel.:.time": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
"ece.ids_properties.homogeneous_time": {
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
},
"ece.line_of_sight.first_point.phi": {
"COCOSIO": 11,
"PYTHON": "electron_cyclotron_emission_hardware(ods, {pulse}, {fast_ece!r})"
Expand Down Expand Up @@ -594,5 +701,8 @@
2
],
"treename": "{EFIT_tree}"
},
"wall.ids_properties.homogeneous_time": {
"VALUE": 1
}
}
Loading

0 comments on commit acb609a

Please sign in to comment.