def main(phosimDir): # Settings outputDir = getAoclcOutputPath() outputImgDir = os.path.join(outputDir, "img") os.makedirs(outputImgDir, exist_ok=True) configDir = getConfigDir() cmdSettingFile = os.path.join(configDir, "cmdFile", "opdDefault.cmd") instSettingFile = os.path.join(configDir, "instFile", "opdDefault.inst") # Declare the opd metrology and add the interested field points metr = OpdMetrology() metr.addFieldXYbyDeg(0, 0) metr.addFieldXYbyDeg(0.2, 0.3) # Set the Telescope facade class tele = TeleFacade() tele.setPhoSimDir(phosimDir) obsId = 9006050 filterType = FilterType.REF tele.setSurveyParam(obsId=obsId, filterType=filterType) # Update the telescope degree of freedom with sepecific camera dx dofInUm = np.zeros(50) dofInUm[6] = 1000 tele.accDofInUm(dofInUm) # Write the physical command file cmdFilePath = tele.writeCmdFile(outputDir, cmdSettingFile=cmdSettingFile, cmdFileName="opd.cmd") # Write the instance file instFilePath = tele.writeOpdInstFile(outputDir, metr, instSettingFile=instSettingFile, instFileName="opd.inst") # Get the argument to run the PhoSim logFilePath = os.path.join(outputImgDir, "opdPhoSim.log") argString = tele.getPhoSimArgs(instFilePath, extraCommandFile=cmdFilePath, numPro=2, outputDir=outputImgDir, e2ADC=0, logFilePath=logFilePath) # Run the PhoSim tele.runPhoSim(argString) # Analyze the OPD fits images opdFitsFile = os.path.join(outputImgDir, "opd_%d_0.fits.gz" % obsId) zk = metr.getZkFromOpd(opdFitsFile=opdFitsFile)[0] print("Zk of OPD_0 is %s." % zk) wavelengthInUm = tele.getRefWaveLength() * 1e-3 pssn = metr.calcPSSN(wavelengthInUm, opdFitsFile=opdFitsFile) print("Calculated PSSN is %.4f." % pssn)
def main(phosimDir): # Settings outputDir = getAoclcOutputPath() outputImgDir = os.path.join(outputDir, "img") os.makedirs(outputImgDir, exist_ok=True) configDir = getConfigDir() cmdSettingFile = os.path.join(configDir, "cmdFile", "starDefault.cmd") instSettingFile = os.path.join(configDir, "instFile", "starSingleExp.inst") # Survey information obsId = 9006000 filterType = FilterType.REF ra = 20 decl = 30 zAngleInDeg = 27.0912 rotSkyPos = np.rad2deg(-1.2323) # Set the Telescope facade class tele = TeleFacade() tele.addSubSys(addCam=True, addM1M3=True, addM2=True) tele.setPhoSimDir(phosimDir) tele.setSurveyParam(obsId=obsId, filterType=filterType, boresight=(ra, decl), zAngleInDeg=zAngleInDeg, rotAngInDeg=rotSkyPos) tele.setInstName(CamType.LsstFamCam) # Declare the SkySim() skySim = SkySim() # Set the observation information mjd = tele.getCamMjd() skySim.setObservationMetaData(ra, decl, rotSkyPos, mjd) # Add the interested stars sensorName = "R22_S11" starId = [0, 1] xInpixelInCam = [3200, 300] yInPixelInCam = [3800, 1000] starMag = [15, 12] for ii in range(len(starId)): skySim.addStarByChipPos(sensorName, starId[ii], xInpixelInCam[ii], yInPixelInCam[ii], starMag[ii]) # Generate the perturbation iSim = 6 pertCmdFilePath = tele.writePertBaseOnConfigFile(outputDir, seedNum=iSim, saveResMapFig=True) # Update the telescope degree of freedom with camera piston in um dofInUm = np.zeros(50) dofInUm[5] = 1000 tele.accDofInUm(dofInUm) # Write the accumulated DOF file tele.writeAccDofFile(outputDir) # Write the star physical command file cmdFilePath = tele.writeCmdFile(outputDir, cmdSettingFile=cmdSettingFile, pertFilePath=pertCmdFilePath, cmdFileName="star.cmd") # Write the instance file instFilePath = tele.writeStarInstFile(outputDir, skySim, instSettingFile=instSettingFile, instFileName="star.inst") # Get the argument to run the PhoSim logFilePath = os.path.join(outputImgDir, "phosimStar.log") argString = tele.getPhoSimArgs(instFilePath, extraCommandFile=cmdFilePath, numPro=1, outputDir=outputImgDir, e2ADC=0, logFilePath=logFilePath) # Run the PhoSim tele.runPhoSim(argString)