Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-18610: Add fields, limited mutability, and trim/assembly-state tracking to cameraGeom #89

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 40 additions & 27 deletions bin.src/makeLsstCameraRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import lsst.afw.geom as afwGeom
import lsst.afw.table as afwTable
from lsst.afw.cameraGeom import DetectorConfig, CameraConfig, \
TransformMapConfig, FIELD_ANGLE, FOCAL_PLANE, PIXELS, NullLinearityType
TransformMapConfig, FIELD_ANGLE, FOCAL_PLANE, PIXELS, NullLinearityType, \
ReadoutCorner, Amplifier
import lsst.geom as geom
from lsst.obs.lsstSim import LsstSimMapper

Expand Down Expand Up @@ -88,8 +89,12 @@ def makeAmpTables(segmentsFile, gainFile):
# how to get this information.
linearityCoeffs = (0., 1., 0., 0.)
linearityType = NullLinearityType
readoutMap = {'LL': afwTable.LL, 'LR': afwTable.LR, 'UR': afwTable.UR, 'UL': afwTable.UL}
ampCatalog = None
readoutMap = {'LL': ReadoutCorner.LL,
'LR': ReadoutCorner.LR,
'UR': ReadoutCorner.UR,
'UL': ReadoutCorner.UL}

ampCatalog = []
detectorName = [] # set to a value that is an invalid dict key, to catch bugs
correctY0 = False
with open(segmentsFile) as fh:
Expand All @@ -99,18 +104,18 @@ def makeAmpTables(segmentsFile, gainFile):

els = l.rstrip().split()
if len(els) == 4:
if ampCatalog is not None:
if len(ampCatalog) != 0:
returnDict[detectorName] = ampCatalog
detectorName = expandDetectorName(els[0])
numy = int(els[2])
schema = afwTable.AmpInfoTable.makeMinimalSchema()
ampCatalog = afwTable.AmpInfoCatalog(schema)

ampCatalog = []
if len(els[0].split('_')) == 3: # wavefront sensor
correctY0 = True
else:
correctY0 = False
continue
record = ampCatalog.addNew()
amplifier = Amplifier.Builder()
name = els[0].split("_")[-1]
name = '%s,%s'%(name[1], name[2])
# Because of the camera coordinate system, we choose an
Expand Down Expand Up @@ -171,25 +176,26 @@ def makeAmpTables(segmentsFile, gainFile):
extraRawY = prescan + voverscan
rawx0 = x0 + extraRawX*(x0//ndatax)
rawy0 = y0 + extraRawY*(y0//ndatay)
# Set the elements of the record for this amp
record.setBBox(bbox)
record.setName(name)
record.setReadoutCorner(readCorner)
record.setGain(gain)
record.setSaturation(saturation)
record.setSuspectLevel(float("nan"))
record.setReadNoise(readnoise)
record.setLinearityCoeffs(linearityCoeffs)
record.setLinearityType(linearityType)
record.setHasRawInfo(True)
record.setRawFlipX(flipx)
record.setRawFlipY(flipy)
record.setRawBBox(rawBBox)
record.setRawXYOffset(geom.Extent2I(rawx0, rawy0))
record.setRawDataBBox(rawDataBBox)
record.setRawHorizontalOverscanBBox(rawHorizontalOverscanBBox)
record.setRawVerticalOverscanBBox(rawVerticalOverscanBBox)
record.setRawPrescanBBox(rawPrescanBBox)
# Set the elements of the amplifier for this amp
amplifier.setBBox(bbox)
amplifier.setName(name)
amplifier.setReadoutCorner(readCorner)
amplifier.setGain(gain)
amplifier.setSaturation(saturation)
amplifier.setSuspectLevel(float("nan"))
amplifier.setReadNoise(readnoise)
amplifier.setLinearityCoeffs(linearityCoeffs)
amplifier.setLinearityType(linearityType)
# amplifier.setHasRawInfo(True)
amplifier.setRawFlipX(flipx)
amplifier.setRawFlipY(flipy)
amplifier.setRawBBox(rawBBox)
amplifier.setRawXYOffset(geom.Extent2I(rawx0, rawy0))
amplifier.setRawDataBBox(rawDataBBox)
amplifier.setRawHorizontalOverscanBBox(rawHorizontalOverscanBBox)
amplifier.setRawVerticalOverscanBBox(rawVerticalOverscanBBox)
amplifier.setRawPrescanBBox(rawPrescanBBox)
ampCatalog.append(amplifier)
returnDict[detectorName] = ampCatalog
return returnDict

Expand Down Expand Up @@ -363,4 +369,11 @@ def makeDir(dirPath, doClobber=False):
for detectorName, ampTable in ampTableDict.items():
shortDetectorName = LsstSimMapper.getShortCcdName(detectorName)
ampInfoPath = os.path.join(outDir, shortDetectorName + ".fits")
ampTable.writeFits(ampInfoPath)
protoTypeSchema = lsst.afw.cameraGeom.Amplifier.getRecordSchema()
detectorTable = afwTable.BaseCatalog(protoTypeSchema)
for amp in ampTable:
record = detectorTable.makeRecord()
tempAmp = amp.finish()
tempAmp.toRecord(record)
detectorTable.append(record)
detectorTable.writeFits(filename=ampInfoPath)
1 change: 1 addition & 0 deletions config/isr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
LSST Sim-specific overrides for IsrTask
"""
config.doFlat = False
config.doLinearize = False

3 changes: 3 additions & 0 deletions python/lsst/obs/lsstSim/lsstSimMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ def map_defects(self, dataId, write=False):
dataId, self,
storage=self.rootStorage)

def map_linearizer(self, dataId, write=False):
return None

def bypass_defects(self, datasetType, pythonType, butlerLocation, dataId):
"""Return a defect based on the butler location returned by map_defects

Expand Down
2 changes: 2 additions & 0 deletions tests/test_lsstSimIsrTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def testRunDataRef(self):
config.doFringe = False
config.doAssembleCcd = False
config.doSnapCombine = False
config.doLinearize = False
lsstIsrTask = LsstSimIsrTask(config=config)
exposure = lsstIsrTask.runDataRef(self.ampRef).exposure
self.assertAlmostEqual(afwMath.makeStatistics(exposure.getMaskedImage(), afwMath.MEAN).getValue(),
Expand All @@ -70,6 +71,7 @@ def testRun(self):
config.doFringe = False
config.doAssembleCcd = False
config.doSnapCombine = False
config.doLinearize = False
lsstIsrTask = LsstSimIsrTask(config=config)
ampExp = self.ampRef.get('raw')
camera = self.ampRef.get("camera")
Expand Down