1
! $Id: compute_fits.prg,v 1.2 2011-05-04 08:03:26 midasmgr Exp $
4
! NAME: compute_fits.prg:
5
! Convert FITS to BDF and compute any other need in the BDF image.
7
! USAGE: @@ compute_fits.prg inframe [frame]
9
! @@ compute_fits.prg ff01.fit flat01
10
! @@ compute_fits.prg ff01.mt
11
!*******************************************************************************
15
! p1 REQUIRED: FITS image to be converted
16
! p2 OPTIONAL: BDF image
18
! Edit here to change defaults:
20
DEFINE/PARA p1 ? I "Enter input FITS frame ? "
21
DEFINE/PARA p2 + ? "Enter output BDF frame ? "
23
! Convert paramaters into variables:
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
33
! Gets basename and extension of input file
36
IF ext .eq. ".bdf" THEN
37
WRITE/OUT "{cmd}: ERROR. There is already a file {basename}{ext}"
40
fitsframe = basename + ext
42
! If BDF frame name {p2} is missing, use fitsframe without extension.
48
! Convert the FITS file into a MIDAS .bdf
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
57
! Flip image up/down right/left
58
!-------------------------------
60
! WRITE/OUT "{cmd}: {frame} flipped XY"
62
! write/desc {frame} start/d/1/2 1,1
63
! write/desc {frame} step/d/1/2 1,1
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.
71
! COMPUTE/IMAGE P_{frame} = ({frame} + 32768)
72
! RENAME P_{frame} {frame}
73
! WRITE/OUT "{cmd}: {frame}.bdf added +32768"
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.
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"
92
! ROTATE/CLOCK {frame} R_{frame}
93
! ROTATE/COUNTER_CLOCK {frame} R_{frame}
94
! RENAME R_{frame} {frame}
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.
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"
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
113
! WRITE/OUT "{cmd}: Correcting hot column 381"
114
! MODIFY/COLU {frame} P_{frame} C @381 >NULL
115
! RENAME P_{frame} {frame}
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.
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
127
! Columns 1,2 and 512 in HaleBlue are defect. They are substituted with command
128
! COMPUTE/COLU with adjacents columns.
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
135
! Hot pixel corrections
136
!-------------------------
137
! Fix HOT (saturated) pixels in HALE-Blue
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
145
! Rotating the images from the central pixel (765,65) 0.15 grad in order
147
! WRITE/OUT "{cmd}: Rotating image .15,765,65
148
! REBIN/ROTA {frame} R_{frame} .15,765,65
149
! RENAME R_{frame} {frame}
151
! Cleaning tempoary files
153
! WRITE/OUT {cmd}: Removing temporary files