Skip to content

DM-50376: Add detailed plots#75

Open
Alex-Broughton wants to merge 4 commits intomainfrom
tickets/DM-50376
Open

DM-50376: Add detailed plots#75
Alex-Broughton wants to merge 4 commits intomainfrom
tickets/DM-50376

Conversation

@Alex-Broughton
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@aferte aferte left a comment

Choose a reason for hiding this comment

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

Great work! I have a few comments in the review.
Do you have examples I could look at? One for LSSTCam and one for ComCam or LATISS if possible?
My main worry otherwise is that the general approach of cp verify is to use unified stats and plotting capabilities from analysis_tools but this is implementing its own plots and stats. If @czwa is fine with it, that's fine by me.

Comment thread bin.src/cpv_report.py
import sys

from lsst.cp.verify.report import main
from lsst.cp.verify.cpvReport import main
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the motivation for renaming report? It seems redundant to me, but I also don't mind much - just wondering.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I renamed it so that there is less confusion between the two different "reports"

Comment thread python/lsst/cp/verify/detailedPlots.py Outdated
Comment thread python/lsst/cp/verify/detailedPlots.py
yield from _nested(v)
else:
yield v
return np.asarray(list(_nested(d)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why can't we just use np.array(list(d.values())) instead of this method?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This recurses into d = {'my_favorite_stat' = 1.2345, 'all_stats': {'stat0': 0.0, 'stat1': 1.0, 'stat2': 2.0}} to return [1.2345, 0.0, 1.0, 2.0], although I suspect it's there to handle d = {'detectorNameA': {'ampName0': 0.0, 'ampName1': 1.0}, 'detectorNameB': {'ampName0': 0.0, 'ampName1': -1.0}}.

Comment thread python/lsst/cp/verify/detailedPlots.py Outdated
f"Linearity Turnoff:\n{round(linTurnoff, 1)} adu",
)

ax.set_xlim(-.5e-7, 6.5e-7)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A general comment for the rest of the code: is it ok to give specific values for the limits instead of limits dependent on the data? E.g. would these be good limits for LATISS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For the detailed plots, we want to make sure everything has the same limits, so that when viewing everything together, one can easily find outliers.

<style>
.grid-container {
display: grid;
grid-template-columns: repeat(15, 1fr);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This (and several other settings below) seems specific to LSSTCam. Is it possible to make it so we can use it for other cameras? I am thinking we will want to use this for LATISS as well in the future. If you prefer not to worry about other cameras, then I am fine but we should clarify in the code name and documentation that this is LSSTCam specific.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The detailed viewer is meant for finding outliers in statistics for large numbers of sensors, like in LSSTCam. I don't think we will need the detailed web pages for LATISS. That is why I separated out the plot generation from the web reports. We can make all plots for every instrument, but we only need to make the web reports for LSSTCam. This would work for AuxTel and ComCam though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I updated it so that the web reports are only for LSSTCam. ComCam's done and we won't need the web reports for AuxTel since it is just one sensor.

Comment thread python/lsst/cp/verify/utils.py Outdated
Copy link
Copy Markdown
Collaborator

@czwa czwa left a comment

Choose a reason for hiding this comment

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

Documentation requests, some clarifications where I got confused, and at least one likely typo (the C01/C10 covariance terms).

The concerns mentioned in detailedReport.py:

  1. How long does this take to run to generate plots? The previous version of the cpv_report also attempted to generate all of the plots at once, and it took an infeasible amount of time to run. This led to the analysis_tools-ification, as then we could have tasks to generate all the plots that run as part of the pipeline.
  2. This also solves the issue with getDetailedImages. If the plots are generated as part of the pipeline, then they have butler dataIds themselves, and so each plot type (corresponding to a dataset_type in the butler) can be directly requested from the refs, and used to build the report.
  3. I'm generally worried about diverging cpv reports. I'm happy to switch the existing plots into this report format, as the existing report is very ugly and difficult to navigate. However, I think the base idea of "generate in task, collate by script" is more robust because it keeps most of the work in something that's more parallelizable.

The location the report will be written to.
collections : `list` [`str`]
A list of collections to search.
**kwargs :
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this is true. doOverwrite will not be set if kwargs['do_overwrite'] is found, and do_copy gets lost entirely.
detectorIds and plotSummaryStats are also not included here.

yield from _nested(v)
else:
yield v
return np.asarray(list(_nested(d)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This recurses into d = {'my_favorite_stat' = 1.2345, 'all_stats': {'stat0': 0.0, 'stat1': 1.0, 'stat2': 2.0}} to return [1.2345, 0.0, 1.0, 2.0], although I suspect it's there to handle d = {'detectorNameA': {'ampName0': 0.0, 'ampName1': 1.0}, 'detectorNameB': {'ampName0': 0.0, 'ampName1': -1.0}}.

Comment thread python/lsst/cp/verify/detailedPlots.py
os.makedirs(f"{self.output}/{raft}/{bay}", exist_ok=True)

def plotLinearizerStatistics(self):
self.plotIdx += 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This leaves plots indexed starting at 1, not zero, if I'm thinking through the logic correctly, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's right. I wanted to leave it indexed at zero as it is more human-readable

Comment thread python/lsst/cp/verify/detailedPlots.py Outdated

self.refs = refs

for ref in tqdm(self.refs, total=len(self.refs), desc="LINEARIZER"):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs a comment explaining what's happening. It's reasonably simple to follow once I know what tqdm does, but I had to google it (although it is in the default stack install, so maybe it's just me).

Comment thread python/lsst/cp/verify/utils.py Outdated
-------
list of matplotlib.patches.Rectangle objects
"""
transform = det.getTransform(cameraGeom.PIXELS, cameraGeom.FOCAL_PLANE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In fact, I think I'm going to suggest that if these functions are essential, they should be factored into methods on FocalPlaneGeometryPlot, so that there's only one code path doing this.

The location the report will be written to.
collections : `list` [`str`]
A list of collections to search.
**kwargs :
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment as above on this docstring not matching the code.

raise RuntimeError(f"The shared directory {self.sharedPath} does not exist.")
if not os.path.isdir(self.sharedPath + "/images"):
raise RuntimeError(f"The shared directory {self.sharedPath} does not follow the expected "
"organizational structure, please refer to DMTN-222 for more information.")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there DMTN-222 ticket branch with this info?

for file in files:
if file.endswith('.png') and not file.endswith('_fp.png'):
try:
pattern = re.compile(r"(step_\d{2}[a-zA-Z]?)-([a-zA-Z0-9_-]+)_(\d{2,3})\.png")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have concerns.

Parameters
----------
statDictA, statDictB : `dict` [`str`, `dict`]
statDictA, statDictB: `dict` [`str`, `dict`]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The dev guide claims these are important spaces: https://developer.lsst.io/python/numpydoc.html#parameters

Raises
------
RuntimeError :
RuntimeError:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But the dev guide also suggests this shouldn't have a : at all, so I'm learning new things too: https://developer.lsst.io/python/numpydoc.html#parameters

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.

3 participants