Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added optional kind parameter to linked list binary reader in order to select the appropriate CTEM data type
  • Loading branch information
daminton committed Jul 19, 2022
1 parent 654054d commit e659999
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/ctem/ctem/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,20 @@ def read_unformatted_binary(filename, gridsize, kind='DP'):
return data


def read_linked_list_binary(filename, gridsize):
def read_linked_list_binary(filename, gridsize, kind='DP'):
if kind == 'DP':
dt = np.dtype('f8')
elif kind == 'SP':
dt = np.dtype('f4')
elif kind == 'I4B':
dt = np.dtype('<i4')
elif kind == 'I8B':
dt = np.dtypye('<i8')
data = np.empty((gridsize,gridsize),dtype="object")
with FortranFile(filename, 'r') as f:
for i in np.arange(gridsize):
for j in np.arange(gridsize):
data[i, j] = f.read_reals(np.float64)
data[i, j] = f.read_reals(dt)
return data


Expand Down

0 comments on commit e659999

Please sign in to comment.