Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for MAST maching mappings. #308

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion omas/machine_mappings/mast.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,62 @@ def thomson_scattering_hardware(ods, pulse):


@machine_mapping_function(__regression_arguments__, pulse=44653)
def thomson_scattering_data(ods, pulse):
def thomson_scattering_data(ods, pulse, server=None, port=None):
"""
Loads MAST Thomson measurement data

:param pulse: int
"""


if int(pulse) < 23000:
trace_te = "atm_te"
trace_ne = "atm_ne"
trace_r = "atm_R"
elif int(pulse) > 43000:
trace_te = "ayc/T_e"
trace_ne = "ayc/n_e"
trace_r = "ayc/r"
else:
trace_te = "ayc_te"
trace_ne = "ayc_ne"
trace_r = "ayc_r"

client = get_pyuda_client(server=server, port=port)

udasignal = client.get(trace_te, pulse)

Te_data = udasignal.data
Te_err = udasignal.errors
Te_time = udasignal.dims[0].data
udasignal = client.get(trace_ne, pulse)
ne_data = udasignal.data
ne_err = udasignal.errors
ne_time = udasignal.dims[0].data

r = client.get(trace_r, pulse).data

r = r[0]

for i, R in enumerate(r):

ch = ods['thomson_scattering']['channel'][i]
ch['name'] = 'ch_' + str(i)
ch['identifier'] = 'ch_' + str(i)
ch['position']['r'] = R
ch['position']['z'] = 0.0

mask = ~np.isnan(ne_data[:,i])

ch['n_e.time'] = ne_time[mask]
ch['n_e.data_error_upper'] = ne_err[mask,i]
ch['n_e.data'] = ne_data[mask,i]

mask = ~np.isinf(Te_data[:,i])
ch['t_e.time'] = Te_time[mask]
ch['t_e.data_error_upper'] = Te_err[mask,i]
ch['t_e.data'] = Te_data[mask,i]

return

@machine_mapping_function(__regression_arguments__, pulse=44653)
Expand Down
9 changes: 6 additions & 3 deletions omas/omas_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
except:
pass

try:
from omas.machine_mappings import mast
except ImportError:
pass
torrinba marked this conversation as resolved.
Show resolved Hide resolved


__all__ = [
'machine_expression_types',
'machines',
Expand Down Expand Up @@ -215,9 +221,6 @@ def resolve_mapped(ods, machine, pulse, mappings, location, idm, options_with_d

# PYTHON
elif 'PYTHON' in mapped:
if 'mast' in machine:
printe(f"MAST is currently not supported because of UDA", topic='machine')
return ods
call = mapped['PYTHON'].format(**options_with_defaults)
# python functions tend to set multiple locations at once
# it is thus very beneficial to cache that
Expand Down
Loading