1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#! /usr/bin/python3
import sys
import numpy
from astropy.io import fits
numpy.set_printoptions(suppress=True, linewidth=100000)
maxdiff = 3.
reference = numpy.array(fits.open(sys.argv[1])[2].data.tolist())
array = numpy.array(fits.open(sys.argv[2])[2].data.tolist())
if reference.shape != array.shape:
print("Size {}x{} does not match reference shape {}x{}"
.format(array.shape[0], array.shape[1],
reference.shape[0], reference.shape[1]))
sys.exit(1)
# We only check the coordinate columns, as the fluxes seem to be a bit
# unstable
diff = numpy.abs(reference[:,:8] - array[:,:8])
differing_rows = numpy.unique(numpy.where(diff >= maxdiff)[0])
print("Max diff to reference is {}".format(diff.max()))
if len(differing_rows) == 0:
sys.exit(0)
else:
print("Result differs in {} rows from reference:".format(len(differing_rows)))
print(differing_rows)
for row in differing_rows[:5]:
print("\n- " + str(reference[row]))
print("+ " + str(array[row]))
if len(differing_rows) > 5:
print("\n[…]")
sys.exit(1)
|