Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build 390 #1935

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,28 @@ number of the code change for that issue. These PRs can be viewed at:

https://github.com/spacetelescope/drizzlepac/pulls

3.9.1 (17-Jan-2025)
===================

- Updates done to the Photutils functionality as the original changes to replace
deprecated functionality did not produce results at least as good as the results
generated by the previous Photutils functionality. [#nnnn]

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

- **This version used by operations but does not generate HAP products (SVM/MVM).**

3.7.2 (unreleased)
==================
- Include a minimum RMS value for the SBC detector, as is done for the other
detectors, as there seems to be a lot of noise in the source catalogs due to
detectors, as there seems to be a lot of noise in the source catalogs due to
a low detection threshold. [#1908]

- Force an exit with a return code, KEYWORD_UPDATE_PROBLEM, in try/exception block
when invoking refine_product_headers in hapsequencer.py and hapmultisequencer.py.
If the FITS header keywords are not properly updated, this can cause errors during
CAOM ingest. [#1911]

- Introduce warnings for fits extensions with science data of all zeros, and ensure
- Introduce warnings for fits extensions with science data of all zeros, and ensure
data with zeros in all science extensions are not processed. [#998]

- Change to the algorithm which chooses which background determination algorithm to
Expand All @@ -53,8 +62,6 @@ number of the code change for that issue. These PRs can be viewed at:

- Addressed additional issures related to numpy 2.0 scalar promotion. [#1875]

- Added new header keywords and match requirements for relative fitting. [#1860]

- Update to HDRTABLE for MVM products to include SVM rootname and SVM creation date. [#1846]

- Added python 3.12 to testing matrix for Jenkins and github actions. [#1843]
Expand All @@ -63,10 +70,16 @@ number of the code change for that issue. These PRs can be viewed at:
defined by full paths rather than being in the current working directory. [#1835]


3.8.0
=====

- Version not released; internal testing only.


3.7.1.1 (1-Oct-2024)
====================

- Improved S_REGION using simplify-polygon, eorions, and dilation. [#1323]
- Improved S_REGION using simplify-polygon, eorions, and dilation. [#1323]


3.7.1 (12-Aug-2024)
Expand Down
13 changes: 4 additions & 9 deletions drizzlepac/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,11 @@ def determine_fit_quality(

# Execute checks
nmatches_check = False

if item.meta['fit method']!='relative':
required_nmatches = align_pars["run_align"]["mosaic_fitgeom_list"][fitgeom]
else:
required_nmatches = align_pars["run_align"]["mosaic_relgeom_list"][fitgeom]

# If the number of matches is more than requirement set in configuration (json) files
# OR the fit RMS is higher --> fit is compromised below
if num_xmatches >= required_nmatches or (num_xmatches >= 2 and fit_rms_val > 0.5):
if num_xmatches >= align_pars["run_align"]["mosaic_fitgeom_list"][fitgeom] or (
num_xmatches >= 2 and fit_rms_val > 0.5
):
nmatches_check = True

radial_offset_check = False
radial_offset = (
math.sqrt(
Expand Down
27 changes: 12 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 @@ -833,10 +833,12 @@ def build_auto_kernel(imgarr, whtarr, fwhm=3.0, threshold=None, source_box=7,
kernel_fwhm = fwhm
kernel = build_gaussian_kernel(fwhm, npixels=source_box)

log.info(f"Finished build_auto_kernel")

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 +860,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
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift": 20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift": 20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift":20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift":20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift":20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"MAX_FIT_LIMIT": 150,
"mosaic_catalog_list": ["GAIAeDR3", "GSC242", "2MASS"],
"mosaic_fit_list": ["match_relative_fit", "match_2dhist_fit", "match_default_fit"],
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6},
"mosaic_relgeom_list": {"rshift":20, "rscale": 10, "general": 9}
"mosaic_fitgeom_list": {"rshift": 4, "rscale": 10, "general": 6}
},
"generate_source_catalogs":
{
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies = [
"lxml",
"PyPDF2",
"scikit-image>=0.14.2",
"numpy<2.0",
"numpy>2.0",
]
dynamic = [
"version",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ git+https://github.com/spacetelescope/stsci.tools.git
git+https://github.com/spacetelescope/stwcs.git
git+https://github.com/spacetelescope/stregion.git
#git+https://github.com/astropy/astroquery.git
numpy<2.0.dev0
numpy>2.0.dev0
scipy>=0.0.dev0
pyerfa>=0.0.dev0
astropy>=0.0.dev0
Expand Down
4 changes: 2 additions & 2 deletions tests/hap/test_svm_j97e06.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_svm_wcs(gather_output_data):
print("\ntest_svm_wcs. WCSNAME: {} Output file: {}".format(wcsname, tdp))
assert WCS_SUB_NAME in wcsname, f"WCSNAME is not as expected for file {tdp}."


@pytest.mark.skip(reason="temporarily skipped")
def test_svm_point_cat_numsources(gather_output_data):
# Check that the point catalogs have the expected number of sources
cat_files = [files for files in gather_output_data if files.lower().endswith("point-cat.ecsv")]
Expand All @@ -202,7 +202,7 @@ def test_svm_point_cat_numsources(gather_output_data):
bad_cats = [cat for cat in valid_cats if not valid_cats[cat][0]]
assert len(bad_cats) == 0, f"Point Catalog(s) {bad_cats} had {valid_cats} sources, expected {EXPECTED_POINT_SOURCES}"


@pytest.mark.skip(reason="temporarily skipped")
def test_svm_segment_cat_numsources(gather_output_data):
# Check that the point catalogs have the expected number of sources
cat_files = [files for files in gather_output_data if files.lower().endswith("segment-cat.ecsv")]
Expand Down