Example #1
0
 def run(self, in_data):
     sub_wedge_merge = []
     fast_characterisation = {}
     force_zero_rotation_axis_start = False
     if "fastCharacterisation" in in_data:
         fast_characterisation = in_data["fastCharacterisation"]
         force_zero_rotation_axis_start = fast_characterisation.get(
             "forceZeroRotationAxisStart", False)
         is_fast_characterisation = True
         list_subwedge_angles = fast_characterisation["listSubWedgeAngles"]
         no_images_in_subwedge = fast_characterisation["noImagesInSubWedge"]
         first_image_path = fast_characterisation["firstImagePath"]
         image_number = 1
         template = first_image_path.replace("0001", "{0:04d}")
         list_image_path = []
         for subwedge_angle in list_subwedge_angles:
             for sub_wedge_image_number in range(no_images_in_subwedge):
                 image_path = template.format(image_number)
                 list_image_path.append(image_path)
                 image_number += 1
     elif "imagePath" in in_data:
         list_image_path = in_data["imagePath"]
         is_fast_characterisation = False
         list_subwedge_angles = None
         no_images_in_subwedge = None
     else:
         raise RuntimeError(
             "Neither 'imagePath' nor 'fastCharacterisation' in input data."
         )
     sub_wedge_number = 1
     input_read_image_header = {"imagePath": list_image_path}
     read_image_header = ReadImageHeader(inData=input_read_image_header)
     read_image_header.execute()
     if read_image_header.isSuccess():
         list_subwedge = read_image_header.outData["subWedge"]
         global_axis_start = None
         if force_zero_rotation_axis_start:
             for subwedge in list_subwedge:
                 axis_start = subwedge["experimentalCondition"][
                     "goniostat"]["rotationAxisStart"]
                 if global_axis_start is None or global_axis_start > axis_start:
                     global_axis_start = axis_start
         for index_subwedge, subwedge in enumerate(list_subwedge):
             if is_fast_characterisation:
                 # Modify the start angle
                 index_angle = int(index_subwedge / no_images_in_subwedge)
                 angle_subwedge = list_subwedge_angles[index_angle]
                 goniostat = subwedge["experimentalCondition"]["goniostat"]
                 if force_zero_rotation_axis_start:
                     goniostat["rotationAxisStart"] -= global_axis_start
                 goniostat["rotationAxisStart"] = (
                     goniostat["rotationAxisStart"] + angle_subwedge) % 360
                 goniostat["rotationAxisEnd"] = (
                     goniostat["rotationAxisEnd"] + angle_subwedge) % 360
             else:
                 subwedge["subWedgeNumber"] = index_subwedge + 1
         sub_wedge_merge = UtilsSubWedge.subWedgeMerge(list_subwedge)
     out_data = {"subWedge": sub_wedge_merge}
     return out_data
 def test_execute_ReadImageHeader_eiger4m(self):
     referenceDataPath = self.dataPath / 'ReadImageHeader_Eiger4M.json'
     inData = UtilsTest.loadAndSubstitueTestData(referenceDataPath)
     readImageHeader = ReadImageHeader(inData=inData)
     readImageHeader.execute()
     self.assertTrue(readImageHeader.isSuccess())
     outData = readImageHeader.outData
     self.assertIsNotNone(outData)
Example #3
0
 def run(self, inData):
     outData = {}
     hdf5File = pathlib.Path(inData['hdf5File'])
     # Read the header
     inDataReadImageHeader = {
         "imagePath": [inData['hdf5File']],
         "isFastMesh": False
     }
     readImageHeader = ReadImageHeader(inData=inDataReadImageHeader)
     readImageHeader.execute()
     if readImageHeader.isSuccess():
         firstSubWedge = readImageHeader.outData["subWedge"][0]
         experimentalCondition = firstSubWedge["experimentalCondition"]
         detector = experimentalCondition["detector"]
         beam = experimentalCondition["beam"]
         goniostat = experimentalCondition["goniostat"]
         beamX = detector["beamPositionX"] / 2.0 / detector["pixelSizeX"]
         beamY = detector["beamPositionY"] / 2.0 / detector["pixelSizeY"]
         directory = hdf5File.parent
         prefix = UtilsImage.getPrefix(hdf5File)
         hdf5ImageNumber = 1
         if 'master' in str(hdf5File):
             masterFile = hdf5File
         else:
             if UtilsConfig.isEMBL():
                 fileName = '{0}_master.h5'.format(prefix)
             else:
                 fileName = '{0}_{1}_master.h5'.format(
                     prefix, hdf5ImageNumber)
             masterFile = directory / fileName
         image = fabio.open(str(masterFile))
         image.data = image.data.reshape(2181, 2, 2074, 2).sum(3).sum(1)
         cbfImage = image.convert("cbf")
         pilatus_headers = fabio.cbfimage.PilatusHeader(
             "Silicon sensor, thickness 0.000750 m")
         pilatus_headers["Start_angle"] = goniostat["rotationAxisStart"]
         pilatus_headers["Angle_increment"] = goniostat["oscillationWidth"]
         pilatus_headers["Detector"] = "Eiger2 16M binned to 4M"
         pilatus_headers["Pixel_size"] = (detector["pixelSizeY"] * 2,
                                          detector["pixelSizeX"] * 2)
         pilatus_headers["Exposure_time"] = beam["exposureTime"]
         pilatus_headers["Wavelength"] = beam["wavelength"]
         pilatus_headers[
             "Detector_distance"] = detector["distance"] / 1000.0
         pilatus_headers["Beam_xy"] = (beamY, beamX)
         pilatus_headers["Count_cutoff"] = 1009869
         cbfImage.pilatus_headers = pilatus_headers
         directory = inData.get("forcedOutputDirectory",
                                str(self.getWorkingDirectory()))
         cbfImagePath = os.path.join(
             directory,
             os.path.basename(inData['hdf5File']).replace(".h5", ".cbf"))
         cbfImage.save(cbfImagePath)
         outData["outputCBFFile"] = cbfImagePath
     return outData
 def test_executeReadImageHeaderTaskk(self):
     referenceDataPath = self.dataPath / 'ControlReadImageHeader.json'
     inData = UtilsTest.loadAndSubstitueTestData(referenceDataPath)
     readImageHeader = ReadImageHeader(inData=inData)
     readImageHeader.execute()
     self.assertTrue(readImageHeader.isSuccess())
Example #5
0
 def test_executeReadImageHeaderTask_id23eh1_1(self):
     referenceDataPath = self.dataPath / "id23eh1_1.json"
     inData = UtilsTest.loadAndSubstitueTestData(referenceDataPath)
     readImageHeader = ReadImageHeader(inData=inData)
     readImageHeader.execute()
     self.assertTrue(readImageHeader.isSuccess())