[yt-svn] commit/yt: MatthewTurk: Reduce the number of seeks in boxlib IO
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Jan 16 09:45:59 PST 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/d8069e2f9549/
Changeset: d8069e2f9549
Branch: yt
User: MatthewTurk
Date: 2015-01-16 01:15:28+00:00
Summary: Reduce the number of seeks in boxlib IO
Affected #: 2 files
diff -r ec8644a41a0e2bc389e63fe2559bc665473ef939 -r d8069e2f9549757aacb8cedeb6c620d8e22a4825 yt/frontends/boxlib/data_structures.py
--- a/yt/frontends/boxlib/data_structures.py
+++ b/yt/frontends/boxlib/data_structures.py
@@ -98,15 +98,14 @@
return [self.index.grids[cid - self._id_offset]
for cid in self._children_ids]
- def _seek(self, f):
+ def _get_offset(self, f):
# This will either seek to the _offset or figure out the correct
# _offset.
if self._offset == -1:
f.seek(self._base_offset, os.SEEK_SET)
f.readline()
self._offset = f.tell()
- else:
- f.seek(self._offset)
+ return self._offset
# We override here because we can have varying refinement levels
def select_ires(self, dobj):
diff -r ec8644a41a0e2bc389e63fe2559bc665473ef939 -r d8069e2f9549757aacb8cedeb6c620d8e22a4825 yt/frontends/boxlib/io.py
--- a/yt/frontends/boxlib/io.py
+++ b/yt/frontends/boxlib/io.py
@@ -66,17 +66,19 @@
f = open(filename, "rb")
for grid in grids:
data[grid.id] = {}
- grid._seek(f)
+ local_offset = grid._get_offset(f) - f.tell()
count = grid.ActiveDimensions.prod()
size = count * bpr
for field in self.ds.index.field_order:
if field in fields:
# We read it ...
+ f.seek(local_offset, os.SEEK_CUR)
v = np.fromfile(f, dtype=dtype, count=count)
v = v.reshape(grid.ActiveDimensions, order='F')
data[grid.id][field] = v
+ local_offset = 0
else:
- f.seek(size, os.SEEK_CUR)
+ local_offset += size
return data
class IOHandlerOrion(IOHandlerBoxlib):
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list