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

« back to all changes in this revision

Viewing changes to contrib/baches/proc/compute_fits.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
! $Id: compute_fits.prg,v 1.2 2011-05-04 08:03:26 midasmgr Exp $
 
2
!
 
3
! AUTHOR: C.Guirao
 
4
! NAME: compute_fits.prg: 
 
5
!  Convert FITS to BDF and compute any other need in the BDF image.
 
6
 
7
! USAGE: @@ compute_fits.prg inframe [frame]
 
8
! EXAMPLES:
 
9
!  @@ compute_fits.prg ff01.fit flat01
 
10
!  @@ compute_fits.prg ff01.mt
 
11
!*******************************************************************************
 
12
! ECHO/FULL
 
13
!
 
14
! INPUT PARAMS:
 
15
! p1 REQUIRED: FITS image to be converted
 
16
! p2 OPTIONAL: BDF image
 
17
!
 
18
! Edit here to change defaults:
 
19
!
 
20
 DEFINE/PARA p1 ? I "Enter input FITS frame ? "
 
21
 DEFINE/PARA p2 + ? "Enter output BDF frame ? "
 
22
!
 
23
! Convert paramaters into variables:
 
24
!
 
25
 DEFINE/LOCA cmd/c/1/30  "compute_fits.prg"
 
26
 DEFINE/LOCA inframe/c/1/40     {p1}
 
27
 DEFINE/LOCA frame/c/1/40       {p2}
 
28
 DEFINE/LOCA fitsframe/c/1/40
 
29
 DEFINE/LOCA indx/i/1/1         0
 
30
 DEFINE/LOCA basename/c/1/40    "" ? +lower_levels
 
31
 DEFINE/LOCA ext/c/1/10         "" ? +lower_levels
 
32
!
 
33
! Gets basename and extension of input file
 
34
!
 
35
 FILE/BACHES {inframe}
 
36
 IF ext .eq. ".bdf" THEN
 
37
    WRITE/OUT "{cmd}: ERROR. There is already a file {basename}{ext}"
 
38
    RETURN/EXIT   
 
39
 ENDIF
 
40
 fitsframe = basename + ext
 
41
!
 
42
! If BDF frame name {p2} is missing, use fitsframe without extension.
 
43
!
 
44
 IF p2 .eq. "+" THEN
 
45
   frame = basename
 
46
 ENDIF
 
47
!
 
48
! Convert the FITS file into a MIDAS .bdf
 
49
!
 
50
 INDISK/FITS {fitsframe} {frame} >NULL
 
51
 WRITE/OUT "{cmd}: {fitsframe} converted to {frame}.bdf"
 
52
!==========================================================
 
53
! Typical operations in the raw images before proceding with 
 
54
! calibration or pipeline. Uncoment what could apply to your
 
55
! CCD:
 
56
!
 
57
! Flip image up/down right/left
 
58
!-------------------------------
 
59
!
 
60
! WRITE/OUT "{cmd}: {frame} flipped XY"
 
61
! flip/ima {frame} xy
 
62
! write/desc {frame} start/d/1/2 1,1
 
63
! write/desc {frame} step/d/1/2 1,1
 
64
!
 
65
! Convert values to positive range (part1)
 
66
!-------------------------------------------
 
67
! Other controllers (like Hale) generates pixel values in the range
 
68
! -32768 to +32768. This can be fixed with the COMPUTE command
 
69
! by adding 32768 to any value.
 
70
!
 
71
! COMPUTE/IMAGE P_{frame} = ({frame} + 32768)
 
72
! RENAME P_{frame} {frame}
 
73
! WRITE/OUT "{cmd}: {frame}.bdf added +32768"
 
74
!
 
75
!
 
76
! Convert values to positive range (part2)
 
77
!-------------------------------------------
 
78
! Some controllers generates negative numbers for pixel value above half
 
79
! the scale (e.g. in a 16bit controller, the scale goes from 0 to 65536,
 
80
! however any value above 32768 is converted in a negative value so the
 
81
! scale goes from 0 to 32768 and -32768 to 0. This error can be fixed
 
82
! with MIDAS with a REPLACE operation that adds 65536 to any negative value.
 
83
!
 
84
! REPLACE/IMAGE {frame} P_{frame} <,-0.00001={frame}+65536
 
85
! RENAME P_{frame} {frame}
 
86
! WRITE/DESC {frame} LHCUTS/D/1/2 0 all
 
87
! WRITE/OUT "{cmd}: {frame}.bdf negative numbers +65536"
 
88
!
 
89
! Rotation
 
90
!---------
 
91
!
 
92
! ROTATE/CLOCK {frame} R_{frame}
 
93
! ROTATE/COUNTER_CLOCK {frame} R_{frame}
 
94
! RENAME R_{frame} {frame}
 
95
!
 
96
! Flipping images (x, y or both)
 
97
!-------------------------------
 
98
! Other controllers generates images from RB (red to blue) instead of
 
99
! BR (blue to red). They need to be flipped and their START & STEP
 
100
! descriptors to be rewriten.
 
101
!
 
102
! FLIP/IMAG {frame}
 
103
! WRITE/DESC {frame} START/d/1/2 1.,1.
 
104
! WRITE/DESC {frame} STEP/d/1/2 1.,1.
 
105
! WRITE/OUT "{cmd}: flipping {frame} to put blue to left"
 
106
!
 
107
! Correcting hot columns
 
108
!------------------------ 
 
109
! The column 381 is a hot column, it has signal plu an additional constant 
 
110
! offset. It can be corrected with the two columns to the left and two 
 
111
! columns to the right using MODIFY/COLUM
 
112
!
 
113
! WRITE/OUT "{cmd}: Correcting hot column 381"
 
114
! MODIFY/COLU {frame} P_{frame} C @381 >NULL
 
115
! RENAME P_{frame} {frame}
 
116
!
 
117
! Other corrections in columns
 
118
!------------------------------
 
119
! Columns 1,511 and 512 in HaleRed are defect. They are substituted with command
 
120
! COMPUTE/COLU with adjacents columns.
 
121
!
 
122
! WRITE/OUT "{cmd}: Correcting bad columns 1,511 and 512"
 
123
! COMPUTE/COLU {frame}.C1 = C2
 
124
! COMPUTE/COLU {frame}.C511 = C510
 
125
! COMPUTE/COLU {frame}.C512 = C510
 
126
!
 
127
! Columns 1,2 and 512 in HaleBlue are defect. They are substituted with command
 
128
! COMPUTE/COLU with adjacents columns.
 
129
!
 
130
! WRITE/OUT "{cmd}: Correcting bad columns 1,2 and 512"
 
131
! COMPUTE/COLU {frame}.C1 = C3
 
132
! COMPUTE/COLU {frame}.C2 = C3
 
133
! COMPUTE/COLU {frame}.C512 = C511
 
134
!
 
135
! Hot pixel corrections
 
136
!-------------------------
 
137
! Fix HOT (saturated) pixels in HALE-Blue
 
138
!
 
139
! WRITE/OUT "{cmd}: Correcting bad pixels at 149,250 and 149,251"
 
140
! FIXP/BACHES {frame} 149,250
 
141
! FIXP/BACHES {frame} 149,251
 
142
!
 
143
! Rotation
 
144
!-----------
 
145
! Rotating the images from the central pixel (765,65) 0.15 grad in order
 
146
! align the spectra.
 
147
! WRITE/OUT "{cmd}: Rotating image .15,765,65
 
148
! REBIN/ROTA {frame} R_{frame} .15,765,65
 
149
! RENAME R_{frame} {frame}
 
150
!
 
151
! Cleaning tempoary files
 
152
!
 
153
! WRITE/OUT {cmd}: Removing temporary files
 
154
 $rm -f NULL
 
155
 $rm -f midlis*.prg
 
156
!
 
157
! ECHO/OFF