6
6
'''
7
7
from __future__ import print_function
8
8
from MDSplus import *
9
- from pylab import *
9
+ # from pylab import *
10
10
import numpy as np
11
11
import sys
12
12
import multiprocessing as mp
21
21
22
22
#print("Importing numpy version"+np.__version__)
23
23
24
- prepath = '/cscratch/share/frnn'
24
+ prepath = '/cscratch/share/frnn/ '
25
25
shot_numbers_path = 'shot_lists/'
26
26
save_path = 'signal_data/'
27
27
machine = 'd3d'
43
43
# shot_numbers_files = ['shotlist_JaysonBarr_disrupt.txt']
44
44
shot_numbers_files = ['d3d_short_clear.txt' ]# ,'d3d_clear.txt', 'd3d_disrupt.txt']
45
45
server_path = 'atlas.gat.com'
46
- import d3d_signals
46
+ from d3d_signals import signal_paths
47
+ import itertools
48
+ signal_paths = list (itertools .chain .from_iterable (signal_paths ))
47
49
# signal_paths = ['PINJ','IP','Q95','DENSITY','WMHD'] #,'PRAD'] #PRAD returns a 2D xdata
48
50
# Recommended signals from DIII-D
49
51
# signal_paths = ['efsli','ipsip','efsbetan','efswmhd','nssampn1l','nssfrqn1l',
@@ -127,6 +129,14 @@ def get_tree_and_tag(path):
127
129
tag = '\\ ' + spl [1 ]
128
130
return tree ,tag
129
131
132
+ def get_tree_and_tag_no_backslash (path ):
133
+ spl = path .split ('/' )
134
+ tree = spl [0 ]
135
+ tag = spl [1 ]
136
+ return tree ,tag
137
+
138
+
139
+
130
140
131
141
def format_save_path (prepath ,signal_path ,shot_num ):
132
142
return prepath + signal_path + '/{}.txt' .format (shot_num )
@@ -161,8 +171,11 @@ def save_shot(shot_num_queue,c,signal_paths,save_prepath,machine):
161
171
print ('Signal {}, shot {} missing. Filling with zeros' .format (signal_path ,shot_num ))
162
172
time ,data = create_missing_value_filler ()
163
173
elif machine == 'd3d' :
174
+ tree ,tag = get_tree_and_tag_no_backslash (signal_path )
164
175
try :
165
- ga1 = gadata .gadata ('{}' .format (signal_path ),shot_num ,tree = 'd3d' ,connection = c )
176
+ ga1 = gadata .gadata ('{}' .format (tag ),shot_num ,tree = tree ,connection = c )
177
+ if not ga1 .found :
178
+ raise
166
179
# ga1 = gadata.gadata('\\{}'.format(signal_path),shot_num,tree='d3d',connection=c)
167
180
data = ga1 .zdata
168
181
time = ga1 .xdata
@@ -171,7 +184,7 @@ def save_shot(shot_num_queue,c,signal_paths,save_prepath,machine):
171
184
print ('Signal {}, shot {} missing. Filling with zeros' .format (signal_path ,shot_num ))
172
185
time ,data = create_missing_value_filler ()
173
186
174
- data_two_column = vstack ((time , data )).transpose ()
187
+ data_two_column = np . vstack ((np . atleast_2d ( time ), np . atleast_2d ( data ) )).transpose ()
175
188
try : #can lead to race condition
176
189
mkdirdepth (save_path_full )
177
190
except OSError , e :
@@ -181,7 +194,7 @@ def save_shot(shot_num_queue,c,signal_paths,save_prepath,machine):
181
194
else :
182
195
# Our target dir exists as a file, or different error, reraise the error!
183
196
raise
184
- savetxt (save_path_full ,data_two_column ,fmt = '%f %f' )
197
+ np . savetxt (save_path_full ,data_two_column ,fmt = '%.5e' ) # fmt = '%f %f')
185
198
print ('.' ,end = '' )
186
199
except :
187
200
print ('Could not save shot {}, signal {}' .format (shot_num ,signal_path ))
0 commit comments