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)
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)
camConfig.transformDict = tmc def makeDir(dirPath, doClobber=False): """Make a directory; if it exists then clobber or fail, depending on doClobber @param[in] dirPath: path of directory to create @param[in] doClobber: what to do if dirPath already exists: if True and dirPath is a dir, then delete it and recreate it, else raise an exception @throw RuntimeError if dirPath exists and doClobber False """ if os.path.exists(dirPath): if doClobber and os.path.isdir(dirPath): print "Clobbering directory %r" % (dirPath,) shutil.rmtree(dirPath) else: raise RuntimeError("Directory %r exists" % (dirPath,)) print "Creating directory %r" % (dirPath,) os.makedirs(dirPath) # write data products outDir = args.OutputDir makeDir(dirPath=outDir, doClobber=args.clobber) camConfigPath = os.path.join(outDir, "camera.py") camConfig.save(camConfigPath) for detectorName, ampTable in ampTableDict.iteritems(): shortDetectorName = DecamMapper.getShortCcdName(detectorName) ampInfoPath = os.path.join(outDir, shortDetectorName + ".fits") ampTable.writeFits(ampInfoPath)
camConfig.transformDict = tmc def makeDir(dirPath, doClobber=False): """Make a directory; if it exists then clobber or fail, depending on doClobber @param[in] dirPath: path of directory to create @param[in] doClobber: what to do if dirPath already exists: if True and dirPath is a dir, then delete it and recreate it, else raise an exception @throw RuntimeError if dirPath exists and doClobber False """ if os.path.exists(dirPath): if doClobber and os.path.isdir(dirPath): print("Clobbering directory %r" % (dirPath,)) shutil.rmtree(dirPath) else: raise RuntimeError("Directory %r exists" % (dirPath,)) print("Creating directory %r" % (dirPath,)) os.makedirs(dirPath) # write data products outDir = args.OutputDir makeDir(dirPath=outDir, doClobber=args.clobber) camConfigPath = os.path.join(outDir, "camera.py") camConfig.save(camConfigPath) for detectorName, ampTable in ampTableDict.items(): shortDetectorName = DecamMapper.getShortCcdName(detectorName) ampInfoPath = os.path.join(outDir, shortDetectorName + ".fits") ampTable.writeFits(ampInfoPath)