Skip to content

Commit

Permalink
Merge pull request #39 from stuwilkins/add3d
Browse files Browse the repository at this point in the history
ENH: Added 3d the proper way
  • Loading branch information
stuwilkins committed Mar 2, 2016
2 parents 1857ac4 + 67cddca commit 057b763
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion csxtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_fastccd_images(light_header, dark_headers=None,
# If we want to do something lazy

tt = ttime.time()
b = get_images_to_4D(bgnd_events, dtype=np.uint16)
b = get_images_to_3D(bgnd_events, dtype=np.uint16)
logger.info("Image conversion took %.3f seconds",
ttime.time() - tt)

Expand Down Expand Up @@ -146,6 +146,29 @@ def get_images_to_4D(images, dtype=None):
return im


def get_images_to_3D(images, dtype=None):
"""Convert image stack to 3D numpy array
This function converts an image stack from
:func: get_images() into a 3D numpy ndarray of a given datatype.
This is useful to just get a simple array from detector data
Parameters
----------
images : the result of get_images()
dtype : the datatype to use for the conversion
Example
-------
>>> header = DataBroker[-1]
>>> images = get_images(header, "my_detector')
>>> a = get_images_to_3D(images, dtype=np.float32)
"""
im = np.vstack([np.asarray(im, dtype=dtype) for im in images])
return im


def _get_images(header, tag, roi=None):
t = ttime.time()
images = get_images(header, tag)
Expand Down

0 comments on commit 057b763

Please sign in to comment.