Skip to content

Commit

Permalink
Source detection step option to fit model PSFs (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 authored Nov 9, 2023
2 parents 6e5887a + 1a3f69f commit cf17a69
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 374 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ tweakreg
- Fix a bug due to which source catalog may contain sources
outside of the bounding box. [#947]

source_detection
----------------

- Support for PSF fitting (optional) for accurate centroids. [#841]

0.12.0 (2023-08-18)
===================

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies = [
'numpy >=1.22',
'photutils @ git+https://github.com/astropy/photutils.git',
'pyparsing >=2.4.7',
'requests >=2.22',
'requests >=2.26',
'rad >= 0.17.1',
# 'rad @ git+https://github.com/spacetelescope/rad.git@main',
'roman_datamodels >= 0.17.1',
Expand All @@ -34,7 +34,7 @@ dependencies = [
'spherical-geometry >= 1.2.22',
'stsci.imagestats >= 1.6.3',
'drizzle >= 1.13.7',
'webbpsf == 1.1.1',
'webbpsf == 1.2.1',
]
dynamic = ['version']

Expand Down
38 changes: 17 additions & 21 deletions romancal/lib/psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,36 @@
# Phase C central wavelengths [micron], released by Goddard (Jan 2023):
# https://roman.ipac.caltech.edu/sims/Param_db.html#wfi_filters
filter_central_wavelengths = {
"WFI_Filter_F062_Center": 0.620,
"WFI_Filter_F087_Center": 0.869,
"WFI_Filter_F106_Center": 1.060,
"WFI_Filter_F129_Center": 1.293,
"WFI_Filter_F146_Center": 1.464,
"WFI_Filter_F158_Center": 1.577,
"WFI_Filter_F184_Center": 1.842,
"WFI_Filter_F213_Center": 2.125,
"F062": 0.620,
"F087": 0.869,
"F106": 1.060,
"F129": 1.293,
"F146": 1.464,
"F158": 1.577,
"F184": 1.842,
"F213": 2.125,
}

default_finder = DAOStarFinder(
# these defaults extracted from the
# romancal SourceDetectionStep
fwhm=2.0,
threshold=2.0,
fwhm=1.0,
threshold=0.0,
sharplo=0.0,
sharphi=1.0,
roundlo=-1.0,
roundhi=1.0,
peakmax=1000.0,
peakmax=None,
)


def create_gridded_psf_model(
path_prefix,
filt,
detector,
oversample=12,
fov_pixels=12,
sqrt_n_psfs=4,
oversample=11,
fov_pixels=9,
sqrt_n_psfs=2,
overwrite=False,
buffer_pixels=100,
instrument_options=None,
Expand All @@ -82,7 +82,8 @@ def create_gridded_psf_model(
Computed gridded PSF model for this SCA.
Examples include: `"SCA01"` or `"SCA18"`.
oversample : int, optional
Oversample factor, default is 12. See WebbPSF docs for details [1]_.
Oversample factor, default is 11. See WebbPSF docs for details [1]_.
Choosing an odd number makes the pixel convolution more accurate.
fov_pixels : int, optional
Field of view width [pixels]. Default is 12.
See WebbPSF docs for details [1]_.
Expand Down Expand Up @@ -150,17 +151,12 @@ def create_gridded_psf_model(
if instrument_options is not None:
wfi.options.update(instrument_options)

central_wavelength_meters = (
filter_central_wavelengths[f"WFI_Filter_{filt}_Center"] * 1e-6 * u.m
)

# Initialize the PSF library
inst = gridded_library.CreatePSFLibrary(
instrument=wfi,
filter_name=filt,
detectors=detector.upper(),
num_psfs=n_psfs,
monochromatic=central_wavelength_meters,
oversample=oversample,
fov_pixels=fov_pixels,
add_distortion=False,
Expand Down Expand Up @@ -279,7 +275,7 @@ def fit_psf_to_image_model(
"""
if grouper is None:
# minimum separation before sources are fit simultaneously:
grouper = SourceGrouper(min_separation=20) # [pix]
grouper = SourceGrouper(min_separation=5) # [pix]

if fitter is None:
fitter = LevMarLSQFitter(calc_uncertainties=True)
Expand Down
Loading

0 comments on commit cf17a69

Please sign in to comment.