def __init__(self,**inputDict): # initialize the parameter Dictionary, and update defaults from inputDict self.paramDict = {"inputFile":"", "writeToFits":False, "outputPrefix":"testone", "xDECam":0.0, "yDECam":0.0, "debugFlag":False, "rootFlag":False, "printLevel":0, "iTelescope":0, "waveLength":700.0e-9, "nZernikeTerms":11, "nbin":128, "nPixels":32, "gridCalcMode":True, "pixelOverSample":4, "scaleFactor":2., "randomFlag":False, "gain":1.0} self.paramDict.update(inputDict) # declare fit function self.gFitFunc = donutengine(**self.paramDict) # check values of bins - prevent errors if self.gFitFunc._nbin != self.gFitFunc._nPixels * self.gFitFunc._pixelOverSample: print "makedonut: ERROR in values of nbin,nPixels,pixelOverSample!!!" sys.exit(0) # also require that _Lu > 2R, ie. that pupil fits in pupil plane # this translates into requiring that (Lambda F / pixelSize) * pixelOverSample * scaleFactor > 1 if self.gFitFunc._pixelOverSample * self.gFitFunc.getScaleFactor() * (700.e-9 * 2.9 / 15.e-6) < 1. : print "makedonut: ERROR pupil doesn't fit!!!" sys.exit(0)
def __init__(self, **inputDict): # init contains all initializations which are done only once for all fits # parameters in fixParamArray1 are nEle,rzero,bkgd,Z2,Z3,Z4,....Z11 self.paramDict = { "nZernikeTerms": 11, "nFits": 1, "fixedParamArray1": [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], #need defaults up to quadrefoil "debugFlag": False, "outputWavefront": False, "outputDiff": True, "outputChi2": False, "printLevel": 1, "maxIterations": 1000, "calcRzeroDerivative": True } # search for key in inputDict, change defaults self.paramDict.update(inputDict) # setup the fit engine self.gFitFunc = donutengine(**self.paramDict) # need dummy versions before calling self.chisq self.imgarray = numpy.zeros(1) self.weight = numpy.ones(1) self.sigmasq = numpy.ones(1) # get decam info or desi info if self.paramDict["iTelescope"] == 6 or self.paramDict[ "iTelescope"] == 7 or self.paramDict["iTelescope"] == 8: print('This is for DESI CI') from donutlib.desiutil import desiciinfo self.dInfo = desiciinfo() elif self.paramDict["iTelescope"] == 5: print('This is for DESI GFA') from donutlib.desiutil import desiinfo self.dInfo = desiinfo() else: print('This is for DECam') from donutlib.decamutil import decaminfo self.dInfo = decaminfo() # setup MINUIT self.gMinuit = ROOT.TMinuit(self.gFitFunc.npar) self.gMinuit.SetFCN(self.chisq) # arglist is for the parameters in Minuit commands arglist = array('d', 10 * [0.]) ierflg = ctypes.c_int(1982) #L ROOT.Long(1982) # set the definition of 1sigma arglist[0] = 1.0 self.gMinuit.mnexcm("SET ERR", arglist, 1, ierflg) # turn off Warnings arglist[0] = 0 self.gMinuit.mnexcm("SET NOWARNINGS", arglist, 0, ierflg) # set printlevel arglist[0] = self.paramDict["printLevel"] self.gMinuit.mnexcm("SET PRINTOUT", arglist, 1, ierflg) # do initial setup of Minuit parameters # status/limit arrays for Minuit parameters self.startingParam = numpy.zeros(self.gFitFunc.npar) self.errorParam = numpy.ones(self.gFitFunc.npar) self.loParam = numpy.zeros(self.gFitFunc.npar) self.hiParam = numpy.zeros(self.gFitFunc.npar) self.paramStatusArray = numpy.zeros( self.gFitFunc.npar) # store =0 Floating, =1 Fixed # Set starting values and step sizes for parameters # (note that one can redefine the parameters, so this method can be called multiple times) for ipar in range(self.gFitFunc.npar): self.gMinuit.DefineParameter(ipar, self.gFitFunc.parNames[ipar], self.startingParam[ipar], self.errorParam[ipar], self.loParam[ipar], self.hiParam[ipar])
def __init__(self, **inputDict): """ initialize """ # initialize the parameter Dictionary, and update defaults from inputDict self.paramDict = { "inputFile": "", "wfmFile": "", "wfmArray": None, "writeToFits": False, "outputPrefix": "testone", "xDECam": 0.0, "yDECam": 0.0, "debugFlag": False, "rootFlag": False, "iTelescope": 0, "waveLength": 700.0e-9, "nZernikeTerms": 37, "nbin": 512, "nPixels": 64, "gridCalcMode": True, "pixelOverSample": 8, "scaleFactor": 1., "rzero": 0.125, "nEle": 1.0e6, "background": 4000., "randomFlag": False, "randomSeed": 209823, # if this is an invalid integer, crazy errors will ensue "gain": 1.0, "flipFlag": False, "ZernikeArray": [] } self.paramDict.update(inputDict) # check parameters are ok if self.paramDict["nbin"] != self.paramDict[ "nPixels"] * self.paramDict["pixelOverSample"]: print("makedonut: nbin must = nPixels * pixelOverSample !!!") sys.exit(1) # also require that _Lu > 2R, ie. that pupil fits in pupil plane # this translates into requiring that (Lambda F / pixelSize) * pixelOverSample * scaleFactor > 1 # Why does this depend on scaleFactor, but not Z4?? Answer: scaleFactor effectively changes the wavelength, so # it must be included. It is also possible that Z4 is too big for the nPixels - buts that another limit than this one F = 2.9 # hardcode for DECam for now pixelSize = 15.e-6 if self.paramDict["pixelOverSample"] * self.paramDict["scaleFactor"] * ( self.paramDict["waveLength"] * F / pixelSize) < 1.: print("makedonut: ERROR pupil doesn't fit!!!") print( " value = ", self.paramDict["pixelOverSample"] * self.paramDict["scaleFactor"] * (self.paramDict["waveLength"] * F / pixelSize)) #sys.exit(2) # for WFM, need to turn gridCalcMode to False for donutengine #if self.paramDict["useWFM"]: # self.paramDict["gridCalcMode"] = False # # don't do this by default, may need it if Zemax is used, but not if correct bins sizes are used. # and it isn't coded with c++ donutengine yet either... # declare fit function self.gFitFunc = donutengine(**self.paramDict) # DECam info self.dinfo = decaminfo() # set random seed numpy.random.seed(self.paramDict["randomSeed"])
def __init__(self,**inputDict): # init contains all initializations which are done only once for all fits # parameters in fixParamArray1 are nEle,rzero,bkgd,Z2,Z3,Z4,....Z11 self.paramDict = {"nZernikeTerms":11, "nFits":1, "fixedParamArray1":[0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1], #need defaults up to quadrefoil "debugFlag":False, "outputWavefront":False, "outputDiff":True, "outputChi2":False, "printLevel":1, "maxIterations":1000} # search for key in inputDict, change defaults self.paramDict.update(inputDict) # setup the fit engine self.gFitFunc = donutengine(**self.paramDict) # need dummy versions before calling self.chisq self.imgarray = numpy.zeros(1) self.weight = numpy.ones(1) self.sigmasq = numpy.ones(1) # get decam info self.decamInfo = decaminfo() # setup MINUIT self.gMinuit = ROOT.TMinuit(self.gFitFunc.npar) self.gMinuit.SetFCN( self.chisq ) # arglist is for the parameters in Minuit commands arglist = array( 'd', 10*[0.] ) ierflg = ROOT.Long(1982) # set the definition of 1sigma arglist[0] = 1.0 self.gMinuit.mnexcm( "SET ERR", arglist, 1, ierflg ) # turn off Warnings arglist[0] = 0 self.gMinuit.mnexcm("SET NOWARNINGS", arglist,0,ierflg) # set printlevel arglist[0] = self.paramDict["printLevel"] self.gMinuit.mnexcm("SET PRINTOUT", arglist,1,ierflg) # do initial setup of Minuit parameters # status/limit arrays for Minuit parameters self.startingParam = numpy.zeros(self.gFitFunc.npar) self.errorParam = numpy.ones(self.gFitFunc.npar) self.loParam = numpy.zeros(self.gFitFunc.npar) self.hiParam = numpy.zeros(self.gFitFunc.npar) self.paramStatusArray = numpy.zeros(self.gFitFunc.npar) # store =0 Floating, =1 Fixed # Set starting values and step sizes for parameters # (note that one can redefine the parameters, so this method can be called multiple times) for ipar in range(self.gFitFunc.npar): self.gMinuit.DefineParameter(ipar,self.gFitFunc.parNames[ipar],self.startingParam[ipar],self.errorParam[ipar],self.loParam[ipar],self.hiParam[ipar])
def __init__(self,**inputDict): """ initialize """ # initialize the parameter Dictionary, and update defaults from inputDict self.paramDict = {"inputFile":"", "wfmFile":"", "wfmArray":None, "writeToFits":False, "outputPrefix":"testone", "xDECam":0.0, "yDECam":0.0, "debugFlag":False, "rootFlag":False, "iTelescope":0, "waveLength":700.0e-9, "nZernikeTerms":37, "nbin":512, "nPixels":64, "gridCalcMode":True, "pixelOverSample":8, "scaleFactor":1., "rzero":0.125, "nEle":1.0e6, "background":4000., "randomFlag":False, "randomSeed":209823, # if this is an invalid integer, crazy errors will ensue "gain":1.0, "flipFlag":False, "ZernikeArray":[]} self.paramDict.update(inputDict) # check parameters are ok if self.paramDict["nbin"] != self.paramDict["nPixels"]*self.paramDict["pixelOverSample"]: print "makedonut: nbin must = nPixels * pixelOverSample !!!" sys.exit(1) # also require that _Lu > 2R, ie. that pupil fits in pupil plane # this translates into requiring that (Lambda F / pixelSize) * pixelOverSample * scaleFactor > 1 # Why does this depend on scaleFactor, but not Z4?? Answer: scaleFactor effectively changes the wavelength, so # it must be included. It is also possible that Z4 is too big for the nPixels - buts that another limit than this one F = 2.9 # hardcode for DECam for now pixelSize = 15.e-6 if self.paramDict["pixelOverSample"] * self.paramDict["scaleFactor"] * (self.paramDict["waveLength"] * F / pixelSize) < 1. : print "makedonut: ERROR pupil doesn't fit!!!" print " value = ",self.paramDict["pixelOverSample"] * self.paramDict["scaleFactor"] * (self.paramDict["waveLength"] * F / pixelSize) #sys.exit(2) # for WFM, need to turn gridCalcMode to False for donutengine #if self.paramDict["useWFM"]: # self.paramDict["gridCalcMode"] = False # # don't do this by default, may need it if Zemax is used, but not if correct bins sizes are used. # and it isn't coded with c++ donutengine yet either... # declare fit function self.gFitFunc = donutengine(**self.paramDict) # DECam info self.dinfo = decaminfo() # set random seed numpy.random.seed(self.paramDict["randomSeed"])
"nPixels": 64, "gridCalcMode": True, "pixelOverSample": 8, "scaleFactor": 1., "rzero": 0.125, "nEle": 1.0e6, "background": 4000., "randomFlag": False, "randomSeed": 209823, # if this is an invalid integer, crazy errors will ensue "gain": 1.0, "flipFlag": False, "iTelescope": 5, # 5 stands for the DESI configuration "ZernikeArray": [] } gFitFunc = donutengine(**paramDict) parArr = np.zeros(gFitFunc.npar) parArr[gFitFunc.ipar_bkgd] = 4000. parArr[gFitFunc.ipar_nEle] = 1.e6 parArr[gFitFunc.ipar_rzero] = 0.15 parArr[gFitFunc.ipar_ZernikeFirst + 2] = 7.4 # Set the angle (in degrees, Zemax Echo 22 coordinate system) # See angles for the test fields inside 00README in the testpupils directory gFitFunc.setXYDESI(1.325, 0.89) #calculate and get the pupil mask gFitFunc.calcAll(parArr) data = gFitFunc.getvImage() pupil = gFitFunc.getvPupilMask()