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
Conversation
07d9c47
to
099dbd9
Compare
There was a problem hiding this 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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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] != []: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] != []: |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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]( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
d0902c4
to
02732b9
Compare
dba3a95
to
509a840
Compare
4c5c5e0
to
572091b
Compare
b8dfa4e
to
a3d6c13
Compare
c50e3c4
to
726de71
Compare
62960cd
to
95a645d
Compare
…the processing carries on
95a645d
to
042cfa5
Compare
No description provided.