Skip to content

Commit cdb620c

Browse files
committed
Legacy parser: remove magic < 9 logic
1 parent 8960877 commit cdb620c

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

stagpy/stagyyparsers.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,52 +370,46 @@ def fields(fieldfile, only_header=False, only_istep=False):
370370

371371
magic %= 100
372372
if magic < 9:
373-
# the rest of the parser still check lower values in case this
374-
# constraint is alleviated
375373
raise ParsingError(fieldfile, 'magic < 9 not supported')
376374

377375
# extra ghost point in horizontal direction
378-
header['xyp'] = int(magic >= 9 and nval == 4)
376+
header['xyp'] = int(nval == 4) # magic >= 9
379377

380378
# total number of values in relevant space basis
381379
# (e1, e2, e3) = (theta, phi, radius) in spherical geometry
382380
# = (x, y, z) in cartesian geometry
383381
header['nts'] = readbin(nwords=3)
384382

385383
# number of blocks, 2 for yinyang or cubed sphere
386-
header['ntb'] = readbin() if magic >= 7 else 1
384+
header['ntb'] = readbin() # magic >= 7
387385

388386
# aspect ratio
389387
header['aspect'] = readbin('f', 2)
390388

391389
# number of parallel subdomains
392390
header['ncs'] = readbin(nwords=3) # (e1, e2, e3) space
393-
header['ncb'] = readbin() if magic >= 8 else 1 # blocks
391+
header['ncb'] = readbin() # magic >= 8, blocks
394392

395393
# r - coordinates
396394
# rgeom[0:self.nrtot+1, 0] are edge radial position
397395
# rgeom[0:self.nrtot, 1] are cell-center radial position
398-
if magic >= 2:
399-
header['rgeom'] = readbin('f', header['nts'][2] * 2 + 1)
400-
else:
401-
header['rgeom'] = np.array(range(0, header['nts'][2] * 2 + 1))\
402-
* 0.5 / header['nts'][2]
396+
header['rgeom'] = readbin('f', header['nts'][2] * 2 + 1) # magic >= 2
403397
header['rgeom'] = np.resize(header['rgeom'], (header['nts'][2] + 1, 2))
404398

405-
header['rcmb'] = readbin('f') if magic >= 7 else None
399+
header['rcmb'] = readbin('f') # magic >= 7
406400

407-
header['ti_step'] = readbin() if magic >= 3 else 0
401+
header['ti_step'] = readbin() # magic >= 3
408402
if only_istep:
409403
return header['ti_step']
410-
header['ti_ad'] = readbin('f') if magic >= 3 else 0
411-
header['erupta_total'] = readbin('f') if magic >= 5 else 0
412-
header['bot_temp'] = readbin('f') if magic >= 6 else 1
404+
header['ti_ad'] = readbin('f') # magic >= 3
405+
header['erupta_total'] = readbin('f') # magic >= 5
406+
header['bot_temp'] = readbin('f') # magic >= 6
413407
header['core_temp'] = readbin('f') if magic >= 10 else 1
414408

415-
if magic >= 4:
416-
header['e1_coord'] = readbin('f', header['nts'][0])
417-
header['e2_coord'] = readbin('f', header['nts'][1])
418-
header['e3_coord'] = readbin('f', header['nts'][2])
409+
# magic >= 4
410+
header['e1_coord'] = readbin('f', header['nts'][0])
411+
header['e2_coord'] = readbin('f', header['nts'][1])
412+
header['e3_coord'] = readbin('f', header['nts'][2])
419413

420414
if only_header:
421415
return header

0 commit comments

Comments
 (0)