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-30169: Define flat tests for cp_verify #5

Merged
merged 6 commits into from Sep 8, 2021
Merged

Conversation

czwa
Copy link
Collaborator

@czwa czwa commented Aug 25, 2021

This defines an initial set of flat verification tests:

  1. Per amplfier noise should be consistent with a Poissonian distribution.
  2. Amplifiers on one detector should have the same mean level.
  3. Detectors in an exposure should have the same mean level.

Additional helper code is added, as well as the ability to measure per-exposure statistics.

@czwa czwa requested a review from plazas August 25, 2021 21:46
Copy link
Contributor

@plazas plazas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good; I just left a few comments regarding clarification.

connections.ccdExposure: 'raw'
connections.outputExposure: 'verifyDefectProc'
overscan.fitType: 'MEDIAN_PER_ROW'
doWrite: True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe once Nate told me that booleans in the YAML scripts should start with lowercase. I'm not sure if there's anything official in the guide (I think not), and I might have seen both conventions, so I'll leave it at your discretion :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if you run yamllint the default is to prefer true for this. Consider adding the yamllint GitHub Action.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added yamllint, pushed, and after fixing things up, it seems to be working. I'll file a ticket to do the same for cp_pipe, as those pipelines were also written by me, and almost certainly have capital letters.

@@ -128,11 +128,14 @@ def run(self, inputStats, camera, inputDims):
outputStats = {}
success = True

mergedStats = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you merging the metrics/stats from all detectors to do an overall statistics test? Or what is the purpose of the merging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of the merge is to allow there to be a hierarchical path from a single top level file (the output of CpVerifyRunMergeTask) that contains a list of all the failures, through the exposure level down to the detector/amp level. The visualization notebooks (which I still need to extend for multi-detector cameras) can start with the top level file, and use that to determine what needs to be examined because of the failure.

for ampName, stats in ampStats.items():
verify = {}

# DMTN-101 Test 10.X: confirm that per-amplifier scatter is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I looking at the wrong version of the DMTN-101 document? https://dmtn-101.lsst.io/ I can't see the definition of the tests that you implement here under section 10.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10.X was my shorthand for "this will be defined in section 10, but isn't formally done yet." I want to get the code written first, because adding/updating tests is easy once the code exists, and getting something running is easier than getting DMTN-101 updates approved.

----------
exposure : `lsst.afw.image.Exposure`
The exposure the statistics are from.
statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name statisticsDictionary is different from statisticsDict in the argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here and elsewhere.

detStats = statisticsDict['DET']

# DMTN-101 Test 10.Y: confirm intra-chip scatter is small.
verifyDet['SCATTER'] = bool(detStats['SCATTER']/detStats['MEAN'] <= 0.05)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition of "small" (0.05) is not expected to be modified? Just pointing that out in case that we want to make it a config parameter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been working with the assumption that once we finish DMTN-101, the tests will be fixed; those will be the criteria we use for calibrations.

The exposure the statistics are from.
statisticsDictionary : `dict` [`str`, `dict` [`str`, scalar]],
Dictionary of measured statistics. The inner dictionary
should have keys that are statistic names (`str`) with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put some examples of the expected statistics names, e.g., "SCATTER", "MEAN", etc.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names are somewhat arbitrary. I didn't want to force the name to equal the afwStatistics string name, as I know there will be metrics that are not calculated from afwStatistics (brighter-fatter will have a size-flux slope as an example).

# Get detector stats:
detectorMeans.append(stats['DET']['MEAN'])

return {'SCATTER': np.stdev(detectorMeans)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we use NumPy and not afw? It doesn't matter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think there'd be any difference. This is a straight standard deviation, so they should be algorithmically identical (no clipping or masking needed).

success = True

# DMTN-101 Test 10.Z: confirm inter-chip scatter is small.
verifyStats['SCATTER'] = bool(statisticsDictionary['EXP']['SCATTER'] <= 0.05)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above about hard-coded 0.05.

@czwa czwa merged commit 6c4860c into master Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants