Skip to content

Conversation

@snbianco
Copy link
Collaborator

@snbianco snbianco commented Oct 7, 2025

Added support in ra_dec_crossmatch for a cutout size of zero, enabling single-point matching to FFIs that contain the specified coordinates. This single-point matching is significantly faster than computing an intersection between polygons.

If only one axis of the cutout size is equal to zero, I add a negligible amount in that dimension and treat the cutout as a very thin rectangle.

@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.29%. Comparing base (200b3e9) to head (b62f8a7).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
+ Coverage   96.25%   96.29%   +0.04%     
==========================================
  Files          17       17              
  Lines        1787     1810      +23     
==========================================
+ Hits         1720     1743      +23     
  Misses         67       67              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@snbianco snbianco marked this pull request as ready for review October 7, 2025 14:31
@snbianco snbianco added the TESScut Issues related to TESScut. label Oct 7, 2025
@snbianco snbianco requested a review from falkben October 7, 2025 14:33

@staticmethod
def _parse_size_input(cutout_size):
def _parse_size_input(cutout_size, *, allow_zero: bool = False) -> np.ndarray:
Copy link
Member

Choose a reason for hiding this comment

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

Just style, but if this method is supposed to be called from outside the class (e.g. footprint_cutout.py) then I think it shouldn't be private (remove leading underscore).

I'm also curious about when we'd want allow_zero to be True.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use it here:

for axis, size in enumerate(Cutout._parse_size_input(cutout_size, allow_zero=True)):

I don't foresee that parameter having much use, but it is needed in this particular case to avoid an error.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant False.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That same function is used in the classes that create cutouts, and an error should be thrown if the cutout size is zero in those cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed _parse_size_input to parse_size_input in last commit!

# Cutout size of 0 should do a point match
point_results = ra_dec_crossmatch(all_ffis, coordinates, 0, 21)
len_point_results = len(point_results)
assert isinstance(point_results, Table)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be good to have an assertion that the crossmatch was actually a point search here.

if you end up splitting up the crossmatch code into two separate function, it should be pretty easy to apply a mock/patch to those functions to assert that the crossmatch_point func was called and not the other. maybe there are other ways to do it (does the returned table include any info we could check?)



def ra_dec_crossmatch(all_ffis: Table, coordinates: SkyCoord, cutout_size, arcsec_per_px: int = 21) -> Table:
def _crossmatch_point(ra: SkyCoord, dec: SkyCoord, all_ffis: Table) -> List[int]:
Copy link
Member

Choose a reason for hiding this comment

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

return type annotation -- should it be np.ndarray?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yes it should. Fixed!

@snbianco snbianco merged commit cfcd623 into main Oct 7, 2025
14 checks passed
@snbianco snbianco deleted the zero-crossmatch branch October 7, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TESScut Issues related to TESScut.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants