Beispiel #1
0
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
Beispiel #2
0
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)
Beispiel #3
0
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.addSubSys(addCam=True, addM1M3=True, addM2=True)
    tele.setPhoSimDir(phosimDir)

    # Set the survey parameters
    obsId = 9006000
    filterType = FilterType.REF
    zAngleInDeg = 27.0912
    rotAngInDeg = np.rad2deg(-1.2323)
    tele.setSurveyParam(obsId=obsId,
                        filterType=filterType,
                        zAngleInDeg=zAngleInDeg,
                        rotAngInDeg=rotAngInDeg)

    # Generate the perturbation
    iSim = 6
    pertCmdFilePath = tele.writePertBaseOnConfigFile(outputDir,
                                                     seedNum=iSim,
                                                     saveResMapFig=True)

    # 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,
                                    pertFilePath=pertCmdFilePath,
                                    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)