~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to applic/proc/compFITS.prg

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
! @(#)compFITS.prg      19.1 (ESO-DMD) 02/25/03 13:20:07
 
2
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
3
 
4
! Midas application procedure compFITS.prg 
 
5
! K. Banse ESO - Garching  000726, 020229
 
6
 
7
! to compare primary headers of FITS files
 
8
 
9
! execute as: @a compFITS flag file1 file2
 
10
 
11
!         flag = IMAGE, TABLE, FITS or DIFFERENCES,dflag
 
12
 
13
!         if flag = D
 
14
!           dflag = xy, x = 0/1 ignore/not ignore empty lines
 
15
!                       y = 0/1 if no/yes special descriptors in file2
 
16
 
17
!           file1 = name of ASCII file holding already the differences of the
 
18
!                   FITS headers of two FITS images/tables
 
19
 
20
!           if y of dflag = 1, 
 
21
!                   file2 = list of descr.s which may differ and are ignored
 
22
 
23
!         else
 
24
!           file1, file2 = image, table, FITS file names (if flag = I, T, F)
 
25
 
26
!  returns  0, if equal 
 
27
!           1, if not equal
 
28
!          -1, if file open errror
 
29
 
30
! e.g. @a compFITS F lola.mt cuca.mt
 
31
 
32
! ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
33
 
34
define/param p1 image c "Enter flag (IMAGE/TABLE):"
 
35
define/local diffy/c/1/2 00
 
36
set/format i2                           !needed later on for M$PARSE()
 
37
 
38
if p1(1:1) .eq. "D" then
 
39
   define/param p2 middif.dat c "Enter ASCII file name with differences:"
 
40
   define/local diffname/c/1/80 {p2}
 
41
   inputi = m$index(p1,",") + 1
 
42
   if inputi .gt. 2 then
 
43
      inputi(2) = inputi + 1
 
44
      diffy(1:2) = p1({inputi(1)}:{inputi(2)})
 
45
   endif
 
46
!
 
47
else
 
48
   define/local diffname/c/1/80 middif.dat
 
49
   $\rm -f middat1.dat middat2.dat
 
50
   if p1(1:1) .eq. "F" then
 
51
      define/param p2 ? C "Enter first FITS file:"
 
52
      define/param p3 ? C "Enter second FITS file:"
 
53
      intape/fits 1 midd {p2} fnn >middat1.dat
 
54
      intape/fits 1 midd {p3} fnn >middat2.dat
 
55
   !
 
56
   else
 
57
      if p1(1:1) .eq. "I" then
 
58
         define/param p2 ? image "Enter first Midas image:"
 
59
         define/param p3 ? image "Enter second Midas image:"
 
60
      else if p1(1:1) .eq. "T" then
 
61
         define/param p2 ? table "Enter first Midas table:"
 
62
         define/param p3 ? table "Enter second Midas table:"
 
63
      else
 
64
         write/out invalid input flag...
 
65
         return -2
 
66
      endif
 
67
      !
 
68
      write/out converting {p2} and {p3} to FITS format ...
 
69
      outdisk/fits {p2} middf1.fits >Null
 
70
      intape/fits 1 midd middf1.fits fnn >middat1.dat
 
71
      outdisk/fits {p3} middf2.fits >Null
 
72
      intape/fits 1 midd middf2.fits fnn >middat2.dat
 
73
   endif
 
74
   ! 
 
75
   write/out comparing the primary header of these FITS files ...
 
76
   if aux_mode .lt. 2 then
 
77
      write/out Sorry, this procedure has not been updated for VMS yet ...
 
78
      return -1
 
79
   else
 
80
      $diff middat1.dat middat2.dat > {diffname}
 
81
   endif
 
82
endif
 
83
 
84
define/local fc/i/1/2 0,0
 
85
open/file {diffname} read fc
 
86
if fc(1) .lt. 0 then
 
87
   write/out Problems in opening ASCII file "{diffname}"
 
88
   return -1
 
89
endif
 
90
 
91
if diffy(2:2) .eq. "1" then
 
92
   define/local dcount/i/1/1 0
 
93
   dcount = m$parse(p3,"lola")
 
94
   if dcount .gt. 0 then
 
95
      do inputi = 1 dcount
 
96
         define/local compar{inputi}/c/1/9 " " all
 
97
         write/keyw compar{inputi}/c/1/8 {lola{inputi}}
 
98
         compar{inputi}(9:9) = "="
 
99
      enddo
 
100
   else
 
101
      diffy(2:2) = "0"
 
102
   endif
 
103
endif
 
104
 
105
read_loop:
 
106
write/key inputc/c/1/20 " " all
 
107
read/file {fc(1)} inputc 20
 
108
if fc(2) .lt. 0 then
 
109
   close/file {fc(1)}
 
110
   write/out FITS headers are `equal'...
 
111
   return 0
 
112
endif
 
113
 
114
! only DATE and FILENAME should be different, nothing else...
 
115
 
116
if inputc(1:1) .ne. "<" .and. inputc(1:1) .ne. ">" then
 
117
   goto read_loop
 
118
endif
 
119
 
120
if inputc(3:7) .eq. "DATE " goto read_loop
 
121
if inputc(3:11) .eq. "FILENAME=" goto read_loop
 
122
if inputc(3:10) .eq. "HISTORY " goto read_loop
 
123
 
124
if diffy(1:1) .eq. "0" then                     !ignore blank lines
 
125
   if inputc(3:3) .eq. " " goto read_loop
 
126
endif
 
127
if diffy(2:2) .eq. "1" then                     !ignore blank lines
 
128
   do inputi = 1 dcount
 
129
      if inputc(3:10) .eq. compar{inputi}(1:8) goto read_loop
 
130
   enddo
 
131
endif
 
132
 
133
! some other differences found...
 
134
write/out line: \"{inputc(1:20)}\" "        "  is bad...
 
135
close/file {fc(1)}
 
136
return 1
 
137
 
 
138
 
 
139