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-39622: Add plotting for images. #59

Closed
wants to merge 6 commits into from
Closed

DM-39622: Add plotting for images. #59

wants to merge 6 commits into from

Conversation

madamow
Copy link
Collaborator

@madamow madamow commented Aug 21, 2023

  • plot data from different objects (Image, MaskedImage, Exposure, numpy.array)
  • add centroids from list, sourceCatalog, FootprintSet
  • add compass and/or grid to plot
  • options to select the stretch.

import astropy.visualization as vis


def makePlot(inData, imageType='image', ax=None, centroids=None, compass=False, coordGrid=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

makePlot should be renamed something like plotImage or plotExposure or perhaps just plot, given the variety of objects is accepts. Basically just remove the make and add anything appropriate/nothing at all, as make doesn't really add anything here - the relevant verb for what it's doing is plotting, so I think that should lead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the imageType arg entirely - it doesn't do anything, and is therefore quite confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the ax arg needs to change to take a figure instead, as axes are much harder to work with and less generic, so make this less extensible.

Copy link
Contributor

Choose a reason for hiding this comment

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

The compass option isn't taking a compass object, it's a boolean option, so it needs a very. Something like plotCompass or showCompass or something like that to show it's a toggleable option.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need an option to add a title here too.

stretch=None, percentile=99., cmap='gray_r', anchorPix=250,
legend=True, savePlotAs=None):

"""Make a plot.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be significantly more descriptive, describing what the function does in some detail, e.g. that it supports many different types of images, shows compasses if the image has a wcs, etc.

python/lsst/summit/utils/plotting.py Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
If input data is an exposure, plot either 'image', or 'masked' image.
Defaults to 'image'.
ax : `matplotlib.axes.Axes`, optional
The Matplotlib axis containing the image data plot.
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't contain it here, it will be used for plotting.

python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
python/lsst/summit/utils/plotting.py Outdated Show resolved Hide resolved
ax.text(east[0], east[1], 'E', color=color)

# Add centroids
if centroids:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this whole approach to dealing with multiple types of sources to plot might not be the most advisable. I think it might be more simple to have a footprints arg which accepts either a list of footprints or a footprintSet, a centroid arg which takes a list of centroids, and a sourceCat arg which accepts sourceCatalogs. I think that would make it easier for users, and make this code a little less contrived and delicate.

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 will rewrite this part of the code. I did not like it from the beginning.

@mfisherlevine
Copy link
Contributor

Could you maybe file a new PR once this is ready for re-review? I'm not sure when it should be considered overhauled, and as it stands I think there might be too many comments on this one to make iteration practical.

@madamow
Copy link
Collaborator Author

madamow commented Sep 13, 2023

Closing this pull request. I will open a new one once all suggested changes to code are applied.

@madamow madamow closed this Sep 13, 2023
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