Skip to content

Commit

Permalink
Use DictField instead
Browse files Browse the repository at this point in the history
  • Loading branch information
plazas committed Nov 10, 2020
1 parent 67ff237 commit 8ef543d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 37 deletions.
22 changes: 14 additions & 8 deletions python/lsst/cp/pipe/makeBrighterFatterKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,21 @@ class MakeBrighterFatterKernelTaskConfig(pexConfig.Config):
doc="The key by which to pull a detector from a dataId, e.g. 'ccd' or 'detector'",
default='ccd',
)
minMeanSignal = pexConfig.Field(
dtype=float,
doc="Minimum value of mean signal (in ADU) to consider.",
default=0,
minMeanSignal = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Minimum values (inclusive) of mean signal (in ADU) above which to consider, per amp."
" The same cut is applied to all amps if this dictionary is of the form"
" {'ALL_AMPS': value}",
default={'ALL_AMPS': 0.0},
)
maxMeanSignal = pexConfig.Field(
dtype=float,
doc="Maximum value to of mean signal (in ADU) to consider.",
default=9e6,
maxMeanSignal = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Maximum values (inclusive) of mean signal (in ADU) below which to consider, per amp."
" The same cut is applied to all amps if this dictionary is of the form"
" {'ALL_AMPS': value}",
default={'ALL_AMPS': 1e6},
)
maxIterRegression = pexConfig.Field(
dtype=int,
Expand Down
51 changes: 22 additions & 29 deletions python/lsst/cp/pipe/ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,21 @@ class MeasurePhotonTransferCurveTaskConfig(pexConfig.Config):
doc="Bin the image by this factor in both dimensions.",
default=1,
)
minMeanSignal = pexConfig.Field(
dtype=str,
minMeanSignal = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Minimum values (inclusive) of mean signal (in ADU) above which to consider, per amp."
" Expected format: AMPNAME:VALUE^AMPNAME:VALUE...^AMPNAME:VALUE. Default: 0 ADU",
default='',
" The same cut is applied to all amps if this dictionary is of the form"
" {'ALL_AMPS': value}",
default={'ALL_AMPS': 0.0},
)
maxMeanSignal = pexConfig.Field(
dtype=str,
maxMeanSignal = pexConfig.DictField(
keytype=str,
itemtype=float,
doc="Maximum values (inclusive) of mean signal (in ADU) below which to consider, per amp."
" Expected format: AMPNAME:VALUE^AMPNAME:VALUE...^AMPNAME:VALUE. Default: 1e6 ADU",
default='',
" The same cut is applied to all amps if this dictionary is of the form"
" {'ALL_AMPS': value}",
default={'ALL_AMPS': 1e6},
)
initialNonLinearityExclusionThresholdPositive = pexConfig.RangeField(
dtype=float,
Expand Down Expand Up @@ -295,29 +299,18 @@ def runDataRef(self, dataRefList):
for ampName in ampNames:
datasetPtc.inputExpIdPairs[ampName] = expIds

maxMeanSignalSplit = self.config.maxMeanSignal.split('^')
minMeanSignalSplit = self.config.minMeanSignal.split('^')
# Set defaults
maxMeanSignalDict = {ampName: 1e6 for ampName in ampNames}
minMeanSignalDict = {ampName: 0.0 for ampName in ampNames}

for ampCutoff in maxMeanSignalSplit:
ampName = ampCutoff.split(":")[0]
value = float(ampCutoff.split(":")[1])
# Overwrite default cutoff
if ampName in maxMeanSignalDict and ampName != 'DEFAULT':
maxMeanSignalDict[ampName] = value
else:
self.log.warn(f"{ampName} from maxMeanSignal not in list of detector ampNames.")

for ampCutoff in minMeanSignalSplit:
ampName = ampCutoff.split(":")[0]
value = float(ampCutoff.split(":")[1])
# Overwrite default cutoff
if ampName in minMeanSignalDict and ampName != 'DEFAULT':
minMeanSignalDict[ampName] = value
else:
self.log.warn(f"{ampName} from minMeanSignal not in list of detector ampNames.")
for ampName in ampNames:
if 'ALL_AMPS' in self.config.maxMeanSignal:
maxMeanSignalDict[ampName] = self.config.maxMeanSignal['ALL_AMPS']
elif ampName in self.config.maxMeanSignal:
maxMeanSignalDict[ampName] = self.config.maxMeanSignal[ampName]

if 'ALL_AMPS' in self.config.minMeanSignal:
minMeanSignalDict[ampName] = self.config.minMeanSignal['ALL_AMPS']
elif ampName in self.config.minMeanSignal:
minMeanSignalDict[ampName] = self.config.minMeanSignal[ampName]

tupleRecords = []
allTags = []
Expand Down

0 comments on commit 8ef543d

Please sign in to comment.