Skip to content

Commit

Permalink
Merge pull request #53 from decarlof/master
Browse files Browse the repository at this point in the history
minor changes affecting APS 1-ID, 2-BM and 32-ID readers
  • Loading branch information
decarlof committed Jun 27, 2017
2 parents 6c57a72 + 6e79fbf commit d93f2f5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dxchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def read_aps_1id(fname, ind_tomo=None, proj=None, sino=None):
# File definitions.
fname = os.path.abspath(fname)
_fname = fname + '000001.tif'
log_file = os.path.dirname(fname) + os.path.sep + 'TomoStillScan.dat'
log_file = fname + 'TomoStillScan.dat'

# Read APS 1-ID log file data
contents = open(log_file, 'r')
Expand Down Expand Up @@ -707,7 +707,8 @@ def read_aps_32id(fname, exchange_rank=0, proj=None, sino=None, dtype=None):
theta = dxreader.read_hdf5(fname, theta_grp, slc=None)

if (theta is None):
theta = np.linspace(0. , np.pi, tomo.shape[0])
theta_size = dxreader.read_dx_dims(fname, 'data')[0]
theta = np.linspace(0. , np.pi, theta_size)
else:
theta = theta * np.pi / 180.
return tomo, flat, dark, theta
Expand Down
27 changes: 27 additions & 0 deletions dxchange/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,33 @@ def read_edf(fname, slc=None):
return arr


def read_dx_dims(fname, dataset):
"""
Read array size of a specific group of Data Exchange file.
Parameters
----------
fname : str
String defining the path of file or file name.
dataset : str
Path to the dataset inside hdf5 file where data is located.
Returns
-------
ndarray
Data set size.
"""

grp = '/'.join(['exchange', dataset])

with h5py.File(fname, "r") as f:
try:
data = f[grp]
except KeyError:
return None

shape = data.shape

return shape

def read_hdf5(fname, dataset, slc=None, dtype=None, shared=False):
"""
Read data from hdf5 file from a specific group.
Expand Down

0 comments on commit d93f2f5

Please sign in to comment.