def createDetector(nAmpX, nAmpY, nPixX, nPixY, pre, hOscan, vOscan, ext, isPerAmp): '''!Fill ampInfo tables \param[in] nAmpX -- Number of amps in the x direction \param[in] nAmpY -- Number of amps in the y direction \param[in] nPixX -- Number of pixels in the amp in the x direction \param[in] nPixY -- Number of pixels in the amp in the y direction \param[in] pre -- Number of prescan rows \param[in] hOscan -- Number of horizontal overscan columns \param[in] vOscan -- Number of vertical overscan rows \param[in] ext -- Number of pixels in the extended register \param[in] isPerAmp -- Are the raw amp data in separate images? \return an lsst.afw.cameraGeom.Detector object ''' schema = afwTable.AmpInfoTable.makeMinimalSchema() ampCatalog = afwTable.AmpInfoCatalog(schema) flipy = True for iy in range(nAmpY): flipy = not flipy flipx = True for ix in range(nAmpX): flipx = not flipx record = ampCatalog.addNew() populateAmpBoxes(nPixX, nPixY, pre, hOscan, vOscan, ext, flipx, flipy, ix, iy, isPerAmp, record) record.setGain(ix + iy * nAmpX + 1.) detConfig = DetectorConfig() detConfig.name = 'TestDetector' detConfig.id = 0 detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = nAmpX * nPixX - 1 detConfig.bbox_y1 = nAmpY * nPixY - 1 detConfig.detectorType = 0 #Science type detConfig.serial = 'THX1138' detConfig.offset_x = 0. detConfig.offset_y = 0. detConfig.refpos_x = nAmpX * nPixX * 0.5 - 0.5 detConfig.refpos_y = nAmpY * nPixY * 0.5 - 0.5 detConfig.yawDeg = 0. detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = 10. / 1000. #in mm detConfig.pixelSize_y = 10. / 1000. #in mm detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() fpTransform = afwGeom.xyTransformRegistry['identity']() plateScale = 1. return makeDetector(detConfig, ampCatalog, fpTransform, plateScale)
def makeDetectorConfigs(detectorLayoutFile): """ Create the detector configs to use in building the Camera @param detectorLayoutFile -- String describing where the focalplanelayout.txt file is located. """ detectorConfigs = [] xsize = 2048 ysize = 4096 #Only do Science detectors right now. #There is an overall 0.05 deg rotation to the entire focal plane that I'm ignoring here. with open(detectorLayoutFile) as fh: fh.readline() for l in fh: els = l.rstrip().split() detectorName = els[1] #skip focus and guiding for now: if detectorName[0] in ('F', 'G'): continue detConfig = DetectorConfig() detConfig.name = detectorName detConfig.id = int(els[0]) detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = xsize - 1 detConfig.bbox_y1 = ysize - 1 detConfig.detectorType = 0 detConfig.serial = els[0] # Convert from microns to mm. detConfig.offset_x = (float(els[2]) + float(els[3]))/2. detConfig.offset_y = (float(els[4]) + float(els[5]))/2. detConfig.refpos_x = (xsize - 1.)/2. detConfig.refpos_y = (ysize - 1.)/2. # TODO translate between John's angles and Orientation angles. # It's not an issue now because there is no rotation except about z in John's model. detConfig.yawDeg = float(els[6]) detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = 0.015 detConfig.pixelSize_y = 0.015 detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() # The FOCAL_PLANE and TAN_PIXEL transforms are generated by the Camera maker, # based on orientaiton and other data. # Any additional transforms (such as ACTUAL_PIXELS) should be inserted here. detectorConfigs.append(detConfig) return detectorConfigs
def createDetector(nAmpX, nAmpY, nPixX, nPixY, pre, hOscan, vOscan, ext, isPerAmp): '''!Fill ampInfo tables \param[in] nAmpX -- Number of amps in the x direction \param[in] nAmpY -- Number of amps in the y direction \param[in] nPixX -- Number of pixels in the amp in the x direction \param[in] nPixY -- Number of pixels in the amp in the y direction \param[in] pre -- Number of prescan rows \param[in] hOscan -- Number of horizontal overscan columns \param[in] vOscan -- Number of vertical overscan rows \param[in] ext -- Number of pixels in the extended register \param[in] isPerAmp -- Are the raw amp data in separate images? \return an lsst.afw.cameraGeom.Detector object ''' schema = afwTable.AmpInfoTable.makeMinimalSchema() ampCatalog = afwTable.AmpInfoCatalog(schema) flipy = True for iy in range(nAmpY): flipy = not flipy flipx = True for ix in range(nAmpX): flipx = not flipx record = ampCatalog.addNew() populateAmpBoxes(nPixX, nPixY, pre, hOscan, vOscan, ext, flipx, flipy, ix, iy, isPerAmp, record) record.setGain(ix+iy*nAmpX+1.) detConfig = DetectorConfig() detConfig.name = 'TestDetector' detConfig.id = 0 detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = nAmpX*nPixX - 1 detConfig.bbox_y1 = nAmpY*nPixY - 1 detConfig.detectorType = 0 #Science type detConfig.serial = 'THX1138' detConfig.offset_x = 0. detConfig.offset_y = 0. detConfig.refpos_x = nAmpX*nPixX*0.5 - 0.5 detConfig.refpos_y = nAmpY*nPixY*0.5 - 0.5 detConfig.yawDeg = 0. detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = 10./1000. #in mm detConfig.pixelSize_y = 10./1000. #in mm detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() fpTransform = afwGeom.xyTransformRegistry['identity']() plateScale = 1. return makeDetector(detConfig, ampCatalog, fpTransform, plateScale)
def makeDetectorConfigs(detectorLayoutFile): """ Create the detector configs to use in building the Camera @param detectorLayoutFile -- String describing where the focalplanelayout.txt file is located. """ detectorConfigs = [] xsize = 2048 ysize = 4096 # Only do Science detectors right now. # There is an overall 0.05 deg rotation to the entire focal plane that I'm ignoring here. with open(detectorLayoutFile) as fh: fh.readline() for l in fh: els = l.rstrip().split() detectorName = els[1] # skip focus and guiding for now: if detectorName[0] in ('F', 'G'): continue detConfig = DetectorConfig() detConfig.name = detectorName detConfig.id = int(els[0]) detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = xsize - 1 detConfig.bbox_y1 = ysize - 1 detConfig.detectorType = 0 detConfig.serial = els[0] # Convert from microns to mm. detConfig.offset_x = (float(els[2]) + float(els[3]))/2. detConfig.offset_y = (float(els[4]) + float(els[5]))/2. detConfig.refpos_x = (xsize - 1.)/2. detConfig.refpos_y = (ysize - 1.)/2. # TODO translate between John's angles and Orientation angles. # It's not an issue now because there is no rotation except about z in John's model. detConfig.yawDeg = float(els[6]) detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = 0.015 detConfig.pixelSize_y = 0.015 detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() # The FOCAL_PLANE and TAN_PIXEL transforms are generated by the Camera maker, # based on orientaiton and other data. # Any additional transforms (such as ACTUAL_PIXELS) should be inserted here. detectorConfigs.append(detConfig) return detectorConfigs
def makeDetectorConfigs(detectorLayoutFile, phosimVersion): """ Create the detector configs to use in building the Camera @param detectorLayoutFile -- String describing where the focalplanelayout.txt file is located. @todo: * set serial to something other than name (e.g. include git sha) * deal with the extra orientation angles (not that they really matter) """ detectorConfigs = [] detType = int(SCIENCE) #We know we need to rotate 3 times and also apply the yaw perturbation nQuarter = 1 with open(detectorLayoutFile) as fh: for l in fh: if l.startswith("#"): continue detConfig = DetectorConfig() els = l.rstrip().split() detConfig.name = expandDetectorName(els[0]) detConfig.id = detectorIdFromAbbrevName(els[0]) detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = int(els[5]) - 1 detConfig.bbox_y1 = int(els[4]) - 1 detConfig.detectorType = detType detConfig.serial = els[0]+"_"+phosimVersion # Convert from microns to mm. detConfig.offset_x = float(els[1])/1000. + float(els[12]) detConfig.offset_y = float(els[2])/1000. + float(els[13]) detConfig.refpos_x = (int(els[5]) - 1.)/2. detConfig.refpos_y = (int(els[4]) - 1.)/2. # TODO translate between John's angles and Orientation angles. # It's not an issue now because there is no rotation except about z in John's model. detConfig.yawDeg = 90.*nQuarter + float(els[9]) detConfig.pitchDeg = float(els[10]) detConfig.rollDeg = float(els[11]) detConfig.pixelSize_x = float(els[3])/1000. detConfig.pixelSize_y = float(els[3])/1000. detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() # The FOCAL_PLANE and TAN_PIXEL transforms are generated by the Camera maker, # based on orientaiton and other data. # Any additional transforms (such as ACTUAL_PIXELS) should be inserted here. detectorConfigs.append(detConfig) return detectorConfigs
def makeDetectorConfigs(detectorLayoutFile, phosimVersion): """ Create the detector configs to use in building the Camera @param detectorLayoutFile -- String describing where the focalplanelayout.txt file is located. @todo: * set serial to something other than name (e.g. include git sha) * deal with the extra orientation angles (not that they really matter) """ detectorConfigs = [] detTypeMap = {"Group2":2, "Group1":3, "Group0":0} #We know we need to rotate 3 times and also apply the yaw perturbation nQuarter = 1 with open(detectorLayoutFile) as fh: for l in fh: if l.startswith("#"): continue detConfig = DetectorConfig() els = l.rstrip().split() detConfig.name = expandDetectorName(els[0]) detConfig.id = detectorIdFromAbbrevName(els[0]) detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = int(els[5]) - 1 detConfig.bbox_y1 = int(els[4]) - 1 detConfig.detectorType = detTypeMap[els[8]] detConfig.serial = els[0]+"_"+phosimVersion # Convert from microns to mm. detConfig.offset_x = float(els[1])/1000. + float(els[12]) detConfig.offset_y = float(els[2])/1000. + float(els[13]) detConfig.refpos_x = (int(els[5]) - 1.)/2. detConfig.refpos_y = (int(els[4]) - 1.)/2. # TODO translate between John's angles and Orientation angles. # It's not an issue now because there is no rotation except about z in John's model. detConfig.yawDeg = 90.*nQuarter + float(els[9]) detConfig.pitchDeg = float(els[10]) detConfig.rollDeg = float(els[11]) detConfig.pixelSize_x = float(els[3])/1000. detConfig.pixelSize_y = float(els[3])/1000. detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() # The FOCAL_PLANE and TAN_PIXEL transforms are generated by the Camera maker, # based on orientaiton and other data. # Any additional transforms (such as ACTUAL_PIXELS) should be inserted here. detectorConfigs.append(detConfig) return detectorConfigs
def makeCcd(ccdName, ccdId, offsetPoint): """make the information necessary to build a set detector @param ccdName: string name of the ccd @param ccdId: Integer id of the ccd @param offsetPoint: Point2D position of the center of the ccd in mm @return a dict of a DetectorConfig and an AmpInfoCatalog """ obsSdssDir = lsst.utils.getPackageDir('obs_sdss') opDir = os.path.join(obsSdssDir, "etc") sc = SdssCameraState(opDir, "opConfig-50000.par", "opECalib-50000.par") eparams = sc.getEParams(ccdName) width = 1024 * 2 height = 1361 pixelSize = 24e-3 # pixel size in mm schema = afwTable.AmpInfoTable.makeMinimalSchema() ampCatalog = afwTable.AmpInfoCatalog(schema) for i in range(2): addAmp(ampCatalog, i, eparams[i][1]) detConfig = DetectorConfig() detConfig.name = ccdName detConfig.id = ccdId detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = width - 1 detConfig.bbox_y1 = height - 1 detConfig.serial = ccdName detConfig.detectorType = SCIENCE detConfig.offset_x = offsetPoint.getX() detConfig.offset_y = offsetPoint.getY() detConfig.refpos_x = (width - 1) / 2. detConfig.refpos_y = (height - 1) / 2. detConfig.yawDeg = 0. detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = pixelSize detConfig.pixelSize_y = pixelSize detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() return {'ccdConfig': detConfig, 'ampInfo': ampCatalog}
def makeCcd(ccdName, ccdId, offsetPoint): """make the information necessary to build a set detector @param ccdName: string name of the ccd @param ccdId: Integer id of the ccd @param offsetPoint: Point2D position of the center of the ccd in mm @return a dict of a DetectorConfig and an AmpInfoCatalog """ obsSdssDir = lsst.utils.getPackageDir('obs_sdss') opDir = os.path.join(obsSdssDir, "etc") sc = SdssCameraState(opDir, "opConfig-50000.par", "opECalib-50000.par") eparams = sc.getEParams(ccdName) width = 1024*2 height = 1361 pixelSize = 24e-3 # pixel size in mm schema = afwTable.AmpInfoTable.makeMinimalSchema() ampCatalog = afwTable.AmpInfoCatalog(schema) for i in range(2): addAmp(ampCatalog, i, eparams[i][1]) detConfig = DetectorConfig() detConfig.name = ccdName detConfig.id = ccdId detConfig.bbox_x0 = 0 detConfig.bbox_y0 = 0 detConfig.bbox_x1 = width - 1 detConfig.bbox_y1 = height - 1 detConfig.serial = ccdName detConfig.detectorType = SCIENCE detConfig.offset_x = offsetPoint.getX() detConfig.offset_y = offsetPoint.getY() detConfig.refpos_x = (width-1)/2. detConfig.refpos_y = (height-1)/2. detConfig.yawDeg = 0. detConfig.pitchDeg = 0. detConfig.rollDeg = 0. detConfig.pixelSize_x = pixelSize detConfig.pixelSize_y = pixelSize detConfig.transposeDetector = False detConfig.transformDict.nativeSys = PIXELS.getSysName() return {'ccdConfig': detConfig, 'ampInfo': ampCatalog}