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-37727: Refactor and develop further the ref cat matching code #133

Merged
merged 13 commits into from Nov 30, 2023

Conversation

sr525
Copy link
Collaborator

@sr525 sr525 commented Jul 17, 2023

No description provided.

@sr525 sr525 force-pushed the tickets/DM-37727 branch 4 times, most recently from 07d9c47 to 099dbd9 Compare July 17, 2023 22:40
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 mostly looks good to me. I tried my best to follow all the inheritances, but didn't look super closely at code that was moved but not obviously changed.

The biggest comment is about taking out the arguments to setDefaults in refCatMatchPlots.py.

a scatter plot.
"""

def setDefaults(self, vectorKey):
Copy link
Contributor

Choose a reason for hiding this comment

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

So, Nate said recently that setDefaults shouldn't have arguments and that I never should have done things this way. If it doesn't cause huge problems, could you try just setting the fields that use vectorKey in the child classes?

Reflecting more, you could do what I did in AstrometricRelativeRepeatability and have a class variable that you set in the pipeline file, then use it to set fields in a finalize function. Then you wouldn't need separate classes for all the flux types and ra and dec. Up to you--I'm not sure what the best way is.

@@ -721,7 +721,7 @@ def _makeSideHistogram(

y_min, y_max = ax.get_ylim()
bins = np.linspace(y_min, y_max, 100)
sideHist.hist(y_all, bins=bins, color="grey", alpha=0.3, orientation="horizontal", log=True)
sideHist.hist(np.array(y_all), bins=bins, color="grey", alpha=0.3, orientation="horizontal", log=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 realize this is outside your PR, but this line made me look at where y_all is set above, and I can't see how line 716 works. In line 719, y_all is a numpy array, but in line 716, it's a string. Also, "all" is not one of the options in the documentation for self.plotTypes or self._datatypes. Maybe @taranu remembers? In any case, I think y_all should already be a numpy array if line 716 is wrong, so you shouldn't have to add this.

Copy link
Collaborator Author

@sr525 sr525 Aug 15, 2023

Choose a reason for hiding this comment

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

I think it is supposed to be any rather than all and also data[], I will test it properly.

@@ -35,7 +35,12 @@ def getInputSchema(self) -> KeyedDataSchema:

def __call__(self, data: KeyedData, **kwargs) -> Scalar:
mask = self.getMask(**kwargs)
return cast(Scalar, float(np.nanmedian(cast(Vector, data[self.vectorKey.format(**kwargs)])[mask])))
if data[self.vectorKey.format(**kwargs)][mask] != []:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if data[self.vectorKey.format(**kwargs)][mask] != []:
if len(data[self.vectorKey.format(**kwargs)][mask]) != 0:

I think this would be more agnostic of the datatype.

@@ -48,7 +53,12 @@ def getInputSchema(self) -> KeyedDataSchema:

def __call__(self, data: KeyedData, **kwargs) -> Scalar:
mask = self.getMask(**kwargs)
return cast(Scalar, float(np.nanmean(cast(Vector, data[self.vectorKey.format(**kwargs)])[mask])))
if data[self.vectorKey.format(**kwargs)][mask] != []:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

errCol = (
f"{fluxCol}"[:fluxInd] + f"{self.uncertaintySuffix.format(**kwargs)}" + f"{fluxCol}"[fluxInd:]
)
vec = cast(Vector, data[fluxCol]) / data[errCol]
Copy link
Contributor

Choose a reason for hiding this comment

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

Was getting rid of the cast() around data[errCol] on purpose? It's fine if so, I just don't immediately understand why.

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 don't remember. I think the cast around the result should be sufficent though?

default=["u", "g", "r", "i", "z", "y"],
filterNames = pexConfig.ListField[str](
doc="Physical filter names to persist downstream.",
default=["HSC-G", "HSC-R", "HSC-I", "HSC-Z", "HSC-Y"],
Copy link
Contributor

Choose a reason for hiding this comment

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

HSC specific stuff should be in obs_subaru.

)

requireProperMotion = pexConfig.Field[bool](
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 leave this in? I'm turning this on in a ticket I'm working on. I might be able to find a workaround if it's really annoying, since I see you aren't using the meas_algorithms reference loader directly anymore.

cats = []
for h in handle:
cats.append(h.get(parameters={"columns": names}))
return vstack(cats)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still KeyedData?

):
filterNames = pexConfig.ListField[str](
doc="Physical filter names to persist downstream.",
default=["HSC-G", "HSC-R", "HSC-I", "HSC-Z", "HSC-Y"],
Copy link
Contributor

Choose a reason for hiding this comment

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

You have this already from CatalogMatchConfig.



class PhotometricCatalogMatchVisitConnections(
CatalogMatchConnections,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as for AstrometricCatalogMatchVisitConnections: I don't think you want to inherit.

@sr525 sr525 force-pushed the tickets/DM-37727 branch 2 times, most recently from d0902c4 to 02732b9 Compare July 25, 2023 13:49
@sr525 sr525 force-pushed the tickets/DM-37727 branch 6 times, most recently from dba3a95 to 509a840 Compare August 29, 2023 13:33
@sr525 sr525 force-pushed the tickets/DM-37727 branch 4 times, most recently from 4c5c5e0 to 572091b Compare September 7, 2023 04:21
@sr525 sr525 force-pushed the tickets/DM-37727 branch 12 times, most recently from c50e3c4 to 726de71 Compare November 22, 2023 13:18
@sr525 sr525 force-pushed the tickets/DM-37727 branch 5 times, most recently from 62960cd to 95a645d Compare November 29, 2023 18:59
@sr525 sr525 merged commit 7d0e31e into main Nov 30, 2023
8 checks passed
@sr525 sr525 deleted the tickets/DM-37727 branch November 30, 2023 04:41
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

2 participants