def set_mask(self, mask): with self._sem: self._mask = mask if mask is not None: self._mask_crc = crc32(mask) else: self._mask_crc = None
def get_mask(self): if self._mask is False: with self._sem: if self._mask is False: self._mask = self.calc_mask() # gets None in worse cases if self._mask is not None: self._mask_crc = crc32(self._mask) return self._mask
def set_maskfile(self, maskfile): if fabio: with self._sem: self._mask = numpy.ascontiguousarray(fabio.open(maskfile).data, dtype=numpy.int8) self._mask_crc = crc32(self._mask) self._maskfile = maskfile else: logger.error("FabIO is not available, unable to load the image to set the mask.")
def set_maskfile(self, maskfile): try: import fabio except: ImportError("Please install fabio to load images") with self._sem: self._mask = numpy.ascontiguousarray(fabio.open(maskfile).data, dtype=numpy.int8) self._mask_crc = crc32(self._mask) self._maskfile = maskfile
def setFlatfieldFile(self, imagefile): """ @param imagefile: filename with the path to the flatfield image """ with self._sem: if imagefile: self.flatfile = imagefile try: self.flatfield = numpy.ascontiguousarray(fabio.open(imagefile).data, numpy.float32) except Exception as error: logger.warning("setFlatfieldFile: Unable to read file %s: %s" % (imagefile, error)) else: self.flatfield_crc = crc32(self.flatfield) self.header["flatfield"] = imagefile else: self.flatfile = self.flatfield = self.flatfield_crc = None self.header["flatfield"] = "None"
def setDarkcurrentFile(self, imagefile): """ @param imagefile: filename with the path to the dark image """ with self._sem: if imagefile: self.darkfile = imagefile try: self.darkcurrent = numpy.ascontiguousarray(fabio.open(imagefile).data, numpy.float32) except Exception as error: logger.warning("setDarkcurrentFile: Unable to read file %s: %s" % (imagefile, error)) else: self.darkcurrent_crc = crc32(self.darkcurrent) self.header["darkcurrent"] = imagefile else: self.darkfile = self.darkcurrent = self.darkcurrent_crc = None self.header["darkcurrent"] = "None"
def setFlatfieldFile(self, imagefile): """ :param imagefile: filename with the path to the flatfield image """ with self._sem: if imagefile: self.flatfile = imagefile try: self.flatfield = numpy.ascontiguousarray( fabio.open(imagefile).data, numpy.float32) except Exception as error: logger.warning( "setFlatfieldFile: Unable to read file %s: %s", imagefile, error) else: self.flatfield_crc = crc32(self.flatfield) self.header["flatfield"] = imagefile else: self.flatfile = self.flatfield = self.flatfield_crc = None self.header["flatfield"] = "None"
def setDarkcurrentFile(self, imagefile): """ :param imagefile: filename with the path to the dark image """ with self._sem: if imagefile: self.darkfile = imagefile try: self.darkcurrent = numpy.ascontiguousarray( fabio.open(imagefile).data, numpy.float32) except Exception as error: logger.warning( "setDarkcurrentFile: Unable to read file %s: %s", imagefile, error) else: self.darkcurrent_crc = crc32(self.darkcurrent) self.header["darkcurrent"] = imagefile else: self.darkfile = self.darkcurrent = self.darkcurrent_crc = None self.header["darkcurrent"] = "None"
def set_mask(self, mask): with self._sem: self._mask = mask self._mask_crc = crc32(mask)