def setUpClass(cls): """Only do the instantiation for one time for the slow speed.""" cls.tele = TeleFacade() cls.tele.addSubSys(addCam=True, addM1M3=True, addM2=True) cls.tele.setSensorOn(sciSensorOn=True, wfSensorOn=False, guidSensorOn=False) # Use the "lsst" instead of "comcam" in the PhoSim simulation with warnings.catch_warnings(): warnings.simplefilter("ignore", category=UserWarning) cls.tele.setInstName(CamType.ComCam) # Set the survey parameters obsId = 9006000 filterType = FilterType.REF boresight = (0.2, 0.3) zAngleInDeg = 27.0912 rotAngInDeg = np.rad2deg(-1.2323) cls.tele.setSurveyParam(obsId=obsId, filterType=filterType, boresight=boresight, zAngleInDeg=zAngleInDeg, rotAngInDeg=rotAngInDeg) # Set up the phosim directory phosimDir = "phosimDir" cls.tele.setPhoSimDir(phosimDir)
def _preparePhosimCmpt(phosimDir, filterType, raInDeg, decInDeg, rotAngInDeg, numPro, isEimg, m1m3ForceError): # Set the Telescope facade class tele = TeleFacade() tele.addSubSys(addCam=True, addM1M3=True, addM2=True) tele.setPhoSimDir(phosimDir) # Prepare the phosim component phosimCmpt = PhosimCmpt(tele) # Set the telescope survey parameters boresight = (raInDeg, decInDeg) zAngleInDeg = 27.0912 phosimCmpt.setSurveyParam(filterType=filterType, boresight=boresight, zAngleInDeg=zAngleInDeg, rotAngInDeg=rotAngInDeg) # Update the setting file if needed settingFile = phosimCmpt.getSettingFile() if (numPro > 1): settingFile.updateSetting("numPro", numPro) if isEimg: settingFile.updateSetting("e2ADC", 0) # Set the seed number for M1M3 surface seedNum = 6 phosimCmpt.setSeedNum(seedNum) # Set the M1M3 force error phosimCmpt.setM1M3ForceError(m1m3ForceError) return phosimCmpt
def _prepareTeleAndSky(phosimDir): # Survey information filterType = FilterType.REF ra = 20 decl = 30 rotSkyPos = 10 # Set the Telescope facade class tele = TeleFacade() tele.setPhoSimDir(phosimDir) tele.setSurveyParam(filterType=filterType, boresight=(ra, decl), 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, 400] yInPixelInCam = [3800, 700] starMag = [15, 16] for ii in range(len(starId)): skySim.addStarByChipPos(sensorName, starId[ii], xInpixelInCam[ii], yInPixelInCam[ii], starMag[ii]) # Output the sky information outputFilePath = os.path.join(getAoclcOutputPath(), "skyLsstFamInfo.txt") skySim.exportSkyToFile(outputFilePath) return tele, skySim
def main(phosimDir, numPro): # 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 rotSkyPos = 10 # Set the Telescope facade class tele = TeleFacade() tele.setPhoSimDir(phosimDir) tele.setSurveyParam(obsId=obsId, filterType=filterType, boresight=(ra, decl), rotAngInDeg=rotSkyPos) tele.setInstName(CamType.LsstCam) # Write the accumulated DOF file tele.writeAccDofFile(outputDir) # Declare the SkySim() skySim = SkySim() # Set the observation information mjd = tele.getCamMjd() skySim.setObservationMetaData(ra, decl, rotSkyPos, mjd) # Add the interested stars sensorName = [ "R44_S00_C0", "R00_S22_C1", "R44_S00_C1", "R00_S22_C0", "R04_S20_C1", "R40_S02_C0", "R04_S20_C0", "R40_S02_C1" ] xInpixelInCam = [500, 800] yInPixelInCam = [1000, 1300] starMag = [15, 15] starId = 0 for sensor in sensorName: for ii in range(len(starMag)): skySim.addStarByChipPos(sensor, starId, xInpixelInCam[ii], yInPixelInCam[ii], starMag[ii]) starId += 1 # Export sky information outputSkyFilePath = os.path.join(outputDir, "skyWfsInfo.txt") skySim.exportSkyToFile(outputSkyFilePath) # Write the star physical command file cmdFilePath = tele.writeCmdFile(outputDir, cmdSettingFile=cmdSettingFile, 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=numPro, outputDir=outputImgDir, e2ADC=0, logFilePath=logFilePath) # Run the PhoSim tele.runPhoSim(argString)
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)