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-35619: Add astrometry residuals with refCat plots #15

Merged
merged 4 commits into from Aug 3, 2022

Conversation

cmsaunders
Copy link
Contributor

No description provided.

@cmsaunders cmsaunders marked this pull request as ready for review July 26, 2022 19:38
@cmsaunders cmsaunders force-pushed the tickets/DM-35619 branch 6 times, most recently from 006d27a to 1fdabb8 Compare July 28, 2022 13:56
dec=refCatalog['coord_dec'] * u.degree)

sourceCat_ap = SkyCoord(ra=targetCatalog['coord_ra'] * u.degree,
dec=targetCatalog['coord_dec'] * u.degree)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have spaces around the * here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know that the units are always gong to be degrees or should it be a config option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mind is blown -- somehow I have been doing spacing around operators wrong.

I added a config option for the units.

Copy link
Member

@timj timj Aug 1, 2022

Choose a reason for hiding this comment

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

When you switch the code to using black you will find that that rule about spaces around operators goes away anyhow... (and this package is using black)

)

matchCatalog = pipeBase.connectionTypes.Output(
doc="Catalog with matched target and reference objects with separations",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I would prefer matchedCatalog as it reinforces that this is the one that has been matched rather than the one to match but I don't think it really matters.

for selector in selectorAction:
for band in ["g", "r", "i", "z", "y"]:
selectorSchema = selector.getFormattedInputSchema(band=band)
columns += [s[0] for s in selectorSchema]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mixture of ' and ". I don't think it matters but it looks neater when it is consistent.

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 was moved to a config option (with consistent quotation marks).

refCat = skyCircle.refCat

# Convert the coordinates to RA/Dec and convert the catalog to a
# dataframe
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spaces around *

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 using black, this is a thing that has a right answer, and black does it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, when I tried to commit, triggering pre-commit, black complained about all the places I just removed whitespaces. However, this seems to disagree with https://developer.lsst.io/python/style.html#binary-operators-should-be-surrounded-by-a-single-space-except-for. Maybe I don't have black configured correctly.

Copy link
Member

Choose a reason for hiding this comment

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

When black is enabled for a project the Python style guide for formatting is no longer relevant. I thought there was a comment about that somewhere in the dev guide but maybe that was only in the section about using black.

Copy link
Contributor

Choose a reason for hiding this comment

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

median = np.nanmedian(value[-x:])
if self.inputUnit != self.outputUnit:
median = (median * u.Unit(self.inputUnit)).to(u.Unit(self.outputUnit)).value
return median
Copy link
Collaborator

Choose a reason for hiding this comment

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

Spaces around *

----------
df : `pandas.core.frame.DataFrame`
The catalog to calculate the position difference from.
Returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

Variable type and name missing.

@sr525
Copy link
Collaborator

sr525 commented Jul 30, 2022

I've left a few minor comments, I know that you have tested this all thoroughly and that it works. One general comment is that I think the style guideline says that we shouldn't have spaces around * and / but there are spaces around them here. Perhaps black did this formatting?

@cmsaunders
Copy link
Contributor Author

@timj , do you mean in interfaces.py?

@timj
Copy link
Member

timj commented Aug 3, 2022

@cmsaunders I was commenting on a line in a commit but that clearly became detached from the pull request so sorry about that.

It was the type: ignore on the Field that I was worrying about. We solved that one in other packages by annotating the variable that the Field is being assigned to.

@cmsaunders
Copy link
Contributor Author

I tried parameterizedBand: Field[bool] =, but it didn't work how I need it to in the class. I don't know if it would have passed mypy.

@natelust
Copy link
Contributor

natelust commented Aug 3, 2022

@timj in this cases @cmsaunders is using something that ducks like a bool on the class interface, but MYPY is unhappy because of LSP even though they duck the same. We could loosen up the type on the base class, but in reality we likely will move toward something similar to what @cmsaunders has on the base class, we just dont want to disrupt right before the weekly, so as we know they duck the same, for now we are just trying to inform MYPY it ok to violate LSP.

@natelust
Copy link
Contributor

natelust commented Aug 3, 2022

@cmsaunders In light of needing yet another cast or typing or something in order to make mypy happy again, let's back up and actually do the type union on the base class. you can change https://github.com/lsst/analysis_tools/blob/main/python/lsst/analysis/tools/interfaces.py#L287 this to parameterizedBand: bool | Field[bool] I think

@natelust
Copy link
Contributor

natelust commented Aug 3, 2022

and remove the type ignore where we added it earlier

@cmsaunders
Copy link
Contributor Author

@natelust, I pushed a change before I saw your last message, which worked, but I'll try your suggestion and see how that works.

@cmsaunders cmsaunders deleted the tickets/DM-35619 branch August 3, 2022 17:11
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

4 participants