Skip to content

Commit

Permalink
give shape with we cannot find in the sparse file (goldBall data)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Wright committed Oct 15, 2024
1 parent 846f267 commit 824c98c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ImageD11/sinograms/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def import_all(self, scans=None, shape=None):
except:
logging.info("nnz not available. Segmentation done?")

def import_from_sparse(self, hname, scans=None):
def import_from_sparse(self, hname, scans=None, shape=None):
"""
hname = hdf5 file containing sparse pixels (and motors)
dataset = a dataset instance to import into
Expand All @@ -258,12 +258,26 @@ def import_from_sparse(self, hname, scans=None):
scans = list(hin["/"])
order = np.argsort([float(v) for v in scans if v.endswith(".1")])
self.scans = [scans[i] for i in order]
else:
self.scans = scans
self.masterfile = hname # hacky, motors come from the sparsefile
self.import_nnz_from_sparse() # must exist
self.import_motors_from_master()
self.shape = self.nnz.shape
# self.guess_shape() # fails with sparse
if shape is not None:
self.shape = shape
self.nnz = np.array(self.nnz).reshape(self.shape)
else:
self.shape = self.nnz.shape
self.omega = np.array(self.omega).reshape(self.shape)
self.dty = np.array(self.dty).reshape(self.shape)
if len(scans) == 1 and self.shape[0]>1:
file_nums = np.arange(self.shape[0]*self.shape[1]).reshape(self.shape)
self.scans = [
"%s::[%d:%d]" % (self.scans[0], row[0], row[-1] + 1)
for row in file_nums
]

self.guessbins()

def import_scans(self, scans=None, hname=None):
Expand Down

0 comments on commit 824c98c

Please sign in to comment.