Skip to content

Commit ef03ac5

Browse files
Julian Kates-HarbeckJulian Kates-Harbeck
authored andcommitted
attempting d3d signal download
1 parent 436cbe2 commit ef03ac5

File tree

5 files changed

+192
-89
lines changed

5 files changed

+192
-89
lines changed

data/d3d_signals.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#JET signal hierarchy
2+
#------------------------------------------------------------------------#
3+
#User only needs to look at 1st and last sections
4+
# - conf.py only needs to import signals_dirs and signals_masks
5+
# - get_mdsplus_data.py only needs signals_dirs and download_masks
6+
# - performance_analysis_utils.py needs :
7+
# - signals_dirs, plot_masks, ppf_labels, jpf_labels
8+
#------------------------------------------------------------------------#
9+
################
10+
# Signal names #
11+
################
12+
#This section contains all the exact JET signal strings and their
13+
#groupings by type and dimensionality.
14+
#User should not touch this. Use for reference
15+
16+
17+
### 0D signals ###
18+
signal_paths = [
19+
'efsli', #Internal Inductance
20+
'ipsip', #Plasma Current
21+
'efsbetan', #Normalized Beta
22+
'efswmhd', #Stored Energy
23+
'nssampn1l', #Tearing Mode Amplitude (rotating 2/1)
24+
'nssfrqn1l', #Tearing Mode Frequency (rotating 2/1)
25+
'nssampn2l', #Tearing Mode Amplitude (rotating 3/2)
26+
'nssfrqn2l', #Tearing Mode Frequency (rotating 3/2)
27+
'dusbradial', #LM Amplitude
28+
'dssdenest', #Plasma Density
29+
r'\bol_l15_p', #Radiated Power core
30+
r'\bol_l03_p', #Radiated Power Edge
31+
'bmspinj', #Total Beam Power
32+
'bmstinj', #Total Beam Torque
33+
'pcechpwrf'] #Total ECH Power
34+
35+
signal_paths = ['d3d/' + path for path in signal_paths]
36+
37+
### 1D EFIT signals ###
38+
signal_paths += [
39+
'AOT/EQU.te', #electron temperature profile vs rho (uniform mapping over time)
40+
'AOT/EQU.dens_e'] #electron density profile vs rho (uniform mapping over time)
41+
42+
#make into list of lists format to be consistent with jet_signals.py
43+
signal_paths = [[path] for path in signal_paths]
44+
45+
#format : 'tree/signal_path' for each path
46+
signals_dirs = signal_paths
47+
48+
49+
##################################################
50+
# USER SELECTIONS #
51+
##################################################
52+
53+
54+
##################################
55+
# Select signals for downloading #
56+
##################################
57+
58+
#Default pass to get_mdsplus_data.py: download all above signals
59+
download_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
60+
# download_masks[-1] = [False] # enable/disable temperature profile
61+
# download_masks[-2] = [False] # enable/disable density profile
62+
63+
#######################################
64+
# Select signals for training/testing #
65+
#######################################
66+
67+
#Default pass to conf.py: train with all above signals
68+
signals_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
69+
signals_masks[-1] = [False] # enable/disable temperature profile
70+
signals_masks[-2] = [False] # enable/disable density profile
71+
72+
#num_signals = sum([group.count(True) for i,group in enumerate(jet_signals.signals_masks)]
73+
###########################################
74+
# Select signals for performance analysis #
75+
###########################################
76+
77+
#User selects these by signal name
78+
plot_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
79+
80+
#LaTeX strings for performance analysis, sorted in lists by signal_group
81+
group_labels = [[r' $I_{plasma}$ [A]'],
82+
[r' Mode L. A. [A]'],
83+
[r' $P_{radiated}$ [W]'], #0d radiation, db/
84+
[r' $P_{radiated}$ [W]'],#1d radiation, db/
85+
[r' $\rho_{plasma}$ [m^-2]'],
86+
[r' $L_{plasma,internal}$'],
87+
[r'$\frac{d}{dt} E_{D}$ [W]'],
88+
[r' $P_{input}$ [W]'],
89+
[r'$E_{D}$'],
90+
#ppf signal labels
91+
[r'ECE unit?']]

data/gadata.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import MDSplus
2+
import numpy
3+
import time
4+
import sys
5+
6+
class gadata:
7+
"""GA Data Obj"""
8+
def __init__(self,signal,shot,tree=None,connection=None,nomds=False):
9+
10+
# Save object values
11+
self.signal = signal
12+
self.shot = shot
13+
self.zdata = -1
14+
self.xdata = -1
15+
self.ydata = -1
16+
self.zunits = ''
17+
self.xunits = ''
18+
self.yunits = ''
19+
self.rank = -1
20+
self.connection = connection
21+
22+
## Retrieve Data
23+
t0 = time.time()
24+
found = False
25+
26+
# Create the MDSplus connection (thin) if not passed in
27+
if self.connection is None:
28+
self.connection = MDSplus.Connection('atlas.gat.com')
29+
30+
# Retrieve data from MDSplus (thin)
31+
if nomds == False:
32+
#first try, retrieve directly from tree and tag
33+
try:
34+
if tree != None:
35+
tag = self.signal
36+
fstree = tree
37+
else:
38+
tag = self.connection.get('findsig("'+self.signal+'",_fstree)').value
39+
fstree = self.connection.get('_fstree').value
40+
41+
self.connection.openTree(fstree,shot)
42+
self.zdata = self.connection.get('_s = '+tag).data()
43+
self.zunits = self.connection.get('units_of(_s)').data()
44+
self.rank = numpy.ndim(self.zdata)
45+
self.xdata = self.connection.get('dim_of(_s)').data()
46+
self.xunits = self.connection.get('units_of(dim_of(_s))').data()
47+
if self.xunits == '' or self.xunits == ' ':
48+
self.xunits = self.connection.get('units(dim_of(_s))').data()
49+
if self.rank > 1:
50+
self.ydata = self.connection.get('dim_of(_s,1)').data()
51+
self.yunits = self.connection.get('units_of(dim_of(_s,1))').data()
52+
if self.yunits == '' or self.yunits == ' ':
53+
self.yunits = self.connection.get('units(dim_of(_s,1))').data()
54+
found = True
55+
56+
# MDSplus seems to return 2-D arrays transposed. Change them back.
57+
if numpy.ndim(self.zdata) == 2: self.zdata = numpy.transpose(self.zdata)
58+
if numpy.ndim(self.ydata) == 2: self.ydata = numpy.transpose(self.ydata)
59+
if numpy.ndim(self.xdata) == 2: self.xdata = numpy.transpose(self.xdata)
60+
61+
except Exception,e:
62+
#node not found
63+
# print ' Signal not in MDSplus: %s' % (signal,)
64+
pass
65+
66+
# Retrieve data from PTDATA if node not found
67+
if not found:
68+
self.zdata = self.connection.get('_s = ptdata2("'+signal+'",'+str(shot)+')')
69+
if len(self.zdata) != 1:
70+
self.xdata = self.connection.get('dim_of(_s)')
71+
self.rank = 1
72+
found = True
73+
74+
# Retrieve data from Pseudo-pointname if not in ptdata
75+
if not found:
76+
# print ' Signal not in PTDATA: %s' % (signal,)
77+
self.zdata = self.connection.get('_s = pseudo("'+signal+'",'+str(shot)+')')
78+
if len(self.zdata) != 1:
79+
self.xdata = self.connection.get('dim_of(_s)')
80+
self.rank = 1
81+
found = True
82+
83+
if not found:
84+
# print ' Signal not in pseudo-pointname: %s' % (signal,)
85+
print " No such signal: %s" % (signal,)
86+
87+
print ' GADATA Retrieval Time : ',time.time() - t0
88+
return

data/get_data.py

Lines changed: 0 additions & 86 deletions
This file was deleted.

data/get_mdsplus_data.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@
4242
# shot_numbers_files = ['shotlist_JaysonBarr_disrupt.txt']
4343
shot_numbers_files = ['d3d_single_clear.txt']# ,'d3d_clear.txt', 'd3d_disrupt.txt']
4444
server_path = 'atlas.gat.com'
45+
import d3d_signals
4546
# signal_paths = ['PINJ','IP','Q95','DENSITY','WMHD'] #,'PRAD'] #PRAD returns a 2D xdata
4647
# Recommended signals from DIII-D
47-
signal_paths = ['efsli','ipsip','efsbetan','efswmhd','nssampn1l','nssfrqn1l',
48-
'nssampn2l','nssfrqn2l',
49-
'dusbradial','dssdenest',r'\bol_l15_p',r'\bol_l03_p','bmspinj','bmstinj','pcechpwrf']
48+
# signal_paths = ['efsli','ipsip','efsbetan','efswmhd','nssampn1l','nssfrqn1l',
49+
# 'nssampn2l','nssfrqn2l',
50+
# 'dusbradial','dssdenest',r'\bol_l15_p',r'\bol_l03_p','bmspinj','bmstinj','pcechpwrf']
51+
# signal_paths = ['d3d/' + path for path in signal_paths]
52+
53+
54+
5055
elif machine == 'jet':
5156
shot_numbers_files = ['CWall_clear.txt','CFC_unint.txt','BeWall_clear.txt','ILW_unint.txt']
5257
server_path = 'mdsplus.jet.efda.org'
@@ -222,3 +227,8 @@ def save_shot(shot_num_queue,c,signal_paths,save_prepath,machine):
222227

223228
# pool.close()
224229
# pool.join()
230+
231+
232+
233+
234+
File renamed without changes.

0 commit comments

Comments
 (0)