def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection()
     if xsDataCollection is not None:
         firstSubWedge = xsDataCollection.subWedge[0]
         firstImage = firstSubWedge.image[0]
         if firstImage.date is not None:
             strDate = firstImage.date.value
         else:
             strDate = "-----"
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         dictTable = {"type": "table",
                      "title": "Data collection info",
                      "columns": [],
                      "data": []}
         listRow = []
         dictTable["columns"].append("Data collection date")
         listRow.append(strDate)
         dictTable["columns"].append("Image prefix")
         listRow.append(strPrefix)
         dictTable["columns"].append("Directory")
         listRow.append(strDirName)
         dictTable["data"].append(listRow)
         #
         self.workflowStepReport.addTable("Data collection info",
                                          dictTable["columns"],
                                          dictTable["data"],
                                          orientation="vertical")
 def createPyarchHtmlDirectoryPath(_xsDataCollection):
     """
     This method creates a directory path for pyarch: in the same directory were the 
     images are located a new directory is created with the following convention:
     
       edna_html_prefix_runNumber
     
     """
     # First extract all reference image directory paths and names
     listImageDirectoryPath = []
     listImagePrefix = []
     for xsDataSubWedge in _xsDataCollection.getSubWedge():
         for xsDataImage in xsDataSubWedge.getImage():
             strImagePath = xsDataImage.getPath().getValue()
             listImageDirectoryPath.append(os.path.dirname(strImagePath))
             listImagePrefix.append(EDUtilsImage.getPrefix(strImagePath))
     # TODO: Check that all paths and prefixes are the same
     strImageDirectory = listImageDirectoryPath[0]
     strPrefix = listImagePrefix[0]
     # Remove any "ref-" or "postref-" from the prefix in order to make it fully
     # compatitble with DNA standards:
     if (strPrefix is not None):
         if (strPrefix.startswith("ref-")):
             strPrefix = strPrefix[4:]
         elif (strPrefix.startswith("postref-")):
             strPrefix = strPrefix[8:]
     strHtmlDirectoryPath = os.path.join(strImageDirectory,
                                         "%s_dnafiles" % strPrefix)
     strPyarchHtmlDirectoryPath = EDHandlerESRFPyarchv1_0.createPyarchFilePath(
         strHtmlDirectoryPath)
     return strPyarchHtmlDirectoryPath
Beispiel #3
0
 def createDNAFileDirectoryPath(self, _xsDataResultCharacterisation):
     """
     This method creates a "DNA" style directory path, i.e. in the same directory were the 
     images are located a new directory is created with the following convention:
     
       dnafiles_prefix_runNumber
     
     The path to this directory is returned if the directory was successfully created.
     """
     # First extract all reference image directory paths and names
     xsDataCollection = _xsDataResultCharacterisation.getDataCollection()
     listImageDirectoryPath = []
     listImagePrefix = []
     for xsDataSubWedge in xsDataCollection.getSubWedge():
         for xsDataImage in xsDataSubWedge.getImage():
             strImagePath = xsDataImage.getPath().getValue()
             listImageDirectoryPath.append(os.path.dirname(strImagePath))
             listImagePrefix.append(EDUtilsImage.getPrefix(strImagePath))
     # TODO: Check that all paths and prefixes are the same
     strImageDirectory = listImageDirectoryPath[0]
     strPrefix = listImagePrefix[0]
     # Remove any "ref-" or "postref-" from the prefix in order to make it fully
     # compatitble with DNA standards:
     if (strPrefix is not None):
         if (strPrefix.startswith("ref-")):
             strPrefix = strPrefix[4:]
         elif (strPrefix.startswith("postref-")):
             strPrefix = strPrefix[8:]
     strDNAFileDirectoryPath = os.path.join(strImageDirectory,
                                            "%s_dnafiles" % strPrefix)
     return strDNAFileDirectoryPath
 def createPyarchHtmlDirectoryPath(_xsDataCollection):
     """
     This method creates a directory path for pyarch: in the same directory were the 
     images are located a new directory is created with the following convention:
     
       edna_html_prefix_runNumber
     
     """
     # First extract all reference image directory paths and names
     listImageDirectoryPath = []
     listImagePrefix = []
     for xsDataSubWedge in _xsDataCollection.getSubWedge():
         for xsDataImage in xsDataSubWedge.getImage():
             strImagePath = xsDataImage.getPath().getValue()
             listImageDirectoryPath.append(os.path.dirname(strImagePath))
             listImagePrefix.append(EDUtilsImage.getPrefix(strImagePath))
     # TODO: Check that all paths and prefixes are the same
     strImageDirectory = listImageDirectoryPath[0]
     strPrefix = listImagePrefix[0]
     # Remove any "ref-" or "postref-" from the prefix in order to make it fully
     # compatitble with DNA standards:
     if (strPrefix is not None):
         if (strPrefix.startswith("ref-")):
             strPrefix = strPrefix[4:]
         elif (strPrefix.startswith("postref-")):
             strPrefix = strPrefix[8:]
     strHtmlDirectoryPath = os.path.join(strImageDirectory, "%s_dnafiles" % strPrefix)
     strPyarchHtmlDirectoryPath = EDHandlerESRFPyarchv1_0.createPyarchFilePath(strHtmlDirectoryPath)
     return strPyarchHtmlDirectoryPath
Beispiel #5
0
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection(
     )
     if xsDataCollection is not None:
         self.page.h2("Data collection info")
         firstSubWedge = xsDataCollection.subWedge[0]
         firstImage = firstSubWedge.image[0]
         strDate = None
         if not firstImage.date is None:
             strDate = firstImage.date.value
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         self.page.table(class_='dataCollectionInfo',
                         border_="1",
                         cellpadding_="0")
         self.page.tr(align_="CENTER")
         self.page.th("Data collection date",
                      bgcolor_=self.strTableColourTitle2)
         if not strDate is None:
             self.page.th(strDate, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Image prefix", bgcolor_=self.strTableColourTitle2)
         self.page.th(strPrefix, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Directory", bgcolor_=self.strTableColourTitle2)
         self.page.th(strDirName, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.table.close()
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection()
     if xsDataCollection is not None:
         self.page.h2( "Data collection info" )
         firstSubWedge = xsDataCollection.subWedge[0]
         firstImage = firstSubWedge.image[0]
         strDate = None
         if not firstImage.date is None:
             strDate = firstImage.date.value
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         self.page.table( class_='dataCollectionInfo', border_="1", cellpadding_="0")
         self.page.tr( align_="CENTER")
         self.page.th("Data collection date", bgcolor_=self.strTableColourTitle2)
         if not strDate is None:
             self.page.th(strDate, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Image prefix", bgcolor_=self.strTableColourTitle2)
         self.page.th(strPrefix, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Directory", bgcolor_=self.strTableColourTitle2)
         self.page.th(strDirName, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.table.close()     
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection()
     if xsDataCollection is not None:
         firstSubWedge = xsDataCollection.subWedge[0]
         # MXSUP-1445: Check if transmission is less than 10% and warn if it's the case
         xsDataBeam = firstSubWedge.getExperimentalCondition().getBeam()
         if xsDataBeam.getTransmission() is not None:
             fTransmission = xsDataBeam.getTransmission().getValue()
             if fTransmission < self.fMinTransmission:
                 strWarningMessage1 = "WARNING! Transmission for characterisation set to %.1f %%" % fTransmission
                 strWarningMessage2 = "Please consider re-characterising with transmission set to 100 %" 
                 self.page.font(_color="red", size="+2")
                 self.page.i()
                 self.page.h2(strWarningMessage1+"<br>"+strWarningMessage2)
                 self.page.i.close()
                 self.page.font.close()
         self.page.h2( "Data collection info" )
         firstImage = firstSubWedge.image[0]
         strDate = firstImage.date.value
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         self.page.table( class_='dataCollectionInfo', border_="1", cellpadding_="0")
         self.page.tr( align_="CENTER")
         self.page.th("Data collection date", bgcolor_=self.strTableColourTitle2)
         self.page.th(strDate, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Image prefix", bgcolor_=self.strTableColourTitle2)
         self.page.th(strPrefix, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr( align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Directory", bgcolor_=self.strTableColourTitle2)
         self.page.th(strDirName, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.table.close()     
Beispiel #8
0
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection(
     )
     if xsDataCollection is not None:
         firstSubWedge = xsDataCollection.subWedge[0]
         firstImage = firstSubWedge.image[0]
         if firstImage.date is not None:
             strDate = firstImage.date.value
         else:
             strDate = "-----"
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         dictTable = {
             "type": "table",
             "title": "Data collection info",
             "columns": [],
             "data": []
         }
         listRow = []
         dictTable["columns"].append("Data collection date")
         listRow.append(strDate)
         dictTable["columns"].append("Image prefix")
         listRow.append(strPrefix)
         dictTable["columns"].append("Directory")
         listRow.append(strDirName)
         dictTable["data"].append(listRow)
         #
         self.workflowStepReport.addTable("Data collection info",
                                          dictTable["columns"],
                                          dictTable["data"],
                                          orientation="vertical")
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     self.DEBUG("EDPluginExecXDSAPPv1_0.postProcess")
     # Populate the results
     prefixRunNumber = EDUtilsImage.getPrefix(self.dataInput.image.path.value)
     xsDataResultXDSAPP = self.parseOutputDirectory(self.getWorkingDirectory(), prefixRunNumber)
     self.dataOutput = xsDataResultXDSAPP
 def createDNAFileDirectoryPath(self, _xsDataResultCharacterisation):
     """
     This method creates a "DNA" style directory path, i.e. in the same directory were the 
     images are located a new directory is created with the following convention:
     
       dnafiles_prefix_runNumber
     
     The path to this directory is returned if the directory was successfully created.
     """
     # First extract all reference image directory paths and names
     xsDataCollection = _xsDataResultCharacterisation.getDataCollection()
     listImageDirectoryPath = []
     listImagePrefix = []
     for xsDataSubWedge in xsDataCollection.getSubWedge():
         for xsDataImage in xsDataSubWedge.getImage():
             strImagePath = xsDataImage.getPath().getValue()
             listImageDirectoryPath.append(os.path.dirname(strImagePath))
             listImagePrefix.append(EDUtilsImage.getPrefix(strImagePath))
     # TODO: Check that all paths and prefixes are the same
     strImageDirectory = listImageDirectoryPath[0]
     strPrefix = listImagePrefix[0]
     # Remove any "ref-" or "postref-" from the prefix in order to make it fully
     # compatitble with DNA standards:
     if (strPrefix is not None):
         if (strPrefix.startswith("ref-")):
             strPrefix = strPrefix[4:]
         elif (strPrefix.startswith("postref-")):
             strPrefix = strPrefix[8:]
     strDNAFileDirectoryPath = os.path.join(strImageDirectory, "%s_dnafiles" % strPrefix)
     return strDNAFileDirectoryPath
Beispiel #11
0
 def postProcess(self, _edObject=None):
     EDPluginExecProcessScript.postProcess(self)
     self.DEBUG("EDPluginExecXDSAPPv1_0.postProcess")
     # Populate the results
     prefixRunNumber = EDUtilsImage.getPrefix(
         self.dataInput.image.path.value)
     xsDataResultXDSAPP = self.parseOutputDirectory(
         self.getWorkingDirectory(), prefixRunNumber)
     self.dataOutput = xsDataResultXDSAPP
 def getH5FilePath(self, filePath, batchSize=1):
     imageNumber = EDUtilsImage.getImageNumber(filePath)
     prefix = EDUtilsImage.getPrefix(filePath)
     h5FileNumber = int((imageNumber - 1) / batchSize) * batchSize + 1
     h5MasterFileName = "{prefix}_{h5FileNumber}_master.h5".format(prefix=prefix,
                                                                   h5FileNumber=h5FileNumber)
     h5MasterFilePath = os.path.join(os.path.dirname(filePath), h5MasterFileName)
     h5DataFileName = "{prefix}_{h5FileNumber}_data_000001.h5".format(prefix=prefix,
                                                                   h5FileNumber=h5FileNumber)
     h5DataFilePath = os.path.join(os.path.dirname(filePath), h5DataFileName)
     return h5MasterFilePath, h5DataFilePath, h5FileNumber
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlDozorv1_0.process")
        xsDataResultControlDozor = XSDataResultControlDozor()
        for xsDataFile in self.dataInput.image:
            edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
            xsDataInputReadImageHeader = XSDataInputReadImageHeader()
            xsDataInputReadImageHeader.image = xsDataFile
            edPluginControlReadImageHeader.dataInput = xsDataInputReadImageHeader
            edPluginControlReadImageHeader.executeSynchronous()
            subWedge = edPluginControlReadImageHeader.dataOutput.subWedge
            xsDataInputDozor = XSDataInputDozor()
            beam = subWedge.experimentalCondition.beam
            detector = subWedge.experimentalCondition.detector
            goniostat = subWedge.experimentalCondition.goniostat
            xsDataInputDozor.detectorType = detector.type
            xsDataInputDozor.exposureTime = XSDataDouble(beam.exposureTime.value)
            xsDataInputDozor.spotSize = XSDataDouble(5.0)
            xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
            xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
#            xsDataInputDozor.fractionPolatization : XSDataDouble optional
            orgx = detector.beamPositionY.value / detector.pixelSizeY.value
            orgy = detector.beamPositionX.value / detector.pixelSizeX.value
            xsDataInputDozor.orgx = XSDataDouble(orgx)
            xsDataInputDozor.orgy = XSDataDouble(orgy)
            xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
#            xsDataInputDozor.imageStep : XSDataDouble optional
            xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
            xsDataInputDozor.firstImageNumber = subWedge.image[0].number
            xsDataInputDozor.numberImages = XSDataInteger(1)
            strFileName = subWedge.image[0].path.value
            strPrefix = EDUtilsImage.getPrefix(strFileName)
            strSuffix = EDUtilsImage.getSuffix(strFileName)
            strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
            xsDataInputDozor.nameTemplateImage = XSDataString(os.path.join(os.path.dirname(strFileName), strXDSTemplate))
            edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor")
            edPluginDozor.dataInput = xsDataInputDozor
            edPluginDozor.executeSynchronous()
            if edPluginDozor.dataOutput.imageDozor != []:
                xsDataResultDozor = edPluginDozor.dataOutput.imageDozor[0]
                xsDataControlImageDozor = XSDataControlImageDozor()
                xsDataControlImageDozor.image = xsDataFile
                xsDataControlImageDozor.spots_num_of = xsDataResultDozor.spots_num_of
                xsDataControlImageDozor.spots_int_aver = xsDataResultDozor.spots_int_aver
                xsDataControlImageDozor.spots_resolution = xsDataResultDozor.spots_resolution
                xsDataControlImageDozor.powder_wilson_scale = xsDataResultDozor.powder_wilson_scale
                xsDataControlImageDozor.powder_wilson_bfactor = xsDataResultDozor.powder_wilson_bfactor
                xsDataControlImageDozor.powder_wilson_resolution = xsDataResultDozor.powder_wilson_resolution
                xsDataControlImageDozor.powder_wilson_correlation = xsDataResultDozor.powder_wilson_correlation
                xsDataControlImageDozor.powder_wilson_rfactor = xsDataResultDozor.powder_wilson_rfactor
                xsDataControlImageDozor.score = xsDataResultDozor.score
                xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor)
        self.dataOutput = xsDataResultControlDozor
 def getH5FilePath(self, filePath, batchSize=1):
     imageNumber = EDUtilsImage.getImageNumber(filePath)
     prefix = EDUtilsImage.getPrefix(filePath)
     h5FileNumber = int((imageNumber - 1) / batchSize) * batchSize + 1
     h5MasterFileName = "{prefix}_{h5FileNumber}_master.h5".format(
         prefix=prefix, h5FileNumber=h5FileNumber)
     h5MasterFilePath = os.path.join(os.path.dirname(filePath),
                                     h5MasterFileName)
     h5DataFileName = "{prefix}_{h5FileNumber}_data_000001.h5".format(
         prefix=prefix, h5FileNumber=h5FileNumber)
     h5DataFilePath = os.path.join(os.path.dirname(filePath),
                                   h5DataFileName)
     return h5MasterFilePath, h5DataFilePath, h5FileNumber
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlBackground3Dv1_0.process")
        xsDataResultControlBackground3D = XSDataResultControlBackground3D()
        for xsDataFile in self.dataInput.image:
            edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
            xsDataInputReadImageHeader = XSDataInputReadImageHeader()
            xsDataInputReadImageHeader.image = xsDataFile
            edPluginControlReadImageHeader.dataInput = xsDataInputReadImageHeader
            edPluginControlReadImageHeader.executeSynchronous()
            subWedge = edPluginControlReadImageHeader.dataOutput.subWedge
            xsDataInputBackground3D = XSDataInputBackground3D()
            beam = subWedge.experimentalCondition.beam
            detector = subWedge.experimentalCondition.detector
            goniostat = subWedge.experimentalCondition.goniostat
            xsDataInputBackground3D.detectorType = detector.type
            xsDataInputBackground3D.exposureTime = XSDataDouble(beam.exposureTime.value)
            xsDataInputBackground3D.detectorDistance = XSDataDouble(detector.distance.value)
            xsDataInputBackground3D.wavelength = XSDataDouble(beam.wavelength.value)
#            xsDataInputBackground3D.fractionPolatization : XSDataDouble optional
            orgx = detector.beamPositionY.value / detector.pixelSizeY.value
            orgy = detector.beamPositionX.value / detector.pixelSizeX.value
            xsDataInputBackground3D.orgx = XSDataDouble(orgx)
            xsDataInputBackground3D.orgy = XSDataDouble(orgy)
            xsDataInputBackground3D.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
#            xsDataInputBackground3D.imageStep : XSDataDouble optional
            xsDataInputBackground3D.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
            xsDataInputBackground3D.firstImageNumber = subWedge.image[0].number
            xsDataInputBackground3D.numberImages = XSDataInteger(1)
            strFileName = subWedge.image[0].path.value
            strPrefix = EDUtilsImage.getPrefix(strFileName)
            strSuffix = EDUtilsImage.getSuffix(strFileName)
            strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
            xsDataInputBackground3D.nameTemplateImage = XSDataString(os.path.join(os.path.dirname(strFileName), strXDSTemplate))
            edPluginBackground3D = self.loadPlugin(self.strEDPluginBackground3DName, "Background3D")
            edPluginBackground3D.dataInput = xsDataInputBackground3D
            edPluginBackground3D.executeSynchronous()
            if edPluginBackground3D.dataOutput.imageBackground != []:
                xsDataResultBackground3D = edPluginBackground3D.dataOutput.imageBackground[0]
                xsDataControlImageBackground3D = XSDataControlImageBackground3D()
                xsDataControlImageBackground3D.image = xsDataFile
                xsDataControlImageBackground3D.scale = xsDataResultBackground3D.scale
                xsDataControlImageBackground3D.bfactor = xsDataResultBackground3D.bfactor
                xsDataControlImageBackground3D.resolution = xsDataResultBackground3D.resolution
                xsDataControlImageBackground3D.correlation = xsDataResultBackground3D.correlation
                xsDataControlImageBackground3D.rfactor = xsDataResultBackground3D.rfactor
                xsDataControlImageBackground3D.b_coef = xsDataResultBackground3D.b_coef
                xsDataControlImageBackground3D.b_cryst = xsDataResultBackground3D.b_cryst
                xsDataControlImageBackground3D.estimate = xsDataResultBackground3D.estimate
                xsDataResultControlBackground3D.addImageBackground(xsDataControlImageBackground3D)
        self.dataOutput = xsDataResultControlBackground3D
 def getBeamlineProposalFromPath(self, _strPathToImage):
     """ESRF specific code for extracting the beamline name and prefix from the path"""
     listPath = _strPathToImage.split("/")
     strPrefix = EDUtilsImage.getPrefix(_strPathToImage).replace("ref-", "")
     if listPath[2] == "visitor":
         strBeamline = listPath[4]
         strProposal = listPath[3]
     elif listPath[3] == "inhouse":
         strBeamline = listPath[2]
         strProposal = listPath[4]
     else:
         strBeamline = "nobeamline"
         strProposal = "noproposal"
     return (strBeamline, strProposal, strPrefix)
Beispiel #17
0
 def getBeamlineProposalFromPath(self, _strPathToImage):
     """ESRF specific code for extracting the beamline name and prefix from the path"""
     listPath = _strPathToImage.split("/")
     strPrefix = EDUtilsImage.getPrefix(_strPathToImage).replace("ref-", "")
     if listPath[2] == "visitor":
         strBeamline = listPath[4]
         strProposal = listPath[3]
     elif listPath[3] == "inhouse":
         strBeamline = listPath[2]
         strProposal = listPath[4]
     else:
         strBeamline = "nobeamline"
         strProposal = "noproposal"
     return (strBeamline, strProposal, strPrefix)
 def getH5FilePath(self, filePath, batchSize=1, isFastMesh=False):
     imageNumber = EDUtilsImage.getImageNumber(filePath)
     prefix = EDUtilsImage.getPrefix(filePath)
     if isFastMesh:
         h5ImageNumber = int((imageNumber - 1) / 100) + 1
         h5FileNumber = 1
     else:
         h5ImageNumber = 1
         h5FileNumber = int((imageNumber - 1) / batchSize) * batchSize + 1
     h5MasterFileName = "{prefix}_{h5FileNumber}_master.h5".format(prefix=prefix,
                                                                   h5FileNumber=h5FileNumber)
     h5MasterFilePath = os.path.join(os.path.dirname(filePath), h5MasterFileName)
     h5DataFileName = "{prefix}_{h5FileNumber}_data_{h5ImageNumber:06d}.h5".format(prefix=prefix,
                                                                                   h5FileNumber=h5FileNumber,
                                                                                   h5ImageNumber=h5ImageNumber)
     h5DataFilePath = os.path.join(os.path.dirname(filePath), h5DataFileName)
     return h5MasterFilePath, h5DataFilePath, h5FileNumber
 def getH5FilePath(self, filePath, batchSize=1, isFastMesh=False):
     imageNumber = EDUtilsImage.getImageNumber(filePath)
     prefix = EDUtilsImage.getPrefix(filePath)
     if isFastMesh:
         h5ImageNumber = int((imageNumber - 1) / 100) + 1
         h5FileNumber = 1
     else:
         h5ImageNumber = 1
         h5FileNumber = int((imageNumber - 1) / batchSize) * batchSize + 1
     h5MasterFileName = "{prefix}_{h5FileNumber}_master.h5".format(
         prefix=prefix, h5FileNumber=h5FileNumber)
     h5MasterFilePath = os.path.join(os.path.dirname(filePath),
                                     h5MasterFileName)
     h5DataFileName = "{prefix}_{h5FileNumber}_data_{h5ImageNumber:06d}.h5".format(
         prefix=prefix,
         h5FileNumber=h5FileNumber,
         h5ImageNumber=h5ImageNumber)
     h5DataFilePath = os.path.join(os.path.dirname(filePath),
                                   h5DataFileName)
     return h5MasterFilePath, h5DataFilePath, h5FileNumber
Beispiel #20
0
    def generateCommands(self, _xsDataInputH5ToCBF):
        """
        This method creates a list of commands for H5ToXDS
        """
        self.DEBUG("EDPluginH5ToCBFv1_0.generateCommands")

        hdf5File = _xsDataInputH5ToCBF.hdf5File.path.value
        directory = os.path.dirname(hdf5File)
        prefix = EDUtilsImage.getPrefix(hdf5File)

        imageNumber = _xsDataInputH5ToCBF.imageNumber.value

        if _xsDataInputH5ToCBF.hdf5ImageNumber is None:
            hdf5ImageNumber = imageNumber
        else:
            hdf5ImageNumber = _xsDataInputH5ToCBF.hdf5ImageNumber.value

        if "master" in hdf5File:
            masterFile = hdf5File
        else:
            masterFile = os.path.join(
                directory, prefix + "_{0}_master.h5".format(hdf5ImageNumber))

        CBFFileName = prefix + "_%04d" % imageNumber + ".cbf"
        tmpCBFFileName = "tmp_" + CBFFileName

        if self.dataInput.forcedOutputDirectory is None:
            self.CBFFile = os.path.join(directory, CBFFileName)
        else:
            forcedOutputDirectory = self.dataInput.forcedOutputDirectory.path.value
            if not os.path.exists(forcedOutputDirectory):
                os.makedirs(forcedOutputDirectory, 0o755)
            self.CBFFile = os.path.join(forcedOutputDirectory, CBFFileName)

        self.tmpCBFFile = os.path.join(self.getWorkingDirectory(),
                                       tmpCBFFileName)

        scriptCommandLine = "{0} {1} {2}".format(
            masterFile, imageNumber - hdf5ImageNumber + 1, tmpCBFFileName)

        return scriptCommandLine
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection(
     )
     if xsDataCollection is not None:
         firstSubWedge = xsDataCollection.subWedge[0]
         # MXSUP-1445: Check if transmission is less than 10% and warn if it's the case
         xsDataBeam = firstSubWedge.getExperimentalCondition().getBeam()
         if xsDataBeam.getTransmission() is not None:
             fTransmission = xsDataBeam.getTransmission().getValue()
             if fTransmission < self.fMinTransmission:
                 strWarningMessage1 = "WARNING! Transmission for characterisation set to %.1f %%" % fTransmission
                 strWarningMessage2 = "Please consider re-characterising with transmission set to 100 %"
                 self.page.font(_color="red", size="+2")
                 self.page.i()
                 self.page.h2(strWarningMessage1 + "<br>" +
                              strWarningMessage2)
                 self.page.i.close()
                 self.page.font.close()
         self.page.h2("Data collection info")
         firstImage = firstSubWedge.image[0]
         strDate = firstImage.date.value
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         self.page.table(class_='dataCollectionInfo',
                         border_="1",
                         cellpadding_="0")
         self.page.tr(align_="CENTER")
         self.page.th("Data collection date",
                      bgcolor_=self.strTableColourTitle2)
         self.page.th(strDate, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Image prefix", bgcolor_=self.strTableColourTitle2)
         self.page.th(strPrefix, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.tr(align_="CENTER", bgcolor_=self.strTableColourTitle2)
         self.page.th("Directory", bgcolor_=self.strTableColourTitle2)
         self.page.th(strDirName, bgcolor_=self.strTableColourRows)
         self.page.tr.close()
         self.page.table.close()
    def generateCommands(self, _xsDataInputH5ToCBF):
        """
        This method creates a list of commands for H5ToXDS
        """
        self.DEBUG("EDPluginH5ToCBFv1_0.generateCommands")

        hdf5File = _xsDataInputH5ToCBF.hdf5File.path.value
        directory = os.path.dirname(hdf5File)
        prefix = EDUtilsImage.getPrefix(hdf5File)

        imageNumber = _xsDataInputH5ToCBF.imageNumber.value

        if _xsDataInputH5ToCBF.hdf5ImageNumber is None:
            hdf5ImageNumber = imageNumber
        else:
            hdf5ImageNumber = _xsDataInputH5ToCBF.hdf5ImageNumber.value

        if "master" in hdf5File:
            masterFile = hdf5File
        else:
            masterFile = os.path.join(directory, prefix + "_{0}_master.h5".format(hdf5ImageNumber))

        CBFFileName = prefix + "_%04d" % imageNumber + ".cbf"
        tmpCBFFileName = "tmp_" + CBFFileName

        if self.dataInput.forcedOutputDirectory is None:
            self.CBFFile = os.path.join(directory, CBFFileName)
        else:
            forcedOutputDirectory = self.dataInput.forcedOutputDirectory.path.value
            if not os.path.exists(forcedOutputDirectory):
                os.makedirs(forcedOutputDirectory, 0755)
            self.CBFFile = os.path.join(forcedOutputDirectory, CBFFileName)

        self.tmpCBFFile = os.path.join(self.getWorkingDirectory(), tmpCBFFileName)

        scriptCommandLine = "{0} {1} {2}".format(masterFile, imageNumber - hdf5ImageNumber + 1, tmpCBFFileName)

        return scriptCommandLine
 def dataCollectionInfo(self):
     xsDataCollection = self.xsDataResultCharacterisation.getDataCollection()
     if xsDataCollection is not None:
         firstSubWedge = xsDataCollection.subWedge[0]
         # MXSUP-1445: Check if transmission is less than 10% and warn if it's the case
         xsDataBeam = firstSubWedge.getExperimentalCondition().getBeam()
         if xsDataBeam.getTransmission() is not None:
             fTransmission = xsDataBeam.getTransmission().getValue()
             if fTransmission < self.fMinTransmission:
                 strWarningMessage1 = "WARNING! Transmission for characterisation set to %.1f %%" % fTransmission
                 strWarningMessage2 = "If this transmission setting is not intentional, please consider re-characterising with transmission set to 100 %"
                 self.workflowStepReport.addWarning(strWarningMessage1)
                 self.workflowStepReport.addWarning(strWarningMessage2)
         firstImage = firstSubWedge.image[0]
         if firstImage.date is not None:
             strDate = firstImage.date.value
         else:
             strDate = "-----"
         strPrefix = EDUtilsImage.getPrefix(firstImage.path.value)
         strDirName = os.path.dirname(firstImage.path.value)
         dictTable = {"type": "table",
                      "title": "Data collection info",
                      "columns": [],
                      "data": []}
         listRow = []
         dictTable["columns"].append("Data collection date")
         listRow.append(strDate)
         dictTable["columns"].append("Image prefix")
         listRow.append(strPrefix)
         dictTable["columns"].append("Directory")
         listRow.append(strDirName)
         dictTable["data"].append(listRow)
         #
         self.workflowStepReport.addTable("Data collection info",
                                          dictTable["columns"],
                                          dictTable["data"],
                                          orientation="vertical")
    def generateXSDataInputXDS(_xsDataCollection):

        xsDataCollection = _xsDataCollection
        xsDataExperimentalCondition = _xsDataCollection.getSubWedge()[0].getExperimentalCondition()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        xsDataInputXDS = XSDataInputXDSGenerateBackgroundImage()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        # Start with the detector

        xsDataXDSDetector = EDHandlerXSDataXDSv1_0.getXSDataXDSDetector(xsDataDetector)
        xsDataInputXDS.setDetector(xsDataXDSDetector)

        # Then the beam

        xsDataXDSBeam = XSDataXDSBeam()

        xsDataVectorDoubleIncidentBeam = XSDataVectorDouble()
        xsDataVectorDoubleIncidentBeam.setV1(0.0)
        xsDataVectorDoubleIncidentBeam.setV2(0.0)
        xsDataVectorDoubleIncidentBeam.setV3(1.0)
        xsDataXDSBeam.setIncident_beam_direction(xsDataVectorDoubleIncidentBeam)

        xsDataVectorDoublePolarizationPlaneNormal = XSDataVectorDouble()
        xsDataVectorDoublePolarizationPlaneNormal.setV1(0.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV2(1.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV3(0.0)
        xsDataXDSBeam.setPolarization_plane_normal(xsDataVectorDoublePolarizationPlaneNormal)

        xsDataXDSBeam.setX_ray_wavelength(XSDataWavelength(dWavelength))

        xsDataInputXDS.setBeam(xsDataXDSBeam)

        # Then the goniostat

        xsDataXDSGoniostat = XSDataXDSGoniostat()

        xsDataVectorDoubleRotationAxis = XSDataVectorDouble()
        xsDataVectorDoubleRotationAxis.setV1(1.0)
        xsDataVectorDoubleRotationAxis.setV2(0.0)
        xsDataVectorDoubleRotationAxis.setV3(0.0)
        xsDataXDSGoniostat.setRotation_axis(xsDataVectorDoubleRotationAxis)

        xsDataXDSGoniostat.setOscillation_range(xsDataGoniostat.getOscillationWidth())

        xsDataXDSGoniostat.setStarting_angle(xsDataGoniostat.getRotationAxisStart())

        xsDataInputXDS.setGoniostat(xsDataXDSGoniostat)

#        # Then the Crystal
#
#        xsDataXDSCrystal = XSDataXDSCrystal()
#
#        xsDataXDSCrystal.setFriedels_law(XSDataString("FALSE"))
#
# #        if ( xsDataCrystal is not None ):
# #            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
# #            if ( xsDataSpaceGroup is not None ):
# #                xsDataStringName = xsDataSpaceGroup.getName()
# #                if ( xsDataStringName is not None ):
# #                    xsDataInputXDS.setSymmetry( XSDataString( xsDataStringName.getValue() ) )
#        xsDataXDSCrystal.setSpace_group_number(XSDataInteger(0))
#
#        xsDataXDSCrystal.setStrong_pixel(XSDataInteger(8))
#
#        xsDataCell = XSDataCell()
#        xsDataCell.setLength_a(XSDataLength(0.0))
#        xsDataCell.setLength_b(XSDataLength(0.0))
#        xsDataCell.setLength_c(XSDataLength(0.0))
#        xsDataCell.setAngle_alpha(XSDataAngle(0.0))
#        xsDataCell.setAngle_beta(XSDataAngle(0.0))
#        xsDataCell.setAngle_gamma(XSDataAngle(0.0))
#        xsDataXDSCrystal.setUnit_cell_constants(xsDataCell)
#
#        xsDataInputXDS.setCrystal(xsDataXDSCrystal)

        # Finaly the images

        xsDataXDSImage = XSDataXDSImage()

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        pyStrPath = xsDataImageFirst.getPath().getValue()
        pyStrFileName = EDUtilsFile.getBaseName(pyStrPath)
        pyStrDirectory = EDUtilsPath.getFolderName(pyStrPath)

        pyStrPrefix = EDUtilsImage.getPrefix(pyStrFileName)
        pyStrSuffix = EDUtilsImage.getSuffix(pyStrFileName)
        pyStrXDSTemplate = "%s_xdslink_?????.%s" % (pyStrPrefix, pyStrSuffix)

        xsDataXDSImage.setName_template_of_data_frames(XSDataString(pyStrXDSTemplate))

        iXDSLowestImageNumberGlobal = 1
        xsDataXDSImage.setStarting_frame(XSDataInteger(iXDSLowestImageNumberGlobal))

        # First we have to find the smallest goniostat rotation axis start:
        fGonioStatOscillationStartMin = None
        for xsDataSubWedge in xsDataSubWedgeList:
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition().getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
            if (fGonioStatOscillationStartMin is None):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart
            elif (fGonioStatOscillationStartMin > fGonioStatOscillationStart):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart

        # Loop through the list of sub wedges

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition().getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()

            # First find the lowest and highest image numbers
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber

            # Loop through the list of images
            iLowestXDSImageNumber = None
            iHighestXDSImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                fImageOscillationStart = fGonioStatOscillationStart + (iImageNumber - iLowestImageNumber) * fGonioStatOscillationRange
                iXDSImageNumber = iXDSLowestImageNumberGlobal + int((fImageOscillationStart - fGonioStatOscillationStartMin) / fGonioStatOscillationRange)
                # print iXDSImageNumber, fImageOscillationStart, fGonioStatOscillationStartMin, fGonioStatOscillationRange
                pyStrSourcePath = xsDataImage.getPath()
                pyStrTarget = "%s_xdslink_%05d.%s" % (pyStrPrefix, iXDSImageNumber, pyStrSuffix)
                xsDataXDSImageLink = XSDataXDSImageLink()
                xsDataFileSource = XSDataFile()
                xsDataFileSource.setPath(pyStrSourcePath)
                xsDataXDSImageLink.setSource(xsDataFileSource)
                xsDataXDSImageLink.setTarget(XSDataString(pyStrTarget))
                xsDataInputXDS.addImage_link(xsDataXDSImageLink)
                if (iLowestXDSImageNumber is None):
                    iLowestXDSImageNumber = iXDSImageNumber
                elif (iLowestXDSImageNumber > iXDSImageNumber):
                    iLowestXDSImageNumber = iXDSImageNumber
                if (iHighestXDSImageNumber is None):
                    iHighestXDSImageNumber = iXDSImageNumber
                elif (iHighestXDSImageNumber < iXDSImageNumber):
                    iHighestXDSImageNumber = iXDSImageNumber
            xsDataXDSIntegerRange = XSDataXDSIntegerRange()
            xsDataXDSIntegerRange.setLower(XSDataInteger(iLowestXDSImageNumber))
            xsDataXDSIntegerRange.setUpper(XSDataInteger(iHighestXDSImageNumber))

            xsDataXDSImage.addBackground_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addData_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addSpot_range(xsDataXDSIntegerRange)

        xsDataInputXDS.setImage(xsDataXDSImage)

        return xsDataInputXDS
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlDozorv1_0.process")
        self.sendMessageToMXCuBE("Processing started...", "info")
        EDUtilsParallel.initializeNbThread()
        xsDataResultControlDozor = XSDataResultControlDozor()
        # Check if connection to ISPyB needed
        if self.dataInput.dataCollectionId is not None:
            edPluginRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
            xsDataInputRetrieveDataCollection.dataCollectionId = self.dataInput.dataCollectionId
            edPluginRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
            edPluginRetrieveDataCollection.executeSynchronous()
            ispybDataCollection = edPluginRetrieveDataCollection.dataOutput.dataCollection
            if self.batchSize is None:
                batchSize = ispybDataCollection.numberOfImages
            else:
                batchSize = self.batchSize
            if batchSize > self.maxBatchSize:
                batchSize = self.maxBatchSize
            if abs(ispybDataCollection.overlap) > 1:
                self.hasOverlap = True
                self.overlap = ispybDataCollection.overlap
            dictImage = self.createImageDictFromISPyB(ispybDataCollection)
        else:
            # No connection to ISPyB, take parameters from input
            if self.dataInput.batchSize is None:
                batchSize = self.maxBatchSize
            else:
                batchSize = self.dataInput.batchSize.value
            dictImage = self.createImageDict(self.dataInput)
        self.screen("Dozor batch size: {0}".format(batchSize))
        if self.dataInput.hdf5BatchSize is not None:
            self.hdf5BatchSize = self.dataInput.hdf5BatchSize.value
        listAllBatches = self.createListOfBatches(dictImage.keys(), batchSize)
        if dictImage[listAllBatches[0][0]].path.value.endswith("h5"):
            # Convert HDF5 images to CBF
            self.screen("HDF5 converter batch size: {0}".format(self.batchSize))
            if self.doRadiationDamage:
                self.cbfTempDir = None
            else:
                self.cbfTempDir = tempfile.mkdtemp(prefix="CbfTemp_")
            listHdf5Batches = self.createListOfBatches(dictImage.keys(), self.batchSize)
            dictImage, self.hasHdf5Prefix = self.convertToCBF(dictImage, listHdf5Batches, self.doRadiationDamage)
        for listBatch in listAllBatches:
            # Read the header from the first image in the batch
            xsDataFile = dictImage[listBatch[0]]
            edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
            xsDataInputReadImageHeader = XSDataInputReadImageHeader()
            xsDataInputReadImageHeader.image = xsDataFile
            edPluginControlReadImageHeader.dataInput = xsDataInputReadImageHeader
            edPluginControlReadImageHeader.executeSynchronous()
            subWedge = edPluginControlReadImageHeader.dataOutput.subWedge
            xsDataInputDozor = XSDataInputDozor()
            beam = subWedge.experimentalCondition.beam
            detector = subWedge.experimentalCondition.detector
            goniostat = subWedge.experimentalCondition.goniostat
            xsDataInputDozor.detectorType = detector.type
            xsDataInputDozor.exposureTime = XSDataDouble(beam.exposureTime.value)
            xsDataInputDozor.spotSize = XSDataInteger(3)
            xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
            xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
#            xsDataInputDozor.fractionPolatization : XSDataDouble optional
            orgx = detector.beamPositionY.value / detector.pixelSizeY.value
            orgy = detector.beamPositionX.value / detector.pixelSizeX.value
            xsDataInputDozor.orgx = XSDataDouble(orgx)
            xsDataInputDozor.orgy = XSDataDouble(orgy)
            xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
#            xsDataInputDozor.imageStep : XSDataDouble optional
            xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
            xsDataInputDozor.firstImageNumber = subWedge.image[0].number
            xsDataInputDozor.numberImages = XSDataInteger(len(listBatch))
            if self.hasOverlap:
                xsDataInputDozor.overlap = XSDataAngle(self.overlap)
            strFileName = subWedge.image[0].path.value
            strPrefix = EDUtilsImage.getPrefix(strFileName)
            strSuffix = EDUtilsImage.getSuffix(strFileName)
            if EDUtilsPath.isEMBL():
                strXDSTemplate = "%s_?????.%s" % (strPrefix, strSuffix)
            elif self.hasHdf5Prefix and not self.hasOverlap:
                strXDSTemplate = "%s_??????.%s" % (strPrefix, strSuffix)
            else:
                strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
            xsDataInputDozor.nameTemplateImage = XSDataString(os.path.join(os.path.dirname(strFileName), strXDSTemplate))
            xsDataInputDozor.wedgeNumber = self.dataInput.wedgeNumber
            xsDataInputDozor.radiationDamage = self.dataInput.radiationDamage
            edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor_%05d" % subWedge.image[0].number.value)
            edPluginDozor.dataInput = xsDataInputDozor
            edPluginDozor.execute()
            edPluginDozor.synchronize()
            indexImage = 0
            imageDozorBatchList = []

            for xsDataResultDozor in edPluginDozor.dataOutput.imageDozor:
                xsDataControlImageDozor = XSDataControlImageDozor()
                xsDataControlImageDozor.number = xsDataResultDozor.number
                xsDataControlImageDozor.image = dictImage[listBatch[indexImage]]
                xsDataControlImageDozor.spotsNumOf = xsDataResultDozor.spotsNumOf
                xsDataControlImageDozor.spotsIntAver = xsDataResultDozor.spotsIntAver
                xsDataControlImageDozor.spotsResolution = xsDataResultDozor.spotsResolution
                xsDataControlImageDozor.powderWilsonScale = xsDataResultDozor.powderWilsonScale
                xsDataControlImageDozor.powderWilsonBfactor = xsDataResultDozor.powderWilsonBfactor
                xsDataControlImageDozor.powderWilsonResolution = xsDataResultDozor.powderWilsonResolution
                xsDataControlImageDozor.powderWilsonCorrelation = xsDataResultDozor.powderWilsonCorrelation
                xsDataControlImageDozor.powderWilsonRfactor = xsDataResultDozor.powderWilsonRfactor
                xsDataControlImageDozor.mainScore = xsDataResultDozor.mainScore
                xsDataControlImageDozor.spotScore = xsDataResultDozor.spotScore
                xsDataControlImageDozor.visibleResolution = xsDataResultDozor.visibleResolution
                xsDataControlImageDozor.spotFile = xsDataResultDozor.spotFile
                xsDataControlImageDozor.angle = xsDataResultDozor.angle
                xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor)
                if xsDataResultControlDozor.inputDozor is None:
                    xsDataResultControlDozor.inputDozor = XSDataDozorInput().parseString(xsDataInputDozor.marshal())
                indexImage += 1

                dozorSpotListShape = []
                dozorSpotList = []
                spotFile = None
                if xsDataControlImageDozor.spotFile is not None:
                    spotFile = xsDataControlImageDozor.spotFile.path.value
                    if os.path.exists(spotFile):
                        numpyArray = numpy.loadtxt(spotFile, skiprows=3)
                        dozorSpotList = base64.b64encode(numpyArray.tostring())
                        dozorSpotListShape.append(numpyArray.shape[0])
                        if len(numpyArray.shape) > 1:
                            dozorSpotListShape.append(numpyArray.shape[1])

                imageDozorDict = {"index": xsDataControlImageDozor.number.value,
                                  "imageName": xsDataControlImageDozor.image.path.value,
                                  "dozor_score": xsDataControlImageDozor.mainScore.value,
                                  "dozorSpotsNumOf" : xsDataControlImageDozor.spotsNumOf.value,
                                  "dozorSpotFile": spotFile,
                                  "dozorSpotList" : dozorSpotList,
                                  "dozorSpotListShape": dozorSpotListShape,
                                  "dozorSpotsIntAver": xsDataControlImageDozor.spotsIntAver.value,
                                  "dozorSpotsResolution": xsDataControlImageDozor.spotsResolution.value
                                  }
                imageDozorBatchList.append(imageDozorDict)

            xsDataResultControlDozor.halfDoseTime = edPluginDozor.dataOutput.halfDoseTime
            xsDataResultControlDozor.pngPlots = edPluginDozor.dataOutput.pngPlots

            self.sendResultToMXCuBE(imageDozorBatchList)
            self.sendMessageToMXCuBE("Batch processed")
        self.dataOutput = xsDataResultControlDozor
        if self.cbfTempDir is not None:
            if self.dataInput.keepCbfTmpDirectory is not None and self.dataInput.keepCbfTmpDirectory.value:
                self.dataOutput.pathToCbfDirectory = XSDataFile(XSDataString(self.cbfTempDir))
            else:
                shutil.rmtree(self.cbfTempDir)
    if sys.argv[index] == "--image":
        index += 1
        while not sys.argv[index].startswith("--"):
            listImages.append(sys.argv[index])
            # Replace the .h5 image file suffix with .cbf
            sys.argv[index] = os.path.splitext(sys.argv[index])[0] + ".cbf"
            index += 1
        break

if len(listImages) == 0:
    print("No --image keyword found!")
    sys.exit(1)

# Find the series number
firstImagePath = listImages[0]
imagePrefixAndRunNumber = EDUtilsImage.getPrefix(firstImagePath)
imageDirectory = os.path.dirname(firstImagePath)
if imageDirectory == "":
    imageDirectory = os.getcwd()
listFilePath = glob.glob(
    os.path.join(imageDirectory, imagePrefixAndRunNumber + "*"))
listH5Number = []
listSerialNumber = []
#
# NSLS Eiger HDF 5 naming convention, e.g.:
# ref-XtalSamp_3_4_10_master.h5       ref-XtalSamp_3_4_11_master.h5
# ref-XtalSamp_3_4_10_data_000001.h5  ref-XtalSamp_3_4_11_data_000001.h5
#
p = re.compile('{0}_(?P<serialNumber>\d+)_data_(?P<imageNumber>\d+).h5'.format(
    imagePrefixAndRunNumber))
firstSerialNumber = None
 def process(self, _edObject=None):
     EDPluginControl.process(self)
     self.DEBUG("EDPluginControlDozorv1_0.process")
     xsDataResultControlDozor = XSDataResultControlDozor()
     # Check if connection to ISPyB needed
     if self.dataInput.dataCollectionId is not None:
         edPluginRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
         xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
         xsDataInputRetrieveDataCollection.dataCollectionId = self.dataInput.dataCollectionId
         edPluginRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
         edPluginRetrieveDataCollection.executeSynchronous()
         ispybDataCollection = edPluginRetrieveDataCollection.dataOutput.dataCollection
         batchSize = ispybDataCollection.numberOfImages
         if batchSize > self.maxBatchSize:
             batchSize = self.maxBatchSize
         if abs(ispybDataCollection.overlap) > 1:
             self.hasOverlap = True
             self.overlap = ispybDataCollection.overlap
         dictImage = self.createImageDictFromISPyB(ispybDataCollection)
     else:
         # No connection to ISPyB, take parameters from input
         if self.dataInput.batchSize is None:
             batchSize = 1
         else:
             batchSize = self.dataInput.batchSize.value
         dictImage = self.createImageDict(self.dataInput)
     listAllBatches = self.createListOfBatches(dictImage.keys(), batchSize)
     if dictImage[listAllBatches[0][0]].path.value.endswith("h5"):
         # Convert HDF5 images to CBF
         self.cbfTempDir = tempfile.mkdtemp(prefix="CbfTemp_")
         dictImage, self.hasHdf5Prefix = self.convertToCBF(dictImage)
     for listBatch in listAllBatches:
         # Read the header from the first image in the batch
         xsDataFile = dictImage[listBatch[0]]
         edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
         xsDataInputReadImageHeader = XSDataInputReadImageHeader()
         xsDataInputReadImageHeader.image = xsDataFile
         edPluginControlReadImageHeader.dataInput = xsDataInputReadImageHeader
         edPluginControlReadImageHeader.executeSynchronous()
         subWedge = edPluginControlReadImageHeader.dataOutput.subWedge
         xsDataInputDozor = XSDataInputDozor()
         beam = subWedge.experimentalCondition.beam
         detector = subWedge.experimentalCondition.detector
         goniostat = subWedge.experimentalCondition.goniostat
         xsDataInputDozor.detectorType = detector.type
         xsDataInputDozor.exposureTime = XSDataDouble(beam.exposureTime.value)
         xsDataInputDozor.spotSize = XSDataInteger(3)
         xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
         xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
         #            xsDataInputDozor.fractionPolatization : XSDataDouble optional
         orgx = detector.beamPositionY.value / detector.pixelSizeY.value
         orgy = detector.beamPositionX.value / detector.pixelSizeX.value
         xsDataInputDozor.orgx = XSDataDouble(orgx)
         xsDataInputDozor.orgy = XSDataDouble(orgy)
         xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
         #            xsDataInputDozor.imageStep : XSDataDouble optional
         xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
         xsDataInputDozor.firstImageNumber = subWedge.image[0].number
         xsDataInputDozor.numberImages = XSDataInteger(len(listBatch))
         if self.hasOverlap:
             xsDataInputDozor.overlap = XSDataAngle(self.overlap)
         strFileName = subWedge.image[0].path.value
         strPrefix = EDUtilsImage.getPrefix(strFileName)
         strSuffix = EDUtilsImage.getSuffix(strFileName)
         if EDUtilsPath.isEMBL():
             strXDSTemplate = "%s_?????.%s" % (strPrefix, strSuffix)
         elif self.hasHdf5Prefix and not self.hasOverlap:
             strXDSTemplate = "%s_??????.%s" % (strPrefix, strSuffix)
         else:
             strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
         xsDataInputDozor.nameTemplateImage = XSDataString(
             os.path.join(os.path.dirname(strFileName), strXDSTemplate)
         )
         xsDataInputDozor.wedgeNumber = self.dataInput.wedgeNumber
         xsDataInputDozor.radiationDamage = self.dataInput.radiationDamage
         edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor_%05d" % subWedge.image[0].number.value)
         edPluginDozor.dataInput = xsDataInputDozor
         edPluginDozor.executeSynchronous()
         indexImage = 0
         for xsDataResultDozor in edPluginDozor.dataOutput.imageDozor:
             xsDataControlImageDozor = XSDataControlImageDozor()
             xsDataControlImageDozor.number = xsDataResultDozor.number
             xsDataControlImageDozor.image = dictImage[listBatch[indexImage]]
             xsDataControlImageDozor.spotsNumOf = xsDataResultDozor.spotsNumOf
             xsDataControlImageDozor.spotsIntAver = xsDataResultDozor.spotsIntAver
             xsDataControlImageDozor.spotsResolution = xsDataResultDozor.spotsResolution
             xsDataControlImageDozor.powderWilsonScale = xsDataResultDozor.powderWilsonScale
             xsDataControlImageDozor.powderWilsonBfactor = xsDataResultDozor.powderWilsonBfactor
             xsDataControlImageDozor.powderWilsonResolution = xsDataResultDozor.powderWilsonResolution
             xsDataControlImageDozor.powderWilsonCorrelation = xsDataResultDozor.powderWilsonCorrelation
             xsDataControlImageDozor.powderWilsonRfactor = xsDataResultDozor.powderWilsonRfactor
             xsDataControlImageDozor.mainScore = xsDataResultDozor.mainScore
             xsDataControlImageDozor.spotScore = xsDataResultDozor.spotScore
             xsDataControlImageDozor.visibleResolution = xsDataResultDozor.visibleResolution
             xsDataControlImageDozor.spotFile = xsDataResultDozor.spotFile
             xsDataControlImageDozor.angle = xsDataResultDozor.angle
             xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor)
             if xsDataResultControlDozor.inputDozor is None:
                 xsDataResultControlDozor.inputDozor = XSDataDozorInput().parseString(xsDataInputDozor.marshal())
             indexImage += 1
         xsDataResultControlDozor.halfDoseTime = edPluginDozor.dataOutput.halfDoseTime
     self.dataOutput = xsDataResultControlDozor
     if self.cbfTempDir is not None:
         shutil.rmtree(self.cbfTempDir)
Beispiel #28
0
    def generateXSDataInputXDS(_xsDataCollection):

        xsDataCollection = _xsDataCollection
        xsDataExperimentalCondition = _xsDataCollection.getSubWedge(
        )[0].getExperimentalCondition()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        xsDataInputXDS = XSDataInputXDSGenerateBackgroundImage()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        # Start with the detector

        xsDataXDSDetector = EDHandlerXSDataXDSv1_0.getXSDataXDSDetector(
            xsDataDetector)
        xsDataInputXDS.setDetector(xsDataXDSDetector)

        # Then the beam

        xsDataXDSBeam = XSDataXDSBeam()

        xsDataVectorDoubleIncidentBeam = XSDataVectorDouble()
        xsDataVectorDoubleIncidentBeam.setV1(0.0)
        xsDataVectorDoubleIncidentBeam.setV2(0.0)
        xsDataVectorDoubleIncidentBeam.setV3(1.0)
        xsDataXDSBeam.setIncident_beam_direction(
            xsDataVectorDoubleIncidentBeam)

        xsDataVectorDoublePolarizationPlaneNormal = XSDataVectorDouble()
        xsDataVectorDoublePolarizationPlaneNormal.setV1(0.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV2(1.0)
        xsDataVectorDoublePolarizationPlaneNormal.setV3(0.0)
        xsDataXDSBeam.setPolarization_plane_normal(
            xsDataVectorDoublePolarizationPlaneNormal)

        xsDataXDSBeam.setX_ray_wavelength(XSDataWavelength(dWavelength))

        xsDataInputXDS.setBeam(xsDataXDSBeam)

        # Then the goniostat

        xsDataXDSGoniostat = XSDataXDSGoniostat()

        xsDataVectorDoubleRotationAxis = XSDataVectorDouble()
        xsDataVectorDoubleRotationAxis.setV1(1.0)
        xsDataVectorDoubleRotationAxis.setV2(0.0)
        xsDataVectorDoubleRotationAxis.setV3(0.0)
        xsDataXDSGoniostat.setRotation_axis(xsDataVectorDoubleRotationAxis)

        xsDataXDSGoniostat.setOscillation_range(
            xsDataGoniostat.getOscillationWidth())

        xsDataXDSGoniostat.setStarting_angle(
            xsDataGoniostat.getRotationAxisStart())

        xsDataInputXDS.setGoniostat(xsDataXDSGoniostat)

        #        # Then the Crystal
        #
        #        xsDataXDSCrystal = XSDataXDSCrystal()
        #
        #        xsDataXDSCrystal.setFriedels_law(XSDataString("FALSE"))
        #
        ##        if ( xsDataCrystal is not None ):
        ##            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
        ##            if ( xsDataSpaceGroup is not None ):
        ##                xsDataStringName = xsDataSpaceGroup.getName()
        ##                if ( xsDataStringName is not None ):
        ##                    xsDataInputXDS.setSymmetry( XSDataString( xsDataStringName.getValue() ) )
        #        xsDataXDSCrystal.setSpace_group_number(XSDataInteger(0))
        #
        #        xsDataXDSCrystal.setStrong_pixel(XSDataInteger(8))
        #
        #        xsDataCell = XSDataCell()
        #        xsDataCell.setLength_a(XSDataLength(0.0))
        #        xsDataCell.setLength_b(XSDataLength(0.0))
        #        xsDataCell.setLength_c(XSDataLength(0.0))
        #        xsDataCell.setAngle_alpha(XSDataAngle(0.0))
        #        xsDataCell.setAngle_beta(XSDataAngle(0.0))
        #        xsDataCell.setAngle_gamma(XSDataAngle(0.0))
        #        xsDataXDSCrystal.setUnit_cell_constants(xsDataCell)
        #
        #        xsDataInputXDS.setCrystal(xsDataXDSCrystal)

        # Finaly the images

        xsDataXDSImage = XSDataXDSImage()

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        pyStrPath = xsDataImageFirst.getPath().getValue()
        pyStrFileName = EDUtilsFile.getBaseName(pyStrPath)
        pyStrDirectory = EDUtilsPath.getFolderName(pyStrPath)

        pyStrPrefix = EDUtilsImage.getPrefix(pyStrFileName)
        pyStrSuffix = EDUtilsImage.getSuffix(pyStrFileName)
        pyStrXDSTemplate = "%s_xdslink_?????.%s" % (pyStrPrefix, pyStrSuffix)

        xsDataXDSImage.setName_template_of_data_frames(
            XSDataString(pyStrXDSTemplate))

        iXDSLowestImageNumberGlobal = 1
        xsDataXDSImage.setStarting_frame(
            XSDataInteger(iXDSLowestImageNumberGlobal))

        # First we have to find the smallest goniostat rotation axis start:
        fGonioStatOscillationStartMin = None
        for xsDataSubWedge in xsDataSubWedgeList:
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            if (fGonioStatOscillationStartMin is None):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart
            elif (fGonioStatOscillationStartMin > fGonioStatOscillationStart):
                fGonioStatOscillationStartMin = fGonioStatOscillationStart

        # Loop through the list of sub wedges

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth(
            ).getValue()

            # First find the lowest and highest image numbers
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber

            # Loop through the list of images
            iLowestXDSImageNumber = None
            iHighestXDSImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                fImageOscillationStart = fGonioStatOscillationStart + (
                    iImageNumber -
                    iLowestImageNumber) * fGonioStatOscillationRange
                iXDSImageNumber = iXDSLowestImageNumberGlobal + int(
                    (fImageOscillationStart - fGonioStatOscillationStartMin) /
                    fGonioStatOscillationRange)
                #print iXDSImageNumber, fImageOscillationStart, fGonioStatOscillationStartMin, fGonioStatOscillationRange
                pyStrSourcePath = xsDataImage.getPath()
                pyStrTarget = "%s_xdslink_%05d.%s" % (
                    pyStrPrefix, iXDSImageNumber, pyStrSuffix)
                xsDataXDSImageLink = XSDataXDSImageLink()
                xsDataFileSource = XSDataFile()
                xsDataFileSource.setPath(pyStrSourcePath)
                xsDataXDSImageLink.setSource(xsDataFileSource)
                xsDataXDSImageLink.setTarget(XSDataString(pyStrTarget))
                xsDataInputXDS.addImage_link(xsDataXDSImageLink)
                if (iLowestXDSImageNumber is None):
                    iLowestXDSImageNumber = iXDSImageNumber
                elif (iLowestXDSImageNumber > iXDSImageNumber):
                    iLowestXDSImageNumber = iXDSImageNumber
                if (iHighestXDSImageNumber is None):
                    iHighestXDSImageNumber = iXDSImageNumber
                elif (iHighestXDSImageNumber < iXDSImageNumber):
                    iHighestXDSImageNumber = iXDSImageNumber
            xsDataXDSIntegerRange = XSDataXDSIntegerRange()
            xsDataXDSIntegerRange.setLower(
                XSDataInteger(iLowestXDSImageNumber))
            xsDataXDSIntegerRange.setUpper(
                XSDataInteger(iHighestXDSImageNumber))

            xsDataXDSImage.addBackground_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addData_range(xsDataXDSIntegerRange)
            xsDataXDSImage.addSpot_range(xsDataXDSIntegerRange)

        xsDataInputXDS.setImage(xsDataXDSImage)

        return xsDataInputXDS
Beispiel #29
0
 def testGetPrefix(self):
     strPrefix = EDUtilsImage.getPrefix(self.__strFileName)
     EDAssert.equal("ref-testscale_1", strPrefix)
Beispiel #30
0
 def testGetHDF5Prefix(self):
     strHDF5FileName = "t20keV-insulin_4_1_master.h5"
     strPrefix = EDUtilsImage.getPrefix(strHDF5FileName)
     EDAssert.equal("t20keV-insulin_4", strPrefix)
Beispiel #31
0
    def generateCommands(self, _xsDataInputH5ToCBF):
        """
        This method creates a list of commands for the converter
        """
        self.DEBUG("EDPluginH5ToCBFv1_1.generateCommands")

        hdf5File = _xsDataInputH5ToCBF.hdf5File.path.value
        directory = os.path.dirname(hdf5File)
        prefix = EDUtilsImage.getPrefix(hdf5File)

        if _xsDataInputH5ToCBF.imageNumber is not None:
            imageNumber = _xsDataInputH5ToCBF.imageNumber.value

            if _xsDataInputH5ToCBF.hdf5ImageNumber is None:
                hdf5ImageNumber = imageNumber
            else:
                hdf5ImageNumber = _xsDataInputH5ToCBF.hdf5ImageNumber.value

            if "master" in hdf5File:
                masterFile = hdf5File
            else:
                if EDUtilsPath.isEMBL():
                    masterFile = os.path.join(directory, prefix + "_master.h5".format(hdf5ImageNumber))
                else:
                    masterFile = os.path.join(directory, prefix + "_{0}_master.h5".format(hdf5ImageNumber))

            if _xsDataInputH5ToCBF.forcedOutputImageNumber is not None:
                CBFFileName = prefix + "_%04d" % _xsDataInputH5ToCBF.forcedOutputImageNumber.value + ".cbf"
                imageNumberInHdf5File = imageNumber
            else:
                CBFFileName = prefix + "_%04d" % imageNumber + ".cbf"
                imageNumberInHdf5File = imageNumber - hdf5ImageNumber + 1

            tmpCBFFileName = "tmp_" + CBFFileName

            if _xsDataInputH5ToCBF.forcedOutputDirectory is None:
                self.CBFFile = os.path.join(directory, CBFFileName)
            else:
                forcedOutputDirectory = self.dataInput.forcedOutputDirectory.path.value
                if not os.path.exists(forcedOutputDirectory):
                    os.makedirs(forcedOutputDirectory, 0o755)
                self.CBFFile = os.path.join(forcedOutputDirectory, CBFFileName)

            scriptCommandLine = "{0} {1} {2}".format(masterFile, imageNumberInHdf5File, self.CBFFile)

        elif _xsDataInputH5ToCBF.startImageNumber is not None and _xsDataInputH5ToCBF.endImageNumber is not None:

            startImageNumber = _xsDataInputH5ToCBF.startImageNumber.value
            endImageNumber = _xsDataInputH5ToCBF.endImageNumber.value

            if _xsDataInputH5ToCBF.hdf5ImageNumber is None:
                hdf5ImageNumber = startImageNumber
            else:
                hdf5ImageNumber = _xsDataInputH5ToCBF.hdf5ImageNumber.value

            if "master" in hdf5File:
                masterFile = hdf5File
            else:
                masterFile = os.path.join(directory, prefix + "_{0}_master.h5".format(hdf5ImageNumber))

            CBFFileNamePrefix = prefix + "_"

            if _xsDataInputH5ToCBF.forcedOutputDirectory is None:
                CBFFilePath = os.path.join(directory, CBFFileNamePrefix)
            else:
                forcedOutputDirectory = self.dataInput.forcedOutputDirectory.path.value
                if not os.path.exists(forcedOutputDirectory):
                    os.makedirs(forcedOutputDirectory, 0o755)
                CBFFilePath = os.path.join(forcedOutputDirectory, CBFFileNamePrefix)

            scriptCommandLine = "{0} {1}:{2} {3}".format(masterFile, startImageNumber, endImageNumber, CBFFilePath)

            self.CBFFileTemplate = CBFFilePath + "######.cbf"

        return scriptCommandLine
    if sys.argv[index] == "--image":
        index += 1
        while not sys.argv[index].startswith("--"):
            listImages.append(sys.argv[index])
            # Replace the .h5 image file suffix with .cbf
            sys.argv[index] = os.path.splitext(sys.argv[index])[0] + ".cbf"
            index += 1
        break

if len(listImages) == 0:
    print("No --image keyword found!")
    sys.exit(1)

# Find the series number
firstImagePath = listImages[0]
imagePrefixAndRunNumber = EDUtilsImage.getPrefix(firstImagePath)
imageDirectory = os.path.dirname(firstImagePath)
if imageDirectory == "":
    imageDirectory = os.getcwd()
listFilePath = glob.glob(os.path.join(imageDirectory, imagePrefixAndRunNumber + "*"))
listH5Number = []
listSerialNumber = []
#
# NSLS Eiger HDF 5 naming convention, e.g.:
# ref-XtalSamp_3_4_10_master.h5       ref-XtalSamp_3_4_11_master.h5
# ref-XtalSamp_3_4_10_data_000001.h5  ref-XtalSamp_3_4_11_data_000001.h5
#
p = re.compile('{0}_(?P<serialNumber>\d+)_data_(?P<imageNumber>\d+).h5'.format(imagePrefixAndRunNumber))
firstSerialNumber = None
for filePath in listFilePath:
    # Regular expression, looking for <prefix>_<runnumber>_data_<serialNumber>.h5