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-32450: Add camera geometry plotting utilities #131

Merged
merged 5 commits into from
Aug 18, 2023
Merged

Conversation

czwa
Copy link
Contributor

@czwa czwa commented Jul 10, 2023

No description provided.

Copy link
Contributor

@cmsaunders cmsaunders left a comment

Choose a reason for hiding this comment

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

This looks good--I mostly just have comments about things that might be able to be made simpler. However, can you put some example plots for the two different levels on the jira ticket?


xAxisLabel = Field[str](doc="Label to use for the x axis.", optional=False)
yAxisLabel = Field[str](doc="Label to use for the y axis.", optional=False)
zAxisLabel = Field[str](doc="Label to use for the z axis.", optional=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but can these and statistic below just be inherited from the parent class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe so. I've removed them and confirmed that the plots look identical.


# U/V coordinates represent focal plane locations.
minU, minV = corners.min(axis=0)
maxU, maxV = corners.max(axis=0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just use these to set plotLimit_x and plotLimit_y rather than go through the loop above?

# This does the appropriate statistic for this
# detector's data.
statistic, _, _ = binned_statistic_dd(
[focalPlane_x[detectorInd], focalPlane_y[detectorInd]],
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't focalPlane_x and focalPlane_y all zeros here? I guess it doesn't matter, since you're just trying to get one number for the whole detector, but then it seems like you could use something simpler than binned_statistic_dd. That said, I couldn't find another scipy function with the needed functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The contents of focalPlane_xy are arbitrary, and should be ignored in this block. I also tried to find another function that understood the same statistic argument, and tracked through the source to see that the other binned_statistic functions make calls to binned_statistic_dd, which does the conversion from the string statistic name to the numeric result itself (here: https://github.com/scipy/scipy/blob/v1.11.1/scipy/stats/_binned_statistic.py#L596).

ampName = amplifier.getName()
detectorInd = data["detector"] == detectorId
ampInd = data["x"] == ampName
detectorInd &= ampInd
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, I think it would be clearer to reverse this to ampInd &= detectorInd so that you are using ampInd later.


class FocalPlaneGeometryPlot(FocalPlanePlot):
"""Plots the focal plane distribution of a parameter in camera
geometry units.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify that camera geometry units means detectors or amplifiers?

for amplifier in detector:
ampName = amplifier.getName()
detectorInd = data["detector"] == detectorId
ampInd = data["x"] == ampName
Copy link
Contributor

Choose a reason for hiding this comment

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

If x is supposed to be the amp name, can you add that to the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This comment convinced me to switch from using x (which as suggested, isn't obvious) to a new amplifier field. I've updated the docs to reflect this. This also allows the x and y vectors to be ignored, allowing a single catalog to be plotted using either FocalPlanePlot or FocalPlaneGeometryPlot (for level='detector').
I wrote a method to manage some further conversions, but it seemed out of scope for this ticket, so I've saved that as a snippet that might be useful in the future.

Copy link
Contributor

@cmsaunders cmsaunders left a comment

Choose a reason for hiding this comment

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

Very minor comment: you could remove "x" and "y" from the columns that are expected in data (lines 290-293).

* Switch to an explicit 'amplifier' column, so as not to overload 'x'.
* Switch to using 'z' column for all expected lengths, as it should
  always exist.
* Clarify index name, as it applies to amplifiers, not detectors.
@czwa czwa merged commit da3c9a1 into main Aug 18, 2023
8 checks passed
@czwa czwa deleted the tickets/DM-32450 branch August 18, 2023 22:16
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.

2 participants