Skip to content
Snippets Groups Projects
Commit 110c5f61 authored by Steffen Hauf's avatar Steffen Hauf
Browse files

Remove unneeded files

parent 86edc57f
No related branches found
No related tags found
1 merge request!32Add FastCCD notebooks
This diff is collapsed.
"""XFEL FCCD Tools
Author: Steffen Hauf <steffen.hauf@xfel.eu>
(c) European X-Ray Free Electron Laser Facility GmbH 2014
This module provides an interface for accessing preliminary LPD data.
Reordering of pixels and inversion is performed through hard-coded look-up tables.
"""
from __future__ import print_function, division, absolute_import
import h5py
import numpy as np
def readData(filename, path='/stream', **kwargs):
""" Reads data from a given file (family) and output reordered images
in stacks
Args:
filename (str): the file path and name. If the file is actually a
family of files only the first file, i.e. the one with index
00000.h5 should be given.
path (str = '/stream', optional): the path in the hdf5 file at which
the data is located.
kwargs: the following additional parameters may be given:
* image_range ([low, high]): a range of images to be read
* x_range ([low, high]): a range of pixels to be read
* y_range ([low, high]): a range of pixels to be read
* pixels_x (int): number of pixels along x-axis, **compatibility only**.
* pixels_y (int): number of pixels along y-axis, **compatibility only**.
Returns:
numpy.array: a reordered and inverted image with rank 2
Note:
This function is compatible with xfelpycaltools.ChunkedReader
"""
imageRange = kwargs.get("image_range", None)
pixelXRange = kwargs.get("x_range", None)
pixelYRange = kwargs.get("y_range", None)
pixelsX = kwargs.get("pixels_x", None)
pixelsY = kwargs.get("pixels_y", None)
f = None
if filename.find("00000") != -1:
filenameFam = filename.replace("00000", "%05d")
f = h5py.File(filenameFam, "r", driver='family',
memb_size=20 * 1024 ** 3) # 20GB chunks
else:
f = h5py.File(filename, "r")
din = None
if imageRange == None:
din = f[path]
else:
din = f[path][imageRange[0]:imageRange[1]]
d = None
if pixelXRange == None and pixelYRange == None:
d = np.array(din[:, :,:])
d = np.rollaxis(d, 0, start=3)
else:
d = np.array(
din[pixelXRange[0]:pixelXRange[1],pixelYRange[0]:pixelYRange[1],:])
d = np.rollaxis(d, 0, start=3)
f.close()
return d.astype(np.float)
def getDataSize(filename, path='/stream'):
""" Returns the number of image in a given file (family)
Args:
filename (str): the file path and name. If the file is actually a
family of files only the first file, i.e. the one with index
00000.h5 should be given.
path (str = '/stream', optional): the path in the hdf5 file at which
the data is located.
"""
f = None
if filename.find("00000") != -1:
filenameFam = filename.replace("00000", "%05d")
# print filenameFam
f = h5py.File(filenameFam, "r", driver='family',
memb_size=20 * 1024 ** 3) # 20GB chunks
else:
f = h5py.File(filename, "r")
return f[path].shape
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment