def setDarkcurrentFile(self, imagefile): try: darkcurrentImage = getDataFromFile(imagefile) except Exception as error: logger.warning("setDarkcurrentFile: Unable to read file %s: %s" % (imagefile, error)) else: self.ai.set_darkcurrent(darkcurrentImage.buffer)
def setFlatfieldFile(self, imagefile): try: backGroundImage = getDataFromFile(imagefile) except Exception as error: logger.warning("setFlatfieldFile: Unable to read file %s: %s" % (imagefile, error)) else: self.ai.set_flatfield(backGroundImage.buffer)
def setBackgroundImage(self, filepath): deb.Param('filepath=%s' % filepath) self.__backGroundImage = getDataFromFile(filepath) if self.__deleteDarkAfterRead: os.unlink(filepath) if (self.__backGroundTask): self.__backGroundTask.setBackgroundImage(self.__backGroundImage)
def setBackgroundImage(self,filepath) : deb.Param('filepath=%s' % filepath) self.__backGroundImage = getDataFromFile(filepath) if self.__deleteDarkAfterRead: os.unlink(filepath) if(self.__backGroundTask) : self.__backGroundTask.setBackgroundImage(self.__backGroundImage)
def putFile (self, localFile, remoteFile): ''' Put the file localFile on the remote file remoteFile Return True if ok, otherwise an error ''' logging.info("Copying the local file {0} to {1}".format(localFile, remoteFile)) data = getDataFromFile(localFile) status = self.writeFile (remoteFile, data) if isinstance(status,Exception): logging.info("Impossible to create the remote file {0}".format(remoteFile)) return status else: return True
def setMaskFile(self,argin) : mask = getDataFromFile(*argin) self.__roiCounterMgr.setMask(mask)
def setMaskFile(self, argin): mask = getDataFromFile(*argin) self.__peakFinderMgr.setMask(mask)
def setFlatFieldImage(self,filepath) : self.__flatFieldImage = getDataFromFile(filepath) if(self.__flatFieldTask) : self.__flatFieldTask.setFlatFieldImage(self.__flatFieldImage)
def setFlatFieldImage(self, filepath): self.__flatFieldImage = getDataFromFile(filepath) if (self.__flatFieldTask): self.__flatFieldTask.setFlatFieldImage(self.__flatFieldImage)
def setMaskImage(self,filepath) : self.__maskImage = getDataFromFile(filepath) if(self.__maskTask) : self.__maskTask.setMaskImage(self.__maskImage)
def setMaskFile(self, argin): mask = getDataFromFile(*argin) self.__roi2spectrumMgr.setMask(mask)
def setJsonConfig(self, jsonconfig): print("start config ...") if os.path.isfile(jsonconfig): config = json.load(open(jsonconfig, "r")) else: config = json.loads(jsonconfig) if "poni" in config: poni = config["poni"] if poni and os.path.isfile(poni): self.ai = pyFAI.load(poni) detector = config.get("detector", "detector") self.ai.detector = pyFAI.detectors.detector_factory(detector) if "wavelength" in config: wavelength = config["wavelength"] try: fwavelength = float(wavelength) except ValueError: logger.error("Unable to convert wavelength to float: %s" % wavelength) else: if fwavelength <= 0 or fwavelength > 1e-6: logger.warning("Wavelength is in meter ... unlikely value %s" % fwavelength) self.ai.wavelength = fwavelength splineFile = config.get("splineFile") if splineFile and os.path.isfile(splineFile): self.ai.detector.splineFile = splineFile self.ai.pixel1 = float(config.get("pixel1", 1)) self.ai.pixel2 = float(config.get("pixel2", 1)) self.ai.dist = config.get("dist", 1) self.ai.poni1 = config.get("poni1", 0) self.ai.poni2 = config.get("poni2", 0) self.ai.rot1 = config.get("rot1", 0) self.ai.rot2 = config.get("rot2", 0) self.ai.rot3 = config.get("rot3", 0) if config.get("chi_discontinuity_at_0"): self.ai.setChiDiscAtZero() mask_file = config.get("mask_file") do_mask = config.get("do_mask") if mask_file and os.path.exists(mask_file) and do_mask: try: mask = getDataFromFile(mask_file).buffer except Exception as error: logger.error("Unable to load mask file %s, error %s" % (mask_file, error)) else: self.ai.mask = mask dark_files = [i.strip() for i in config.get("dark_current", "").split(",") if os.path.isfile(i.strip())] if dark_files and config.get("do_dark"): d0 = getDataFromFile(dark_files[0]).buffer darks = numpy.zeros(d0.shape[0], d0.shape[1], len(dark_files), dtype=numpy.float32) for i, f in enumerate(dark_files): darks[:, :, i] = getDataFromFile(f).buffer self.ai.darkcurrent = darks.mean(axis= -1) flat_files = [i.strip() for i in config.get("flat_field", "").split(",") if os.path.isfile(i.strip())] if flat_files and config.get("do_flat"): d0 = getDataFromFile(flat_files[0]).buffer flats = numpy.zeros(d0.shape[0], d0.shape[1], len(flat_files), dtype=numpy.float32) for i, f in enumerate(flat_files): flats[:, :, i] = getDataFromFile(f).buffer self.ai.darkcurrent = flats.mean(axis= -1) if config.get("do_2D"): self.nbpt_azim = int(config.get("azim_pt")) else: self.nbpt_azim = 1 if config.get("rad_pt"): self.nbpt_rad = int(config.get("rad_pt")) self.unit = pyFAI.units.to_unit(config.get("unit", pyFAI.units.TTH_DEG)) logger.info(self.ai.__repr__()) self.reset()
def setMaskFile(self,argin) : mask = getDataFromFile(*argin) self.__roi2spectrumMgr.setMask(mask)
def setMaskFile(self,argin) : mask = getDataFromFile(*argin) self.__peakFinderMgr.setMask(mask)