Skip to content

Commit

Permalink
Updating release branch. (#1945)
Browse files Browse the repository at this point in the history
Co-authored-by: mdlpstsci <[email protected]>
  • Loading branch information
s-goldman and mdlpstsci authored Jan 29, 2025
1 parent cd6bd9a commit e6711b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ number of the code change for that issue. These PRs can be viewed at:
https://github.com/spacetelescope/drizzlepac/pulls


3.9.1 (29-Jan-2025)
==================

- Further updates done to address the deprecated Photutils functionality as the
original changes did not produce results at least as good as the results
generated by the previous Photutils functionality. [#1934]


3.9.0 (16-Dec-2024)
===================

Expand Down
25 changes: 10 additions & 15 deletions drizzlepac/haputils/astrometric_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
sigma_clipped_stats, SigmaClip)
from astropy.visualization import SqrtStretch
from astropy.visualization.mpl_normalize import ImageNormalize
from astropy.modeling.fitting import LevMarLSQFitter
from astropy.modeling.fitting import LMLSQFitter
from astropy.time import Time
from astropy.utils.decorators import deprecated

Expand Down Expand Up @@ -836,7 +836,7 @@ def build_auto_kernel(imgarr, whtarr, fwhm=3.0, threshold=None, source_box=7,
return (kernel, kernel_psf), kernel_fwhm


def find_fwhm(psf, default_fwhm):
def find_fwhm(psf, default_fwhm, log_level=logutil.logging.INFO):
"""Determine FWHM for auto-kernel PSF
This function iteratively fits a Gaussian model to the extracted PSF
Expand All @@ -858,43 +858,38 @@ def find_fwhm(psf, default_fwhm):
Value of the computed Gaussian FWHM for the PSF
"""
fwhm = 0.0

# Default 1.0 * default_fwhm (default_fwhm is detector-dependent)
aperture_radius = 1.5 * default_fwhm
source_group = SourceGrouper(min_separation=8)
mmm_bkg = MMMBackground()
# LocalBackground: Inner and outer radius of circular annulus in pixels
base = int(math.ceil(aperture_radius))
local_bkg = LocalBackground(base + 1, base + 3, mmm_bkg)
iraffind = DAOStarFinder(threshold=2.5 * mmm_bkg(psf), fwhm=default_fwhm)
fitter = LevMarLSQFitter()
# LevMarLSQFitter is in disfavor and will be deprecated
fitter = LMLSQFitter()
sigma_psf = gaussian_fwhm_to_sigma * default_fwhm
gaussian_prf = IntegratedGaussianPRF(sigma=sigma_psf)
gaussian_prf.sigma.fixed = False
try:
itr_phot_obj = IterativePSFPhotometry(finder=iraffind,
grouper=source_group,
localbkg_estimator=local_bkg,
psf_model=gaussian_prf,
aperture_radius=aperture_radius,
fitter=fitter,
fit_shape=(11, 11),
maxiters=2)

phot_results = itr_phot_obj(psf)
except Exception:
log.error("The find_fwhm() failed due to problem with fitting.")
except Exception as x_cept:
log.warn(f"The find_fwhm() failed due to problem with fitting. Trying again. Exception: {x_cept}")
return None

# Check the phot_results table was generated successfully
if isinstance(phot_results, (type(None))):
log.warn("The PHOT_RESULTS table was not generated successfully. Trying again.")
return None

# Check the table actually has rows
if len(phot_results['flux_fit']) == 0:
return None

# Check the 'flags' column has at least one row with a flag value of zero
if (phot_results['flags'] == 0).sum() == 0:
log.warn("The PHOT_RESULTS table has no rows. Trying again.")
return None

# Insure none of the fluxes determined by photutils is np.nan
Expand Down
10 changes: 3 additions & 7 deletions drizzlepac/haputils/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,21 +495,17 @@ def align_to_gaia(
headerlet_filenames=headerlet_filenames, fit_label=fit_label
)
else:
log.warning("No satisfactory fit found for any catalog.")
log.warning("No satisfactory fit found for any catalog. No correction to absolute astrometric frame applied.\n")
raise ValueError

except Exception:
# Report a problem with the alignment
if fit_label.upper().strip() == "SVM":
log.warning(
"EXCEPTION encountered in align_to_gaia for the FilteredProduct.\n"
)
"EXCEPTION encountered in align_to_gaia for the FilterProduct. Proceeding with previous best solution.\n")
else:
log.warning(
"EXCEPTION encountered in align_to_gaia for the SkyCellProduct.\n"
)
log.warning("No correction to absolute astrometric frame applied.\n")
log.warning("Proceeding with previous best solution.\n")
"EXCEPTION encountered in align_to_gaia for the SkyCellProduct. Proceeding with previous best solution.\n")

# Only write out the traceback if in "debug" mode since not being able to
# align the data to an absolute astrometric frame is not actually a failure.
Expand Down
2 changes: 1 addition & 1 deletion tests/hap/test_svm_ibqk07.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

POLLER_FILE = "wfc3_bqk_07_input.out"
WCS_IR_SUB_NAME = "HSC30"
WCS_UVIS_SUB_NAME = "FIT_SVM_GAIA"
WCS_UVIS_SUB_NAME = "HSC30"
expected_total_point_sources = {
"hst_12557_07_wfc3_ir_total_ibqk07_point-cat.ecsv": 2,
"hst_12557_07_wfc3_uvis_total_ibqk07_point-cat.ecsv": 13}
Expand Down

0 comments on commit e6711b3

Please sign in to comment.