Skip to content

Commit

Permalink
fix regtest failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mcara committed May 16, 2024
1 parent 56a1108 commit 81989c3
Showing 1 changed file with 37 additions and 47 deletions.
84 changes: 37 additions & 47 deletions jwst/tweakreg/tweakreg_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,6 @@ def _set_skip_step(self, images, err_msg, level=logging.WARNING, skip=True, kind
def process(self, input):
use_custom_catalogs = self.use_custom_catalogs

if self.separation <= _SQRT2 * self.tolerance:
return self._set_skip_step(
input,
"Parameter 'separation' must be larger than 'tolerance' by at "
"least a factor of sqrt(2) to avoid source confusion.",
logging.ERROR,
)

if self.abs_separation <= _SQRT2 * self.abs_tolerance:
return self._set_skip_step(
input,
"Parameter 'abs_separation' must be larger than 'abs_tolerance' "
"by at least a factor of sqrt(2) to avoid source confusion.",
logging.ERROR,
)

if use_custom_catalogs:
catdict = _parse_catfile(self.catfile)
# if user requested the use of custom catalogs and provided a
Expand Down Expand Up @@ -203,6 +187,22 @@ def process(self, input):
"containing one or more DataModels.", ) + e.args[1:]
raise e

if self.separation <= _SQRT2 * self.tolerance:
return self._set_skip_step(

Check warning on line 191 in jwst/tweakreg/tweakreg_step.py

View check run for this annotation

Codecov / codecov/patch

jwst/tweakreg/tweakreg_step.py#L191

Added line #L191 was not covered by tests
input,
"Parameter 'separation' must be larger than 'tolerance' by at "
"least a factor of sqrt(2) to avoid source confusion.",
logging.ERROR,
)

if self.abs_separation <= _SQRT2 * self.abs_tolerance:
return self._set_skip_step(

Check warning on line 199 in jwst/tweakreg/tweakreg_step.py

View check run for this annotation

Codecov / codecov/patch

jwst/tweakreg/tweakreg_step.py#L199

Added line #L199 was not covered by tests
input,
"Parameter 'abs_separation' must be larger than 'abs_tolerance' "
"by at least a factor of sqrt(2) to avoid source confusion.",
logging.ERROR,
)

if self.abs_refcat is not None and self.abs_refcat.strip():
align_to_abs_refcat = True
# Set expand_refcat to True to eliminate possibility of duplicate
Expand Down Expand Up @@ -533,52 +533,42 @@ def process(self, input):
msg = e.args[0]
if (msg == "Too few input images (or groups of images) with "
"non-empty catalogs."):
# we need at least two exposures to perform image alignment
self.log.warning(msg)
self.log.warning(
"At least one exposure is required to align images "
"to an absolute reference catalog. Alignment to an "
"absolute reference catalog will not be performed."
)
if not rel_ok:
self.log.warning("Nothing to do. Skipping 'TweakRegStep'...")
for model in images:
model.meta.cal_step.tweakreg = "SKIPPED"
self.skip = True
return images

# we need at least one exposure (group) to perform
# absolute image alignment
self._set_skip_step(

Check warning on line 538 in jwst/tweakreg/tweakreg_step.py

View check run for this annotation

Codecov / codecov/patch

jwst/tweakreg/tweakreg_step.py#L538

Added line #L538 was not covered by tests
images,
err_msg=[
msg,
"At least two exposures are required for relative "
"image alignment."
"At least one exposure is required to align images "
"to an absolute reference catalog. Alignment to an "
"absolute reference catalog will not be performed."
],
skip=not align_to_abs_refcat,
kind='relative',
level=logging.WARNING if align_to_abs_refcat else logging.ERROR
skip=not rel_ok,
kind='absolute' if rel_ok else '',
)

if not rel_ok:
return images
else:
raise e

except RuntimeError as e:
msg = e.args[0]
if msg.startswith("Number of output coordinates exceeded allocation"):
# we need at least two exposures to perform image alignment
self.log.error(msg)
self.log.error(
"Multiple sources within specified tolerance "
"matched to a single reference source. Try to "
"adjust 'tolerance' and/or 'separation' parameters."
"Alignment to an absolute reference catalog will "
"not be performed."
self._set_skip_step(

Check warning on line 558 in jwst/tweakreg/tweakreg_step.py

View check run for this annotation

Codecov / codecov/patch

jwst/tweakreg/tweakreg_step.py#L558

Added line #L558 was not covered by tests
images,
err_msg=[
msg,
"Multiple sources within specified tolerance "
"matched to a single reference source. Try to "
"adjust 'tolerance' and/or 'separation' parameters."
"Alignment to an absolute reference catalog will "
"not be performed."
],
skip=not rel_ok,
kind='absolute' if rel_ok else '',
)
if not rel_ok:
self.log.warning("Skipping 'TweakRegStep'...")
self.skip = True
for model in images:
model.meta.cal_step.tweakreg = "SKIPPED"
return images
else:
raise e
Expand Down

0 comments on commit 81989c3

Please sign in to comment.