def correct(self, imagedata, despike=False, despikesize=None, despikethresh=None, clip=None): ''' this puts an image through a pipeline of corrections ''' normalized = self.normalize(imagedata) plan = self.retrievePlan(imagedata) if plan is not None: self.fixBadPixels(normalized, plan) if clip and (clip[0] or clip[1]): clipped = numpy.clip(normalized, clip[0], clip[1]) else: clipped = normalized if despike: self.node.logger.debug('Despiking...') nsize = despikesize thresh = despikethresh imagefun.despike(clipped, nsize, thresh) self.node.logger.debug('Despiked') final = numpy.asarray(clipped, numpy.float32) return final
plan, plandata = self.retrieveCorrectorPlan(cameradata) # save corrector plan for easy post-processing of raw frames imagedata['corrector plan'] = plandata if plan is not None: self.fixBadPixels(imagedata['image'], plan) pixelmax = imagedata['camera']['ccdcamera']['pixelmax'] imagedata['image'] = numpy.asarray(imagedata['image'], numpy.float32) if pixelmax is not None: imagedata['image'] = numpy.clip(imagedata['image'], 0, pixelmax) if plan is not None and plan['despike']: self.logger.debug('Despiking...') nsize = plan['despike size'] thresh = plan['despike threshold'] imagefun.despike(imagedata['image'], nsize, thresh) self.logger.debug('Despiked') ''' final = numpy.asarray(clipped, numpy.float32) return final ''' def reseachCorrectorPlan(self, cameradata): qcamera = leginondata.CameraEMData() # Fix Me: Ignore gain index for now because camera setting does not have it when theplan is saved. for key in ('ccdcamera','dimension','binning','offset'): qcamera[key] = cameradata[key] qplan = leginondata.CorrectorPlanData() qplan['camera'] = qcamera plandatalist = qplan.query() if plandatalist: