def ReturnCamera(baseDir):
    """
    This method reads in the files

    baseDir/focalplanelayout.txt
    baseDir/segmentation.txt

    and returns an afw.cameraGeom object

    Below is the original documentation of the function this code was copied from:

    Create the configs for building a camera.  This runs on the files distributed with PhoSim.  Currently gain and
    saturation need to be supplied as well.  The file should have three columns: on disk amp id (R22_S11_C00), gain, saturation.
    For example:
    DetectorLayoutFile -- https://dev.lsstcorp.org/cgit/LSST/sims/phosim.git/plain/data/lsst/focalplanelayout.txt?h=dev
    SegmentsFile -- https://dev.lsstcorp.org/cgit/LSST/sims/phosim.git/plain/data/lsst/segmentation.txt?h=dev
    """
    defaultOutDir = 'scratch'

    DetectorLayoutFile = os.path.join(baseDir, 'focalplanelayout.txt')
    SegmentsFile = os.path.join(baseDir, 'segmentation.txt')
    GainFile = None
    phosimVersion='1.0'

    ampTableDict = makeAmpTables(SegmentsFile, GainFile)
    detectorConfigList = makeDetectorConfigs(DetectorLayoutFile, phosimVersion)

    #Build the camera config.
    camConfig = CameraConfig()
    camConfig.detectorList = dict([(i,detectorConfigList[i]) for i in range(len(detectorConfigList))])
    camConfig.name = 'LSST'
    camConfig.plateScale = 2.0 #arcsec per mm
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    pincushion = 0.925
    # Don't have this yet ticket/3155
    #camConfig.boresiteOffset_x = 0.
    #camConfig.boresiteOffset_y = 0.
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'inverted'
    radialClass = afwGeom.xyTransformRegistry['radial']
    tConfig.transform.active.transform.retarget(radialClass)
    # According to Dave M. the simulated LSST transform is well approximated (1/3 pix)
    # by a scale and a pincusion.

    #this is ultimately used to convert from focal plane coordinates to pupil coordinates
    #see the asgnment below to tmc.transforms
    tConfig.transform.active.transform.coeffs = [0., 1./pScaleRad, 0., pincushion/pScaleRad]

    #tConfig.transform.active.boresiteOffset_x = camConfig.boresiteOffset_x
    #tConfig.transform.active.boresiteOffset_y = camConfig.boresiteOffset_y
    tmc = afwGeom.TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()
    tmc.transforms = {PUPIL.getSysName():tConfig}
    camConfig.transformDict = tmc

    myCamera = makeCameraFromCatalogs(camConfig, ampTableDict)
    return myCamera
def ReturnCamera(baseDir):
    """
    This method reads in the files

    baseDir/focalplanelayout.txt
    baseDir/segmentation.txt

    and returns an afw.cameraGeom object

    Below is the original documentation of the function this code was copied from:

    Create the configs for building a camera.  This runs on the files distributed with PhoSim.  Currently gain and
    saturation need to be supplied as well.  The file should have three columns: on disk amp id (R22_S11_C00), gain, saturation.
    For example:
    DetectorLayoutFile -- https://dev.lsstcorp.org/cgit/LSST/sims/phosim.git/plain/data/lsst/focalplanelayout.txt?h=dev
    SegmentsFile -- https://dev.lsstcorp.org/cgit/LSST/sims/phosim.git/plain/data/lsst/segmentation.txt?h=dev
    """
    defaultOutDir = 'scratch'

    DetectorLayoutFile = os.path.join(baseDir, 'focalplanelayout.txt')
    SegmentsFile = os.path.join(baseDir, 'segmentation.txt')
    GainFile = None
    phosimVersion='1.0'

    ampTableDict = makeAmpTables(SegmentsFile, GainFile)
    detectorConfigList = makeDetectorConfigs(DetectorLayoutFile, phosimVersion)

    #Build the camera config.
    camConfig = CameraConfig()
    camConfig.detectorList = dict([(i,detectorConfigList[i]) for i in xrange(len(detectorConfigList))])
    camConfig.name = 'LSST'
    camConfig.plateScale = 2.0 #arcsec per mm
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    pincushion = 0.925
    # Don't have this yet ticket/3155
    #camConfig.boresiteOffset_x = 0.
    #camConfig.boresiteOffset_y = 0.
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'inverted'
    radialClass = afwGeom.xyTransformRegistry['radial']
    tConfig.transform.active.transform.retarget(radialClass)
    # According to Dave M. the simulated LSST transform is well approximated (1/3 pix)
    # by a scale and a pincusion.

    #this is ultimately used to convert from focal plane coordinates to pupil coordinates
    #see the asgnment below to tmc.transforms
    tConfig.transform.active.transform.coeffs = [0., 1./pScaleRad, 0., pincushion/pScaleRad]

    #tConfig.transform.active.boresiteOffset_x = camConfig.boresiteOffset_x
    #tConfig.transform.active.boresiteOffset_y = camConfig.boresiteOffset_y
    tmc = afwGeom.TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()
    tmc.transforms = {PUPIL.getSysName():tConfig}
    camConfig.transformDict = tmc

    myCamera = makeCameraFromCatalogs(camConfig, ampTableDict)
    return myCamera
Example #3
0
def makeCamera(name="SDSS", outputDir=None):
    """Make a camera
    @param name: name of the camera
    @param outputDir: If not None, write the objects used to make the camera to this location
    @return a camera object
    """
    camConfig = CameraConfig()
    camConfig.name = name
    camConfig.detectorList = {}
    camConfig.plateScale = 16.5  # arcsec/mm
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    radialDistortCoeffs = [0.0, 1.0 / pScaleRad]
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'inverted'
    radialClass = afwGeom.xyTransformRegistry['radial']
    tConfig.transform.active.transform.retarget(radialClass)
    tConfig.transform.active.transform.coeffs = radialDistortCoeffs
    tmc = afwGeom.TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()
    tmc.transforms = {PUPIL.getSysName(): tConfig}
    camConfig.transformDict = tmc

    ccdId = 0
    ampInfoCatDict = {}
    for i in range(6):
        dewarName = str(i + 1)
        filters = "riuzg"
        for j, c in enumerate(reversed(filters)):
            ccdName = "%s%s" % (c, dewarName)
            offsetPoint = afwGeom.Point2D(25.4 * 2.5 * (2.5 - i),
                                          25.4 * 2.1 * (2.0 - j))
            ccdInfo = makeCcd(ccdName, ccdId, offsetPoint)
            ampInfoCatDict[ccdName] = ccdInfo['ampInfo']
            camConfig.detectorList[ccdId] = ccdInfo['ccdConfig']
            ccdId += 1
    if outputDir is not None:
        camConfig.save(os.path.join(outputDir, 'camera.py'))
        for k in ampInfoCatDict:
            ampInfoCatDict[k].writeFits(
                os.path.join(outputDir, "%s.fits" % (k)))
    return makeCameraFromCatalogs(camConfig, ampInfoCatDict)
Example #4
0
def makeCamera(name="SDSS", outputDir=None):
    """Make a camera
    @param name: name of the camera
    @param outputDir: If not None, write the objects used to make the camera to this location
    @return a camera object
    """
    camConfig = CameraConfig()
    camConfig.name = name
    camConfig.detectorList = {}
    camConfig.plateScale = 16.5  # arcsec/mm
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    radialDistortCoeffs = [0.0, 1.0/pScaleRad]
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'inverted'
    radialClass = afwGeom.transformRegistry['radial']
    tConfig.transform.active.transform.retarget(radialClass)
    tConfig.transform.active.transform.coeffs = radialDistortCoeffs
    tmc = TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()
    tmc.transforms = {FIELD_ANGLE.getSysName(): tConfig}
    camConfig.transformDict = tmc

    ccdId = 0
    ampInfoCatDict = {}
    for i in range(6):
        dewarName = str(i+1)
        filters = "riuzg"
        for j, c in enumerate(reversed(filters)):
            ccdName = "%s%s" % (c, dewarName)
            offsetPoint = afwGeom.Point2D(25.4*2.5*(2.5-i), 25.4*2.1*(2.0 - j))
            ccdInfo = makeCcd(ccdName, ccdId, offsetPoint)
            ampInfoCatDict[ccdName] = ccdInfo['ampInfo']
            camConfig.detectorList[ccdId] = ccdInfo['ccdConfig']
            ccdId += 1
    if outputDir is not None:
        camConfig.save(os.path.join(outputDir, 'camera.py'))
        for k in ampInfoCatDict:
            ampInfoCatDict[k].writeFits(os.path.join(outputDir, "%s.fits"%(k)))
    return makeCameraFromCatalogs(camConfig, ampInfoCatDict)
    parser.add_argument("DetectorLayoutFile", help="Path to detector layout file")
    parser.add_argument("SegmentsFile", help="Path to amp segments file")
    parser.add_argument("OutputDir",
        help = "Path to dump configs and AmpInfo Tables; defaults to %r" % (defaultOutDir,),
        nargs = "?",
        default = defaultOutDir,
    )
    parser.add_argument("--clobber", action="store_true", dest="clobber", default=False,
        help=("remove and re-create the output directory if it already exists?"))
    args = parser.parse_args()
    ampTableDict = makeAmpTables(args.SegmentsFile)
    detectorConfigList = makeDetectorConfigs(args.DetectorLayoutFile)

    #Build the camera config.
    camConfig = CameraConfig() 
    camConfig.detectorList = dict([(i,detectorConfigList[i]) for i in xrange(len(detectorConfigList))])
    camConfig.name = 'DECAM'
    #From DECam calibration doc
    camConfig.plateScale = 17.575
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'radial'
    nomWavelen =  0.625 #nominal wavelen in microns
    coeff0 = 0
    coeff1 = 1 - 2.178e-4 - 2.329e-4/nomWavelen + 4.255e-5/nomWavelen**2
    coeff2 = 0
    coeff3 = -6.174e-8 + 5.569e-9/nomWavelen
    tConfig.transform.active.coeffs = [pScaleRad*coeff0, pScaleRad*coeff1, pScaleRad*coeff2,
                                       pScaleRad*coeff3]
    tmc = afwGeom.TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()
    parser.add_argument("DetectorLayoutFile", help="Path to detector layout file")
    parser.add_argument("SegmentsFile", help="Path to amp segments file")
    parser.add_argument("OutputDir",
                        help="Path to dump configs and AmpInfo Tables; defaults to %r" % (defaultOutDir,),
                        nargs="?",
                        default=defaultOutDir,
                        )
    parser.add_argument("--clobber", action="store_true", dest="clobber", default=False,
                        help=("remove and re-create the output directory if it already exists?"))
    args = parser.parse_args()
    ampTableDict = makeAmpTables(args.SegmentsFile)
    detectorConfigList = makeDetectorConfigs(args.DetectorLayoutFile)

    # Build the camera config.
    camConfig = CameraConfig()
    camConfig.detectorList = dict([(i, detectorConfigList[i]) for i in range(len(detectorConfigList))])
    camConfig.name = 'DECAM'
    # From DECam calibration doc
    camConfig.plateScale = 17.575
    pScaleRad = afwGeom.arcsecToRad(camConfig.plateScale)
    tConfig = afwGeom.TransformConfig()
    tConfig.transform.name = 'radial'
    nomWavelen = 0.625  # nominal wavelen in microns
    coeff0 = 0
    coeff1 = 1 - 2.178e-4 - 2.329e-4/nomWavelen + 4.255e-5/nomWavelen**2
    coeff2 = 0
    coeff3 = -6.174e-8 + 5.569e-9/nomWavelen
    tConfig.transform.active.coeffs = [pScaleRad*coeff0, pScaleRad*coeff1, pScaleRad*coeff2,
                                       pScaleRad*coeff3]
    tmc = afwGeom.TransformMapConfig()
    tmc.nativeSys = FOCAL_PLANE.getSysName()