def __init__(self, image_file, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) FormatHDF5.__init__(self, image_file, **kwargs)
def __init__(self, image_file, index=0, reconst_mode=False, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) self._raw_data = None self.index = index self.image_filename = image_file FormatHDF5.__init__(self, image_file, **kwargs) self.PIXEL_SIZE = 78.2 / 1000 # um self.RECONST_SIZE = 3840 # This hard-coded value can be overwritten # by RAYONIX_DISTANCE self.distance = 240.0 # mm self.mask = None # Read metadata if possible self.read_metadata() # Override by environmental variables import os if "RAYONIX_DISTANCE" in os.environ: self.distance = float(os.environ["RAYONIX_DISTANCE"])
def __init__(self, image_file, index=0, reconst_mode=False, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) self._raw_data = None self.index = index self.image_filename = image_file FormatHDF5.__init__(self, image_file, **kwargs) # This hard-coded value can be overwritten # by RAYONIX_DISTANCE self.distance = 240.0 # mm self.mask = None # Read metadata if possible # Read pixel size from the metadata and determine the binning of rayonix self.read_metadata() self.PIXEL_SIZE = self.pixelsize_in_um / 1000 # convert um to mm self.bin_size = int(self.pixelsize_in_um / 39.1) self.RECONST_SIZE = 7680 // self.bin_size # Override by environmental variables if os.getenv("RAYONIX_DISTANCE"): self.distance = float(os.environ["RAYONIX_DISTANCE"])
def __init__(self, image_file, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) FormatHDF5.__init__(self, image_file, **kwargs) self._h5_handle = h5py.File(self.get_image_file(), 'r') self._geometry_define()
def __init__(self, image_file, index=0, reconst_mode=False, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) self._raw_data = None self.index = index self.image_filename = image_file FormatHDF5.__init__(self, image_file, **kwargs) self.PIXEL_SIZE = 50 / 1000 # 50 um self.RECONST_SIZE = 2398 # compatible with DataConvert3 -reconst mode # These hard-coded values can be overwritten # by MPCCD_GEOMETRY and MPCCD_DISTANCE # # These values can be retrieved from SACLA API. # Alternatively, you can get it from a CrystFEL geometry file by # awk '/corner_x/{x=50*$3} /corner_y/{y=50*$3; printf x","y","rot","} # /\/ss/{rot=-atan2($3, $4)/3.141592*180}' input.geom self.distance = 50.0 # mm self.panel_origins = [(-1755.000000, 51711.000000, 0.000000), (-1711.000000, 24944.000000, 0.000000), (817.000000, -1808.000000, 0.000000), (812.000000, -28466.000000, 0.000000), (-792.000000, 28544.000000, 0.000000), (-781.000000, 1840.000000, 0.000000), (1650.000000, -24900.000000, 0.000000), (1655.000000, -51626.000000, 0.000000)] # um self.panel_rotations = [ -89.906197, -89.915802, -89.980003, -89.929298, 89.963097, 89.880798, 90.000000, 90.029503 ] import os if 'MPCCD_RECONST_MODE' in os.environ: reconst_mode = bool(os.environ['MPCCD_RECONST_MODE']) self.RECONST_MODE = reconst_mode self.RECONST_64 = True # Set False if you want to keep panels completely horizontal # But this makes errors bigger. if 'MPCCD_GEOMETRY' in os.environ: try: tmp = map(float, os.environ['MPCCD_GEOMETRY'].split(",")) if len(tmp) != 24: raise for i in range(8): self.panel_origins[i] = (-tmp[i * 3], tmp[i * 3 + 1], 0) self.panel_rotations[i] = tmp[i * 3 + 2] except Exception: raise "Invalid MPCCD Geomtry" if 'MPCCD_DISTANCE' in os.environ: self.distance = float(os.environ['MPCCD_DISTANCE'])
def __init__(self, image_file, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) FormatHDF5.__init__(self, image_file, **kwargs) #def _start(self): self._h5_handle = h5py.File(self.get_image_file(), 'r') self._decide_multi_panel() self.load_dark() self.load_gain() self.load_mask() self.load_xyz() self._geometry_define() self._assembler_define()
def understand(image_file): try: tag = FormatHDF5.open_file(image_file, 'rb').read(8) except IOError: return False # check that this is a HDF5 file (should not have got here if not # anyway...) if tag != "\211HDF\r\n\032\n": return False import h5py h5_handle = h5py.File(image_file, 'r') try: desc = h5_handle['entry/instrument/detector/description'] except KeyError: h5_handle.close() return False if 'Lambda' in desc.value[0]: h5_handle.close() return True return False
def __init__(self, image_file): assert(self.understand(image_file)) FormatHDF5.__init__(self, image_file) self._raw_data = None self.pixel_size = 50 / 1000 # 50 um self.RECONST_SIZE = 2398 # compatible with DataConvert3 -reconst mode self.RECONST_MODE = True self.RECONST_64 = True self.distance = 52.0 # mm # TODO: These should be read from geometry file. self.panel_origins = [(-1755.000000, 51711.000000, 0.000000), (-1711.000000, 24944.000000, 0.000000), (817.000000, -1808.000000, 0.000000), (812.000000, -28466.000000, 0.000000), (-792.000000, 28544.000000, 0.000000), (-781.000000, 1840.000000, 0.000000), (1650.000000, -24900.000000, 0.000000), (1655.000000, -51626.000000, 0.000000)] # um self.panel_rotations = [-89.906197, -89.915802, -89.980003, -89.929298, 89.963097, 89.880798, 90.000000, 90.029503]
def understand(image_file): try: tag = FormatHDF5.open_file(image_file, "rb").read(8) except IOError: return False # check that this is a HDF5 file (should not have got here if not # anyway...) if tag != "\211HDF\r\n\032\n": return False with h5py.File(image_file, "r") as h5_handle: try: desc = h5_handle["entry/instrument/detector/description"] except KeyError: return False if "Lambda" in desc[()][0]: return True return False
def __init__(self, image_file, **kwargs): assert (self.understand(image_file)) FormatHDF5.__init__(self, image_file, **kwargs)
def understand(image_file): try: tag = FormatHDF5.open_file(image_file, 'rb').read(8) except IOError, e: return False
def __init__(self, image_file, **kwargs): assert(self.understand(image_file)) FormatHDF5.__init__(self, image_file, **kwargs)
def __init__(self, image_file, index=0, reconst_mode=False, **kwargs): from dxtbx import IncorrectFormatError if not self.understand(image_file): raise IncorrectFormatError(self, image_file) self._raw_data = None self.index = index self.image_filename = image_file FormatHDF5.__init__(self, image_file, **kwargs) self.PIXEL_SIZE = 50 / 1000 # 50 um self.RECONST_SIZE = 2398 # compatible with DataConvert3 -reconst mode # These hard-coded values can be overwritten # by MPCCD_GEOMETRY and MPCCD_DISTANCE # # These values can be retrieved from SACLA API. # Alternatively, you can get it from a CrystFEL geometry file by # awk '/corner_x/{x=50*$3} /corner_y/{y=50*$3; printf x","y","rot","} # /\/ss/{rot=-atan2($3, $4)/3.141592*180}' input.geom # Default value for Phase I MPCCD self.distance = 50.0 # mm self.panel_origins = [ (-1755.000000, 51711.000000, 0.000000), (-1711.000000, 24944.000000, 0.000000), (817.000000, -1808.000000, 0.000000), (812.000000, -28466.000000, 0.000000), (-792.000000, 28544.000000, 0.000000), (-781.000000, 1840.000000, 0.000000), (1650.000000, -24900.000000, 0.000000), (1655.000000, -51626.000000, 0.000000), ] # um self.panel_rotations = [ -89.906197, -89.915802, -89.980003, -89.929298, 89.963097, 89.880798, 90.000000, 90.029503, ] self.thickness = 0.050 self.mask = None # Read metadata if possible self.read_metadata() # Override by environmental variables if "MPCCD_RECONST_MODE" in os.environ: reconst_mode = bool(os.environ["MPCCD_RECONST_MODE"]) self.RECONST_MODE = reconst_mode self.RECONST_64 = ( True) # Set False if you want to keep panels completely horizontal # But this makes errors bigger. if "MPCCD_GEOMETRY" in os.environ: try: tmp = [ float(i) for i in os.environ["MPCCD_GEOMETRY"].split(",") ] if len(tmp) != 24: raise EnvironmentError( "Environment variable MPCCD_GEOMETRY must contain 24 comma-separated parts" ) for i in range(8): self.panel_origins[i] = (-tmp[i * 3], tmp[i * 3 + 1], 0) self.panel_rotations[i] = tmp[i * 3 + 2] except Exception as e: raise EnvironmentError( "Invalid MPCCD Geometry specified in environment variable MPCCD_GEOMETRY: {}" .format(e)) if "MPCCD_DISTANCE" in os.environ: self.distance = float(os.environ["MPCCD_DISTANCE"])