Skip to content

Commit 8e1a783

Browse files
committed
fix for new variable names
1 parent 38c1607 commit 8e1a783

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

xgc_reader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ class databfm(object):
343343
def __init__(self):
344344
with adios2.open("xgc.bfieldm.bp","rra") as self.f:
345345
self.vars=self.f.available_variables()
346-
if(hasattr(self.vars,'rmajor' )):
346+
if('rmajor' in self.vars):
347347
v='rmajor'
348348
else:
349349
v='/bfield/rvec'
350350
ct=self.vars[v].get("Shape")
351351
c=int(ct)
352352
self.rmid=self.f.read(v,start=[0],count=[c],step_start=0, step_count=1)
353-
if(hasattr(self.vars,'psi_n')):
353+
if('psi_n' in self.vars):
354354
v='psi_n'
355355
else:
356356
v='/bfield/psi_eq_x_psi'

xgc_utils.py

+18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ def load_prf(filename):
1010
var = var[0:-1]
1111
return(psi,var)
1212

13+
def load_prf2(filename):
14+
with open(filename, 'r') as file:
15+
#read dimensions
16+
[n] = map(int, file.readline().strip().split())
17+
#allocate array
18+
psi=np.zeros(n)
19+
var=np.zeros(n)
20+
21+
for l in range(n):
22+
[psi[l], var[l]]=map(float, file.readline().strip().split() )
23+
24+
#read end flag
25+
[end_flag]=map(int, file.readline().strip().split())
26+
if(end_flag!=-1):
27+
print('Error: end flag is not -1. end_flag= %d'%end_flag)
28+
return(psi,var)
29+
30+
1331
def save_prf(x, y, fname):
1432
with open(fname, "w") as f:
1533
sz=np.size(x)

0 commit comments

Comments
 (0)