Skip to content

Commit

Permalink
use ndarray comparison options in wcs comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Oct 16, 2023
1 parent c2671f0 commit 9396086
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions romancal/regtest/regtestdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,26 +633,22 @@ def _wcs_to_ra_dec(wcs):
return wcs(x, y)


class WCSOperator(BaseOperator):
class WCSOperator(NDArrayTypeOperator):
def give_up_diffing(self, level, diff_instance):
# for comparing wcs instances this function evaluates
# each wcs and compares the resulting ra and dec outputs
# TODO should we compare the bounding boxes?
ra_a, dec_a = _wcs_to_ra_dec(level.t1)
ra_b, dec_b = _wcs_to_ra_dec(level.t2)
meta = {}
for name, a, b in [("ra", ra_a, ra_b), ("dec", dec_a, dec_b)]:
# TODO do we want to do something fancier than allclose?
if not np.allclose(a, b):
meta[name] = {
"abs_diff": np.abs(a - b),
}
if meta:
diff_instance.custom_report_result(
"wcs_differ",
level,
meta,
)
ra_diff = self._compare_arrays(ra_a, ra_b)
dec_diff = self._compare_arrays(dec_a, dec_b)
difference = {}
if ra_diff:
difference["ra"] = ra_diff
if dec_diff:
difference["dec"] = dec_diff
if difference:
diff_instance.custom_report_result("wcs_differ", level, difference)
return True


Expand Down Expand Up @@ -712,7 +708,7 @@ def compare_asdf(result, truth, ignore=None, rtol=1e-05, atol=1e-08, equal_nan=T
),
TimeOperator(types=[astropy.time.Time]),
TableOperator(rtol, atol, equal_nan, types=[astropy.table.Table]),
WCSOperator(types=[gwcs.WCS]),
WCSOperator(rtol, atol, equal_nan, types=[gwcs.WCS]),
]
# warnings can be seen in regtest runs which indicate
# that ddtrace logs are evaluated at times after the below
Expand Down

0 comments on commit 9396086

Please sign in to comment.