Skip to content

Apcor updates rgc#96

Merged
rgcosentino merged 4 commits intospacetelescope:mainfrom
rgcosentino:apcor_updates_rgc
May 5, 2026
Merged

Apcor updates rgc#96
rgcosentino merged 4 commits intospacetelescope:mainfrom
rgcosentino:apcor_updates_rgc

Conversation

@rgcosentino
Copy link
Copy Markdown
Collaborator

Following some examples of using stpsf from @tddesjardins I updated the aperture correction module to use some pre-baked functions accessible to the psf object in stpsf.

@rgcosentino rgcosentino requested a review from acalamid May 1, 2026 17:50
The enclosed energy fractions are fixed at the JWST NIRCAM values:
x = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95].
Each value of the enclosed energy fraction has an accompanying pixel radius and aperture correction.
ee_radii: aperture radii in arcseconds, defined on a fixed grid from 0.025 to 5.0 arcsec in steps of 0.025
Copy link
Copy Markdown

@acalamid acalamid May 4, 2026

Choose a reason for hiding this comment

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

I really appreciate that now the EE fraction is calculated as a function of circular aperture!
Regarding the choice of radii: 1) I would use pixels instead of arcseconds, since images are distorted and the distortion changes as a function of location on the detector and of the detector. This is particularly important when running the code on observed images; 2) I would increase the first aperture radius since there is no need to measure anything with a radius smaller than 1 pixel for the purpose of the EE correction. For instance, a set of radii from 2 pixels up to 45-50 would work. When we need to add real pixel values for the sky, the inner radius should be bigger than the last circular aperture radius, i.e. at least 46 or 51 pixels, with the outer radius at least 56 or 61 pixel. This would put "infinity" at around 6.5-7", which is a good approximation. I did some tests on images simulated with Romanisim, and the flux of measured stars in the field of view was getting constant around 4.5 to 5 arcseconds.
Regarding the spacing, 1 to 2 pixel should be enough, especially if you interpolate later, 2 pixels might be better.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Did you test using one of the output files with simulated data from Romanisim? Or was that a separate test?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I attach here the plot comparing the per correction reference file for WFI01 and F106 (black circles) with those obtained by: 1) simulating a LMC stellar field from synthetic photometry 2) the field around the standard star WD1657+343; 3) a catalog of 200 stars created by romanisim.  All simulations were done with romanisim. In all 3 cases the EE fractions were calculated on a sample of selected stars in brightness and classified as stars by Source Extractor. These are about 10-20 stars. Values of the EE curve are a bit different in the 4 cases, in particular for the LMC simulations. These stars were fainter and more crowded compared to the other cases. The agreement of the current aperture correction reference file is very good with the simulations.

Each value of the enclosed energy fraction has an accompanying pixel radius and aperture correction.
ee_radii: aperture radii in arcseconds, defined on a fixed grid from 0.025 to 5.0 arcsec in steps of 0.025
ee_fractions: enclosed energy fraction evaluated at each radius
ap_corrections: aperture corrections at each radius, computed as the inverse of the EE fraction (1 / EE)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The aperture correction expressed as 1/EE fraction works if used to correct the star fluxes. For instance, this doesn't work if correcting star magnitudes. In that case the formula to use would be m_cor = m + 2.5×log(EE(r)) Should we provide a reference file with the EE fraction as a function of r and than the user will use the file as they prefer to correct the measurements? Or Romancal is reading a number from these files and dividing by it already? I don't think this part of Romancal is implemented yet so we might think about it. In this way the reference files would be useful to Romancal and to users at the same time.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If you are seeing something that we need to add, please let @tddesjardins and me know asap. We can add extra arrays to the reference file but should note that they are not required by the schema yet if there are truly new.

ee_radii: aperture radii in arcseconds, defined on a fixed grid from 0.025 to 5.0 arcsec in steps of 0.025
ee_fractions: enclosed energy fraction evaluated at each radius
ap_corrections: aperture corrections at each radius, computed as the inverse of the EE fraction (1 / EE)
sky_background_rin, sky_background_rout: placeholders for sky annulus radii (currently not used and set to None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suppose these are currently set to none since there is no real sky background in the STPSF simulation?


Generates a stpsf model and performs circular aperture photometry at integer oversampled pixel radii between min_radius and max_radius. Interpolating the aperture photometry and evaluating the interpolation at the enclosed energy fractions determines the enclosed energy pixel radii and allows for the aperture correction to be calculated.
# Define radii grid
radii_arcsec = np.arange(0.025, 5.0001, 0.025)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See my comment above

#TODO: this needs to be updated to include background effects
aperture_corrections = 1./enclosed_energy_fractions
# Aperture corrections
aperture_corrections = 1.0 / ee_fractions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See my comment above

'ap_corrections': aperture_corrections,
'sky_background_rin': 2.4,
'sky_background_rout': 2.8,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Weren't the sky_rin adn sky_rout supposed to be set to "none" at the moment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

These are the values requested from romancal red team.

@schlafly
Copy link
Copy Markdown

schlafly commented May 5, 2026

We don't use the sky background component of these for anything and so I don't feel strongly about the values. We do report sky backgrounds measured in that annulus and so it's good that those numbers are consistent with the ones we report (though I agree that they don't have particular value in this file, but we're stuck with the format).

romancal reports the aperture fluxes without a correction; I think that's the right thing to do since we don't know a priori whether the object is a star or a galaxy, and galactic folks certainly wouldn't want an aperture correction. This file's primary role in the pipeline is to determine where to put the cut between stars and galaxies for the is_extended star/galaxy flag.

In that context, here's the aper04 / aper02 flux ratio Mairan's simulation. The aper04 / aper02 ratios from this file are overplotted as horizontal lines.

image

I'm not thrilled by the agreement. It's surprising that they're sometimes high and sometimes low; most explanations I could come up with would always be one or the other (e.g., redder spectrum than we expect -> larger FWHM; skipping convolution with the pixel -> smaller FWHM; excluding IPC -> smaller FWHM; ...). We put the star/galaxy cut at 1.1x this ratio, so that's good enough to be okay but in F106 we're only 0.05 mag from the line and so around SNR ~ 20 we'll start calling a good fraction of the stars galaxies.

The curves look very reasonable to me.
image

@rgcosentino rgcosentino requested a review from acalamid May 5, 2026 17:52
Copy link
Copy Markdown
Collaborator

@BradleySappington BradleySappington left a comment

Choose a reason for hiding this comment

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

reviewed by SMEs

@rgcosentino rgcosentino merged commit c967d0e into spacetelescope:main May 5, 2026
1 check passed
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.

5 participants