Skip to content

Default Photometry and Centroid Routes#34

Closed
bensharkey wants to merge 5 commits into
mainfrom
sharkey_patch
Closed

Default Photometry and Centroid Routes#34
bensharkey wants to merge 5 commits into
mainfrom
sharkey_patch

Conversation

@bensharkey

Copy link
Copy Markdown
Collaborator

Adding API routes for a default aperture photometry step, including centroided astrometry route

@bensharkey bensharkey requested a review from mkelley April 23, 2026 17:12

@mkelley mkelley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can't start up the service because one of the routes is missing:

connexion.exceptions.ResolverError: Cannot resolve operationId "catch_analysis_tools.app.services.subtract_median_background.perform_median_subtraction"! Import error was "No module named 'catch_analysis_tools.app.services.subtract_median_background'"

Also, could you pin the numpy version to <= 2.2? I couldn't start the service with 2.4 because of this error, that I don't understand:

connexion.exceptions.ResolverError: module 'numpy' has no attribute 'in1d'

AFAICT, in1d is not used in our code, but down-grading numpy solved the issue.

@bensharkey

Copy link
Copy Markdown
Collaborator Author

Done. Sorry that the perform_median_subtraction route wasn't tracked on my end!

@bensharkey

Copy link
Copy Markdown
Collaborator Author

FYI that the in1d problem seems to pop up in random places with astropy, I know I've seen it pop up a couple of time over the past year for me, it's often hidden somewhere in photutils.

@mkelley

mkelley commented Apr 24, 2026

Copy link
Copy Markdown
Member

Ah, got it. So the right solution is astropy>=7.1.2 numpy>=2.0. Now I can start it up.

@mkelley mkelley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I can run the API, but I get an error on the photometry and centroid routes because I don't have a .wcs file. Can the code use the FITS header by default? In addition, how will a user provide the WCS solution?

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
/subtract_median_background:
post:
operationId: catch_analysis_tools.app.services.subtract_median_background.perform_median_subtraction
summary: "Compute the median background with source masking, saving the background-subtracted image as a new FITS file."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Edit to reflect the fact that this is a windowed median filtering (as opposed to subtraction of the image median).

background_subtracted_image_path:
description: Path to the background-subtracted FITS file.
type: string
/do_default_photometry:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename "photometry/circular_aperture"?


"500":
description: Internal server error
/subtract_median_background:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename "background/median_filtered"? or similar?

centroid_figure:
description: Location of centroid plot.
type: string
/get_centroided_target_location:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename "centroid"?

Co-authored-by: Michael Kelley <msk@astro.umd.edu>
@bensharkey

Copy link
Copy Markdown
Collaborator Author

I can run the API, but I get an error on the photometry and centroid routes because I don't have a .wcs file. Can the code use the FITS header by default? In addition, how will a user provide the WCS solution?

The WCS file is created by the astrometry pipeline, and I had things built assuming the astrometric step had already been run. I'm happy to change those assumptions, and it would be ok to use the FITS header by default, but then I would need to look closer at the headers for the different surveys to figure that out. The convenience of using Yaeji's output file was that it standardized some parameters.

Co-authored-by: Michael Kelley <msk@astro.umd.edu>
@mkelley

mkelley commented Apr 24, 2026

Copy link
Copy Markdown
Member

The WCS file is created by the astrometry pipeline, and I had things built assuming the astrometric step had already been run. I'm happy to change those assumptions, and it would be ok to use the FITS header by default, but then I would need to look closer at the headers for the different surveys to figure that out. The convenience of using Yaeji's output file was that it standardized some parameters.

The user won't always run that calibration step, e.g., there's not much of a reason to do so with the PanSTARRS images, which are already distortion corrected.

@bensharkey

Copy link
Copy Markdown
Collaborator Author

The WCS file is created by the astrometry pipeline, and I had things built assuming the astrometric step had already been run. I'm happy to change those assumptions, and it would be ok to use the FITS header by default, but then I would need to look closer at the headers for the different surveys to figure that out. The convenience of using Yaeji's output file was that it standardized some parameters.

The user won't always run that calibration step, e.g., there's not much of a reason to do so with the PanSTARRS images, which are already distortion corrected.

Ok, should I then be relying on the zero points in the headers? That's the main thing that the calibration step provides from the photometry perspective. Will we need to have logic laid out for every filter type in the database? I'm just trying to get a handle on what level of complexity I should be building towards.

@mkelley

mkelley commented Apr 24, 2026

Copy link
Copy Markdown
Member

Ok, should I then be relying on the zero points in the headers?

Yes, we will want that, too 🙏🏻

@bensharkey

bensharkey commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator Author

Ok, should I then be relying on the zero points in the headers?

Yes, we will want that, too 🙏🏻

Thanks for the back and forth - the reason why the wcs file is currently required by the photometry route is because that's where the zero point information lives, too. Is it a better approach overall for me to make the centroid and photometry paths agnostic about all of the header information? I could see a path forward where photometry works entirely in pixel-space (not RA/Dec) and in ADU space, without asking about anything other than the fits image itself.

Then, the translation to world coordinates and magnitudes would happen from other routes?

@mkelley

mkelley commented Apr 24, 2026

Copy link
Copy Markdown
Member

Yeah, that could work. Converting flux to magnitudes is trivial. The WCS world<-->pixel conversions is harder, so could you make a new route to handle that?

@bensharkey

bensharkey commented Apr 24, 2026 via email

Copy link
Copy Markdown
Collaborator Author

@mkelley mkelley linked an issue Apr 30, 2026 that may be closed by this pull request
@mkelley mkelley closed this May 28, 2026
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.

Add astrometry and photometry API routes

2 participants