def __makeMRB(self, log=None): """routine for calling MultiRingBinned""" exp = wx.GetApp().ws det = exp.detector pdat = exp.activeMaterial.planeData img = exp.activeImage nrho = self.mrb_pan.numRho_spn.GetValue() neta = self.mrb_pan.numEta_spn.GetValue() etaMin = self.mrb_pan.emin * piBy180 etaMax = self.mrb_pan.emax * piBy180 cakeArgs = { 'verbose': True, 'numEta': neta, 'corrected': False, 'etaRange': [etaMin, etaMax] } self.mrb = detector.MultiRingBinned(det, pdat, img, targetNRho=nrho, polarRebinKWArgs=cakeArgs, log=log) # log.write('\ndone', done=True) return
def calibrate(self, calInp, rdrInp, mat, log=None): """Calibrate this detector using specified reader and options""" # # Save inputs for the record # self.calInp = calInp self.rdrInp = rdrInp self.mat = mat # self.detector.setupRefinement(tuple(self.refineFlags)) # # Set calibrant properties # calDat = mat.planeData # # Generate images # self.fitParams = [] self.mrbImages = [] # reader = rdrInp.makeReader() nf = reader.getNFrames() for i in range(nf): msg = '*** fitting frame %d of %d\n' %(i+1, nf) + \ '*** detector x, y, D = (%g, %g, %g)\n' \ %(self.detector.xc, self.detector.yc, self.detector.workDist) + \ '*** material name:\t%s\n' %(mat.name) + \ '*** target num rho:\t%d\n' %(calInp.numRho) + \ 'using the following HKLs:\n' \ + mat.planeData.hkls.__repr__() # # Reset tthmax here in case detector geometry pushes # a ring off the detector. # # NO!!! # calDat.tThMax = self.detector.getTThMax() cFrame = reader() if log: log.write(msg) else: print msg pass if calInp.fitType == FitModes.MULTIRING: mrb = detector.MultiRingBinned( self.detector, calDat, cFrame, targetNRho=calInp.numRho, polarRebinKWArgs=calInp.cakeArgs, log=log) tmp = mrb.doFit() self.mrbImages.append(mrb) else: print '... using direct fit mode' self.detector.fitRings(cFrame, calDat, xtol=calInp.xtol) tmp = self.detector.xFitRings pass self.fitParams.append(self.detector.getParams(allParams=True)) print 'fit parameters(%d):\n' % i, self.fitParams[-1] pass # mean and std dev of geometric parameters meanParams = numpy.mean(numpy.array(self.fitParams), 0).tolist() stdvParams = numpy.std(numpy.array(self.fitParams), 0).tolist() # make detector object from mean of phi = 0-180 scans self.detector._Detector2DRC__updateFromPList(meanParams) return