Skip to content

Commit 7b2d8b6

Browse files
author
Julian Kates-Harbeck
committed
small bug fix with checking for no-content
1 parent ca3a88c commit 7b2d8b6

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

data/signals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def fetch_nstx_data(signal_path,shot_num,c):
214214
'torquein':torquein,
215215
'energydt':energydt,'ipdirect':ipdirect,'iptarget':iptarget,'iperr':iperr,
216216
'tmamp1':tmamp1,'tmamp2':tmamp2,'tmfreq1':tmfreq1,'tmfreq2':tmfreq2,'pechin':pechin,
217-
'rho_profile_spatial':rho_profile_spatial,'etemp':etemp,
217+
# 'rho_profile_spatial':rho_profile_spatial,'etemp':etemp,
218218
'etemp_profile':etemp_profile,'edens_profile':edens_profile,
219219
'itemp_profile':itemp_profile,'zdens_profile':zdens_profile,
220220
'trot_profile':trot_profile,'pthm_profile':pthm_profile,

plasma/primitives/data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ def load_data_from_txt_safe(self,prepath,shot,dtype='float32'):
6666
return None,False
6767
try:
6868
data = np.loadtxt(file_path,dtype=dtype)
69-
if data == get_missing_value_array():
69+
if np.all(data == get_missing_value_array()):
7070
print('Signal {}, shot {} contains no data'.format(self.description,shot.number))
7171
return None,False
72-
except:
72+
except Exception as e:
73+
print(e)
7374
print('Couldnt load signal {} shot {}. Removing.'.format(file_path,shot.number))
7475
os.remove(file_path)
7576
return None, False

plasma/primitives/shots.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import numpy as np
1818

1919
from plasma.utils.processing import train_test_split,cut_and_resample_signal
20+
from plasma.utils.downloading import makedirs_process_safe
2021

2122
class ShotListFiles(object):
2223
def __init__(self,machine,prepath,paths,description=''):
@@ -455,14 +456,7 @@ def convert_to_ttd(self,tr,conf):
455456
return ttd
456457

457458
def save(self,prepath):
458-
if not os.path.exists(prepath):
459-
try: #can lead to race condition
460-
os.makedirs(prepath)
461-
except OSError as e:
462-
if e.errno == errno.EEXIST:# File exists, and it's a directory, another process beat us to creating this dir, that's OK.
463-
pass
464-
else:# Our target dir exists as a file, or different error, reraise the error!
465-
raise
459+
makedirs_process_safe(prepath)
466460
save_path = self.get_save_path(prepath)
467461
np.savez(save_path,valid=self.valid,is_disruptive=self.is_disruptive,
468462
signals_dict=self.signals_dict,ttd=self.ttd)

0 commit comments

Comments
 (0)