Example #1
0
    def setUp(self):

        self.configFilePath = os.path.join(getModulePath(), "configData",
                                           "telescopeConfig", "GT.inst")
        self.tele = TeleFacade(configFilePath=self.configFilePath)

        # Set the subsystem data directory
        camDataDir = os.path.join(getModulePath(), "configData", "camera")
        M1M3dataDir = os.path.join(getModulePath(), "configData", "M1M3")
        M2dataDir = os.path.join(getModulePath(), "configData", "M2")
        self.tele.setSubSysConfigDir(camDataDir=camDataDir,
                                     M1M3dataDir=M1M3dataDir,
                                     M2dataDir=M2dataDir)

        # Set the survey parameters
        obsId = 9006000
        filterType = FilterType.G
        boresight = (0.2, 0.3)
        zAngleInDeg = 27.0912
        rotAngInDeg = np.rad2deg(-1.2323)
        mjd = 59552.3
        self.tele.setSurveyParam(obsId=obsId, filterType=filterType,
                                 boresight=boresight, zAngleInDeg=zAngleInDeg,
                                 rotAngInDeg=rotAngInDeg, mjd=mjd)

        # Set the output dir
        self.outputDir = os.path.join(getModulePath(), "output", "temp")
        os.makedirs(self.outputDir)
Example #2
0
def precondition(phosimDir):

    # Survey information
    instName = "lsst"
    filterType = FilterType.REF
    ra = 20
    decl = 30
    rotSkyPos = 10
    mjd = 59580.0

    # Declare the SkySim()
    skySim = SkySim()

    # Set the focal plane information
    folderPath2FocalPlane = os.path.join(phosimDir, "data", instName)
    skySim.setFolderPath2FocalPlane(folderPath2FocalPlane)

    # Set the observation information
    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(getModulePath(), "output",
                                  "skyLsstFamInfo.txt")
    skySim.exportSkyToFile(outputFilePath)

    # Set the Telescope facade class
    configFilePath = os.path.join(getModulePath(), "configData",
                                  "telescopeConfig", "GT.inst")
    tele = TeleFacade(configFilePath=configFilePath)
    tele.setSubSysConfigDir(phosimDir=phosimDir)
    tele.setSurveyParam(filterType=filterType,
                        boresight=(ra, decl),
                        rotAngInDeg=rotSkyPos,
                        mjd=mjd)
    tele.setInstName(instName)

    return tele, skySim
Example #3
0
    def testSetSurveyParamWithCorrectInput(self):

        obsId = 100
        filterType = FilterType.U
        boresight = (10, 20)
        zAngleInDeg = 10.0
        rotAngInDeg = 11.0
        mjd = 4000.0

        tele = TeleFacade()
        tele.setSurveyParam(obsId=obsId, filterType=filterType,
                            boresight=boresight, zAngleInDeg=zAngleInDeg,
                            rotAngInDeg=rotAngInDeg, mjd=mjd)

        self.assertEqual(tele.surveyParam["obsId"], obsId)
        self.assertEqual(tele.surveyParam["filterType"], filterType)
        self.assertEqual(tele.surveyParam["boresight"], boresight)
        self.assertEqual(tele.surveyParam["zAngleInDeg"], zAngleInDeg)
        self.assertEqual(tele.surveyParam["rotAngInDeg"], rotAngInDeg)
        self.assertEqual(tele.surveyParam["mjd"], mjd)
Example #4
0
    def __init__(self, phosimDir):
        """Initialization of WEP PhoSim component class.

        WEP: wavefront estimation pipeline.

        Parameters
        ----------
        phosimDir : str
            PhoSim directory.
        """

        self.metr = OpdMetrology()
        self.tele = TeleFacade()

        self.outputDir = ""
        self.outputImgDir = ""
        self.seedNum = 0

        self.phosimParam = {"numPro": 1, "e2ADC": 1}

        self._config(phosimDir)
Example #5
0
    def testSetSubSysConfigDir(self):

        tele = TeleFacade(configFilePath=self.configFilePath)
        self.assertEqual(tele.cam, None)
        self.assertEqual(tele.M1M3, None)
        self.assertEqual(tele.M2, None)

        camDataDir = "NotCamDataDir"
        M1M3dataDir = "NotM1M3dataDir"
        M2dataDir = "NotM2dataDir"
        phosimDir = "NotPhosimDir"
        tele.setSubSysConfigDir(camDataDir=camDataDir, M1M3dataDir=M1M3dataDir,
                                M2dataDir=M2dataDir, phosimDir=phosimDir)

        # Check the subsystems are instantiated after setting up the
        # configuration directory.
        self.assertNotEqual(tele.cam, None)
        self.assertNotEqual(tele.M1M3, None)
        self.assertNotEqual(tele.M2, None)

        self.assertEqual(tele.cam.camDataDir, camDataDir)
        self.assertEqual(tele.M1M3.mirrorDataDir, M1M3dataDir)
        self.assertEqual(tele.M2.mirrorDataDir, M2dataDir)
        self.assertEqual(tele.phoSimCommu.phosimDir, phosimDir)
def main(phosimDir):

    # Settings
    outputDir = os.path.join(getModulePath(), "output")
    outputImgDir = os.path.join(outputDir, "img")

    cmdSettingFile = os.path.join(getModulePath(), "configData", "cmdFile",
                                  "starDefault.cmd")
    instSettingFile = os.path.join(getModulePath(), "configData", "instFile",
                                   "starSingleExp.inst")

    # Survey information
    obsId = 9006000
    instName = "lsst"
    filterType = FilterType.REF
    ra = 20
    decl = 30
    rotSkyPos = 10
    mjd = 59580.0

    # Declare the SkySim()
    skySim = SkySim()

    # Set the focal plane information
    folderPath2FocalPlane = os.path.join(phosimDir, "data", instName)
    skySim.setFolderPath2FocalPlane(folderPath2FocalPlane)

    # Set the observation information
    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(getModulePath(), "output",
                                     "skyWfsInfo.txt")
    skySim.exportSkyToFile(outputSkyFilePath)

    # Set the Telescope facade class
    configFilePath = os.path.join(getModulePath(), "configData",
                                  "telescopeConfig", "GT.inst")
    tele = TeleFacade(configFilePath=configFilePath)
    tele.setSubSysConfigDir(phosimDir=phosimDir)
    tele.setSurveyParam(obsId=obsId,
                        filterType=filterType,
                        boresight=(ra, decl),
                        rotAngInDeg=rotSkyPos,
                        mjd=mjd)
    tele.setInstName(instName)

    # Write the accumulated DOF file
    tele.writeAccDofFile(outputDir)

    # 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=8,
                                   outputDir=outputImgDir,
                                   e2ADC=0,
                                   logFilePath=logFilePath)

    # Run the PhoSim
    tele.runPhoSim(argString)
Example #7
0
def main(phosimDir):

    # Settings
    outputDir = os.path.join(getModulePath(), "output")
    outputImgDir = os.path.join(outputDir, "img")

    cmdSettingFile = os.path.join(getModulePath(), "configData", "cmdFile",
                                  "opdDefault.cmd")
    instSettingFile = os.path.join(getModulePath(), "configData", "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
    configFilePath = os.path.join(getModulePath(), "configData",
                                  "telescopeConfig", "GT.inst")
    tele = TeleFacade(configFilePath=configFilePath)
    tele.setSubSysConfigDir(phosimDir=phosimDir)

    obsId = 9006050
    filterType = FilterType.REF
    tele.setSurveyParam(obsId=obsId, filterType=filterType)

    # Update the telescope degree of freedom
    dofInUm = np.zeros(50)

    # Camera dx
    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_9006050_0.fits.gz")
    zk = metr.getZkFromOpd(opdFitsFile=opdFitsFile)[0]
    print(zk)

    wavelengthInUm = tele.WAVELENGTH_IN_NM * 1e-3
    pssn = metr.calcPSSN(wavelengthInUm, opdFitsFile=opdFitsFile)

    print(pssn)
Example #8
0
def main(phosimDir):

    # Settings
    outputDir = os.path.join(getModulePath(), "output")
    outputImgDir = os.path.join(outputDir, "img")

    cmdSettingFile = os.path.join(getModulePath(), "configData", "cmdFile",
                                  "opdDefault.cmd")
    instSettingFile = os.path.join(getModulePath(), "configData", "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
    configFilePath = os.path.join(getModulePath(), "configData",
                                  "telescopeConfig", "GT.inst")
    tele = TeleFacade(configFilePath=configFilePath)

    # Subsystem data direction
    camDataDir = os.path.join(getModulePath(), "configData", "camera")
    M1M3dataDir = os.path.join(getModulePath(), "configData", "M1M3")
    M2dataDir = os.path.join(getModulePath(), "configData", "M2")
    tele.setSubSysConfigDir(camDataDir=camDataDir, M1M3dataDir=M1M3dataDir,
                            M2dataDir=M2dataDir, phosimDir=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
    dofInUm = np.zeros(50)

    # Camera dx
    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_9006000_0.fits.gz")
    zk = metr.getZkFromOpd(opdFitsFile=opdFitsFile)[0]
    print(zk)

    wavelengthInUm = tele.WAVELENGTH_IN_NM * 1e-3
    pssn = metr.calcPSSN(wavelengthInUm, opdFitsFile=opdFitsFile)

    print(pssn)
Example #9
0
def main(phosimDir):

    # Settings
    outputDir = os.path.join(getModulePath(), "output")
    outputImgDir = os.path.join(outputDir, "img")

    cmdSettingFile = os.path.join(getModulePath(), "configData", "cmdFile",
                                  "starDefault.cmd")
    instSettingFile = os.path.join(getModulePath(), "configData", "instFile",
                                   "starDefault.inst")

    # Survey information
    obsId = 9006000
    instName = "lsst"
    filterType = FilterType.REF
    ra = 20
    decl = 30
    rotSkyPos = 10
    mjd = 59580.0

    # Declare the SkySim()
    skySim = SkySim()

    # Set the focal plane information
    folderPath2FocalPlane = os.path.join(phosimDir, "data", instName)
    skySim.setFolderPath2FocalPlane(folderPath2FocalPlane)

    # Set the observation information
    skySim.setObservationMetaData(ra, decl, rotSkyPos, mjd)

    # Add the interested stars
    sensorName = "R22_S11"
    starId = [0]
    xInpixelInCam = [3200]
    yInPixelInCam = [3800]
    starMag = [15]
    for ii in range(len(starId)):
        skySim.addStarByChipPos(sensorName, starId[ii], xInpixelInCam[ii],
                                yInPixelInCam[ii], starMag[ii])

    # Set the Telescope facade class
    configFilePath = os.path.join(getModulePath(), "configData",
                                  "telescopeConfig", "GT.inst")
    tele = TeleFacade(configFilePath=configFilePath)
    tele.setSubSysConfigDir(phosimDir=phosimDir)
    tele.setSurveyParam(obsId=obsId,
                        filterType=filterType,
                        boresight=(ra, decl),
                        rotAngInDeg=rotSkyPos,
                        mjd=mjd)
    tele.setInstName(instName)

    # Update the telescope degree of freedom
    dofInUm = np.zeros(50)

    # Camera piston in um
    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,
                                    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)