-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes from all commits
b4b263e
dd93c57
4fe8e56
d00ad3c
104d1a8
3917b4e
ac809ea
c54ac14
d18bf3e
c6f15a0
8309d6f
0c2906e
042cfa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,15 @@ class CoaddPlotFlagSelector(FlagSelector): | |
def getInputSchema(self) -> KeyedDataSchema: | ||
yield from super().getInputSchema() | ||
|
||
def refMatchContext(self): | ||
self.selectWhenFalse = [ | ||
"{band}_psfFlux_flag_target", | ||
"{band}_pixelFlags_saturatedCenter_target", | ||
"{band}_extendedness_flag_target", | ||
"xy_flag_target", | ||
] | ||
self.selectWhenTrue = ["detect_isPatchInner_target", "detect_isDeblendedSource_target"] | ||
|
||
def __call__(self, data: KeyedData, **kwargs) -> Vector: | ||
result: Optional[Vector] = None | ||
bands: tuple[str, ...] | ||
|
@@ -162,9 +171,19 @@ class VisitPlotFlagSelector(FlagSelector): | |
(i.e., using sourceTable_visit catalogs). | ||
""" | ||
|
||
catalogSuffix = Field[str](doc="The suffix to apply to all the keys.", default="") | ||
|
||
def getInputSchema(self) -> KeyedDataSchema: | ||
yield from super().getInputSchema() | ||
|
||
def refMatchContext(self): | ||
self.selectWhenFalse = [ | ||
"psfFlux_flag_target", | ||
"pixelFlags_saturatedCenter_target", | ||
"extendedness_flag_target", | ||
"centroid_flag_target", | ||
] | ||
|
||
def __call__(self, data: KeyedData, **kwargs) -> Vector: | ||
result: Optional[Vector] = None | ||
temp = super().__call__(data, **kwargs) | ||
|
@@ -227,8 +246,11 @@ class SnSelector(SelectorBase): | |
) | ||
|
||
def getInputSchema(self) -> KeyedDataSchema: | ||
yield (fluxCol := self.fluxType), Vector | ||
yield f"{fluxCol}{self.uncertaintySuffix}", Vector | ||
fluxCol = self.fluxType | ||
fluxInd = fluxCol.find("lux") + len("lux") | ||
errCol = f"{fluxCol}"[:fluxInd] + f"{self.uncertaintySuffix}" + f"{fluxCol}"[fluxInd:] | ||
yield fluxCol, Vector | ||
yield errCol, Vector | ||
|
||
def __call__(self, data: KeyedData, **kwargs) -> Vector: | ||
"""Makes a mask of objects that have S/N greater than | ||
|
@@ -260,8 +282,11 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector: | |
bands = ("",) | ||
for band in bands: | ||
fluxCol = self.fluxType.format(**(kwargs | dict(band=band))) | ||
errCol = f"{fluxCol}{self.uncertaintySuffix.format(**kwargs)}" | ||
vec = cast(Vector, data[fluxCol]) / cast(Vector, data[errCol]) | ||
fluxInd = fluxCol.find("lux") + len("lux") | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Was getting rid of the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
temp = (vec > self.threshold) & (vec < self.maxSN) | ||
if mask is not None: | ||
mask &= temp # type: ignore | ||
|
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 thinky_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.