File: fpdiff

package info (click to toggle)
source-extractor 2.25.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,004 kB
  • sloc: ansic: 39,413; sh: 1,063; makefile: 312; python: 26
file content (38 lines) | stat: -rwxr-xr-x 1,079 bytes parent folder | download | duplicates (2)
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)