Skip to content

Commit

Permalink
Update for TdlpackIO
Browse files Browse the repository at this point in the history
Added dates and leadtimes variables to the open class.  Once the file is indexed, we then create a unique tuples of reference dates and lead times.
  • Loading branch information
eengl committed Apr 9, 2020
1 parent c927be4 commit 541ddc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TdlpackIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _get_index(self):
self._index['size'].append(temp[1])
self._index['type'].append('data')
self._index['date'].append(temp[6])
self._index['lead'].append(int(temp[9]-((temp[9]/1000)*1000)))
self._index['lead'].append(int(str(temp[9])[-3:]))
self._index['id1'].append(temp[7])
self._index['id2'].append(temp[8])
self._index['id3'].append(temp[9])
Expand Down Expand Up @@ -176,6 +176,8 @@ def _get_index(self):
break

self._hasindex = True
self.dates = tuple(sorted(set(self._index['date'])))
self.leadtimes = tuple(sorted(set(self._index['lead'])))

def close(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions test/test_tdlpackio_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# Open vector TDLPACK file; iterate; close
# ----------------------------------------------------------------------------------------
f = TdlpackIO.open("sampledata/hre201701.sq")
print(f.dates)
print(f.leadtimes)
f.seek(0)
for rec in f:
print(f.recordnumber,type(rec),rec.id)
Expand All @@ -31,6 +33,8 @@
# Open gridded TDLPACK file; iterate; close
# ----------------------------------------------------------------------------------------
f = TdlpackIO.open("sampledata/gfspkd47.2017020100.sq")
print(f.dates)
print(f.leadtimes)
f.seek(0)
for rec in f:
print(f.recordnumber,type(rec),rec.id)
Expand Down

0 comments on commit 541ddc4

Please sign in to comment.