Skip to content

Commit 33681eb

Browse files
committed
Clean up files in data/
1 parent 1e985a9 commit 33681eb

File tree

7 files changed

+693
-507
lines changed

7 files changed

+693
-507
lines changed

data/d3d_signals.py

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,59 @@
1-
#JET signal hierarchy
2-
#------------------------------------------------------------------------#
3-
#User only needs to look at 1st and last sections
1+
# D3D signal hierarchy
2+
# ------------------------------------------------------------------------
3+
# User only needs to look at 1st and last sections
44
# - conf.py only needs to import signals_dirs and signals_masks
55
# - get_mdsplus_data.py only needs signals_dirs and download_masks
66
# - performance_analysis_utils.py needs :
77
# - signals_dirs, plot_masks, ppf_labels, jpf_labels
8-
#------------------------------------------------------------------------#
8+
# ------------------------------------------------------------------------
99
################
1010
# Signal names #
1111
################
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
12+
# This section contains all the exact D3D signal strings and their
13+
# groupings by type and dimensionality.
14+
# User should not touch this. Use for reference
1515

1616

17-
### 0D signals ###
17+
# 0D signals #
1818
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 Not always on!
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 Not always on!
3434

3535
signal_paths = ['d3d/' + path for path in signal_paths]
3636

37-
### 0D EFIT signals ###
37+
# 0D EFIT signals
3838
signal_paths += ['EFIT01/RESULTS.AEQDSK.Q95']
39-
40-
### 1D EFIT signals ###
41-
#signal_paths += [
42-
#'AOT/EQU.t_e', #electron temperature profile vs rho (uniform mapping over time)
43-
#'AOT/EQU.dens_e'] #electron density profile vs rho (uniform mapping over time)
4439

45-
#these signals seem to give more reliable data
40+
# 1D EFIT signals
41+
# signal_paths += [
42+
# 'AOT/EQU.t_e', # electron temperature profile vs rho
43+
# 'AOT/EQU.dens_e'] # electron density profile vs rho
44+
45+
# these signals seem to give more reliable data
4646
signal_paths += [
47-
'ZIPFIT01/PROFILES.ETEMPFIT', #electron temperature profile vs rho (uniform mapping over time)
48-
'ZIPFIT01/PROFILES.EDENSFIT'] #electron density profile vs rho (uniform mapping over time)
47+
'ZIPFIT01/PROFILES.ETEMPFIT', # electron temperature profile vs rho
48+
'ZIPFIT01/PROFILES.EDENSFIT'] # electron density profile vs rho
4949

50-
#make into list of lists format to be consistent with jet_signals.py
50+
# make into list of lists format to be consistent with jet_signals.py
5151
signal_paths = [[path] for path in signal_paths]
5252

53-
#format : 'tree/signal_path' for each path
53+
# format : 'tree/signal_path' for each path
5454
signals_dirs = signal_paths
5555

56-
56+
5757
##################################################
5858
# USER SELECTIONS #
5959
##################################################
@@ -63,37 +63,39 @@
6363
# Select signals for downloading #
6464
##################################
6565

66-
#Default pass to get_mdsplus_data.py: download all above signals
66+
# Default pass to get_mdsplus_data.py: download all above signals
6767
download_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
68-
# download_masks[-1] = [False] # enable/disable temperature profile
69-
# download_masks[-2] = [False] # enable/disable density profile
68+
# download_masks[-1] = [False] # enable/disable temperature profile
69+
# download_masks[-2] = [False] # enable/disable density profile
7070

7171
#######################################
7272
# Select signals for training/testing #
7373
#######################################
7474

75-
#Default pass to conf.py: train with all above signals
75+
# Default pass to conf.py: train with all above signals
7676
signals_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
77-
signals_masks[-1] = [False] # enable/disable temperature profile
78-
signals_masks[-2] = [False] # enable/disable density profile
77+
signals_masks[-1] = [False] # enable/disable temperature profile
78+
signals_masks[-2] = [False] # enable/disable density profile
79+
80+
# num_signals = sum([group.count(True) for i, group in
81+
# enumerate(jet_signals.signals_masks)]
7982

80-
#num_signals = sum([group.count(True) for i,group in enumerate(jet_signals.signals_masks)]
8183
###########################################
8284
# Select signals for performance analysis #
8385
###########################################
8486

85-
#User selects these by signal name
87+
# User selects these by signal name
8688
plot_masks = [[True]*len(sig_list) for sig_list in signals_dirs]
8789

88-
#LaTeX strings for performance analysis, sorted in lists by signal_group
90+
# LaTeX strings for performance analysis, sorted in lists by signal_group
8991
group_labels = [[r' $I_{plasma}$ [A]'],
90-
[r' Mode L. A. [A]'],
91-
[r' $P_{radiated}$ [W]'], #0d radiation, db/
92-
[r' $P_{radiated}$ [W]'],#1d radiation, db/
93-
[r' $\rho_{plasma}$ [m^-2]'],
94-
[r' $L_{plasma,internal}$'],
95-
[r'$\frac{d}{dt} E_{D}$ [W]'],
96-
[r' $P_{input}$ [W]'],
97-
[r'$E_{D}$'],
98-
#ppf signal labels
92+
[r' Mode L. A. [A]'],
93+
[r' $P_{radiated}$ [W]'], # 0d radiation, db/
94+
[r' $P_{radiated}$ [W]'], # 1d radiation, db/
95+
[r' $\rho_{plasma}$ [m^-2]'],
96+
[r' $L_{plasma,internal}$'],
97+
[r'$\frac{d}{dt} E_{D}$ [W]'],
98+
[r' $P_{input}$ [W]'],
99+
[r'$E_{D}$'],
100+
# ppf signal labels
99101
[r'ECE unit?']]

data/gadata.py

Lines changed: 93 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,108 @@
1-
import MDSplus
1+
import MDSplus
22
import numpy
3-
import time
4-
import sys
3+
# import time
4+
55

66
class gadata:
7-
"""GA Data Obj"""
8-
def __init__(self,signal,shot,tree=None,connection=None,nomds=False):
7+
"""GA Data Obj"""
8+
9+
def __init__(self, signal, shot, tree=None, connection=None, nomds=False):
910

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-
11+
# Save object values
12+
self.signal = signal
13+
self.shot = shot
14+
self.zdata = -1
15+
self.xdata = -1
16+
self.ydata = -1
17+
self.zunits = ''
18+
self.xunits = ''
19+
self.yunits = ''
20+
self.rank = -1
21+
self.connection = connection
2222

23-
## Retrieve Data
24-
t0 = time.time()
25-
self.found = False
23+
# Retrieve Data
24+
# t0 = time.time()
25+
self.found = False
2626

27-
# Create the MDSplus connection (thin) if not passed in
28-
if self.connection is None:
29-
self.connection = MDSplus.Connection('atlas.gat.com')
27+
# Create the MDSplus connection (thin) if not passed in
28+
if self.connection is None:
29+
self.connection = MDSplus.Connection('atlas.gat.com')
3030

31-
# Retrieve data from MDSplus (thin)
32-
if nomds == False:
33-
#first try, retrieve directly from tree and tag
34-
try:
35-
#print 'trying direct using tree and tag'
36-
if tree != None:
37-
tag = self.signal
38-
fstree = tree
39-
else:
40-
tag = self.connection.get('findsig("'+self.signal+'",_fstree)').value
41-
fstree = self.connection.get('_fstree').value
31+
# Retrieve data from MDSplus (thin)
32+
if not nomds:
33+
# first try, retrieve directly from tree and tag
34+
try:
35+
# print('trying direct using tree and tag')
36+
if tree is not None:
37+
tag = self.signal
38+
fstree = tree
39+
else:
40+
tag = self.connection.get(
41+
'findsig("' + self.signal + '",_fstree)').value
42+
fstree = self.connection.get('_fstree').value
4243

43-
self.connection.openTree(fstree,shot)
44-
self.zdata = self.connection.get('_s = '+tag).data()
45-
self.zunits = self.connection.get('units_of(_s)').data()
46-
self.rank = numpy.ndim(self.zdata)
47-
if self.rank > 1:
48-
self.xdata = self.connection.get('dim_of(_s,1)').data()
49-
self.xunits = self.connection.get('units_of(dim_of(_s,1))').data()
50-
if self.xunits == '' or self.xunits == ' ':
51-
self.xunits = self.connection.get('units(dim_of(_s,1))').data()
44+
self.connection.openTree(fstree, shot)
45+
self.zdata = self.connection.get('_s = ' + tag).data()
46+
self.zunits = self.connection.get('units_of(_s)').data()
47+
self.rank = numpy.ndim(self.zdata)
48+
if self.rank > 1:
49+
self.xdata = self.connection.get('dim_of(_s,1)').data()
50+
self.xunits = self.connection.get(
51+
'units_of(dim_of(_s,1))').data()
52+
if self.xunits == '' or self.xunits == ' ':
53+
self.xunits = self.connection.get(
54+
'units(dim_of(_s,1))').data()
5255

53-
self.ydata = self.connection.get('dim_of(_s)').data()
54-
self.yunits = self.connection.get('units_of(dim_of(_s))').data()
55-
if self.yunits == '' or self.yunits == ' ':
56-
self.yunits = self.connection.get('units(dim_of(_s))').data()
57-
else:
58-
self.xdata = self.connection.get('dim_of(_s)').data()
59-
self.xunits = self.connection.get('units_of(dim_of(_s))').data()
60-
if self.xunits == '' or self.xunits == ' ':
61-
self.xunits = self.connection.get('units(dim_of(_s))').data()
62-
#print 'zdata: ' + str(self.zdata)
63-
self.found = True
56+
self.ydata = self.connection.get('dim_of(_s)').data()
57+
self.yunits = self.connection.get(
58+
'units_of(dim_of(_s))').data()
59+
if self.yunits == '' or self.yunits == ' ':
60+
self.yunits = self.connection.get(
61+
'units(dim_of(_s))').data()
62+
else:
63+
self.xdata = self.connection.get('dim_of(_s)').data()
64+
self.xunits = self.connection.get(
65+
'units_of(dim_of(_s))').data()
66+
if self.xunits == '' or self.xunits == ' ':
67+
self.xunits = self.connection.get(
68+
'units(dim_of(_s))').data()
69+
# print('zdata: ' + str(self.zdata))
70+
self.found = True
6471

65-
# MDSplus seems to return 2-D arrays transposed. Change them back.
66-
if numpy.ndim(self.zdata) == 2: self.zdata = numpy.transpose(self.zdata)
67-
if numpy.ndim(self.ydata) == 2: self.ydata = numpy.transpose(self.ydata)
68-
if numpy.ndim(self.xdata) == 2: self.xdata = numpy.transpose(self.xdata)
72+
# MDSplus seems to return 2-D arrays transposed. Change them
73+
# back.
74+
if numpy.ndim(self.zdata) == 2:
75+
self.zdata = numpy.transpose(self.zdata)
76+
if numpy.ndim(self.ydata) == 2:
77+
self.ydata = numpy.transpose(self.ydata)
78+
if numpy.ndim(self.xdata) == 2:
79+
self.xdata = numpy.transpose(self.xdata)
6980

70-
except Exception as e:
71-
pass
81+
except Exception as e:
82+
print(e)
83+
pass
7284

73-
# Retrieve data from PTDATA if node not found
74-
if not self.found:
75-
#print 'Trying ptdata: %s' % (signal,)
76-
self.zdata = self.connection.get('_s = ptdata2("'+signal+'",'+str(shot)+')')
77-
if len(self.zdata) != 1:
78-
self.xdata = self.connection.get('dim_of(_s)')
79-
self.rank = 1
80-
self.found = True
85+
# Retrieve data from PTDATA if node not found
86+
if not self.found:
87+
# print('Trying ptdata: %s' % (signal,))
88+
self.zdata = self.connection.get(
89+
'_s = ptdata2("' + signal+'",' + str(shot)+')')
90+
if len(self.zdata) != 1:
91+
self.xdata = self.connection.get('dim_of(_s)')
92+
self.rank = 1
93+
self.found = True
8194

82-
# Retrieve data from Pseudo-pointname if not in ptdata
83-
if not self.found:
84-
#print ' Signal not in PTDATA: %s' % (signal,)
85-
self.zdata = self.connection.get('_s = pseudo("'+signal+'",'+str(shot)+')')
86-
if len(self.zdata) != 1:
87-
self.xdata = self.connection.get('dim_of(_s)')
88-
self.rank = 1
89-
self.found = True
95+
# Retrieve data from Pseudo-pointname if not in ptdata
96+
if not self.found:
97+
# print(' Signal not in PTDATA: %s' % (signal,))
98+
self.zdata = self.connection.get(
99+
'_s = pseudo("' + signal+'",' + str(shot)+')')
100+
if len(self.zdata) != 1:
101+
self.xdata = self.connection.get('dim_of(_s)')
102+
self.rank = 1
103+
self.found = True
90104

91-
if not self.found: #this means the signal wasn't found
92-
pass
105+
if not self.found: # this means the signal wasn't found
106+
pass
93107

94-
return
108+
return

data/get_mdsplus_data.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
from plasma.utils.downloading import download_all_shot_numbers
2-
from data.signals import *
32
from plasma.conf import conf
43

54

6-
prepath = '/p/datad2/' #'/cscratch/share/frnn/'#'/p/datad2/'
5+
prepath = '/p/datad2/' # '/cscratch/share/frnn/'
76
shot_numbers_path = 'shot_lists/'
87
save_path = 'signal_data_new/'
9-
machine = conf['paths']['all_machines'][0]# d3d#jet#d3d #should match with data set from conf.yaml
10-
signals = conf['paths']['all_signals']#all_signals#jet_signals#d3d_signals
8+
# d3d, jet # should match with data set from conf.yaml
9+
machine = conf['paths']['all_machines'][0]
10+
signals = conf['paths']['all_signals'] # jet_signals, d3d_signals
1111
print('using signals: ')
1212
print(signals)
1313

1414
# shot_list_files = plasma.conf.jet_full
15-
#shot_list_files = plasma.conf.d3d_full
16-
shot_list_files = conf['paths']['shot_files'][0]#plasma.conf.d3d_100
17-
18-
download_all_shot_numbers(prepath,save_path,shot_list_files,signals)
15+
# shot_list_files = plasma.conf.d3d_full
16+
shot_list_files = conf['paths']['shot_files'][0] # plasma.conf.d3d_100
1917

18+
download_all_shot_numbers(prepath, save_path, shot_list_files, signals)

0 commit comments

Comments
 (0)