Skip to content

Commit

Permalink
feat: allow progress tracking for SeriesData.saveh5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Mar 4, 2019
1 parent 2c1e08a commit c958262
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.8.0
- feat: allow tracking the progress of SeriesData.saveh5 using
multiprocessing.Value objects
0.7.1
- docs: fix missing changelog files
0.7.0
Expand Down
19 changes: 17 additions & 2 deletions qpformat/file_formats/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,21 @@ def get_qpimage_raw(self, idx):
the "identifier" metadata key set!
"""

def saveh5(self, h5file):
"""Save the data set as an hdf5 file (qpimage.QPSeries format)"""
def saveh5(self, h5file, count=None, max_count=None):
"""Save the data set as an hdf5 file (qpimage.QPSeries format)
Parameters
----------
h5file: str, pathlib.Path, or h5py.Group
Where to store the series data
count, max_count: multiprocessing.Value
Can be used to monitor the progress of the algorithm.
Initially, the value of `max_count.value` is incremented
by the total number of steps. At each step, the value
of `count.value` is incremented.
"""
if max_count is not None:
max_count.value += len(self)
with qpimage.QPSeries(h5file=h5file,
h5mode="w",
identifier=self.identifier) as qps:
Expand All @@ -222,6 +235,8 @@ def saveh5(self, h5file):
# hard-link the background data
qpiraw = self.get_qpimage_raw(ii)
qps.add_qpimage(qpiraw, bg_from_idx=0)
if count is not None:
count.value += 1

def set_bg(self, dataset):
"""Set background data
Expand Down

0 comments on commit c958262

Please sign in to comment.