1
! $Id: baches_resolving_power.prg,v 1.3 2011-04-06 14:02:41 midasmgr Exp $
3
! AUTHOR: A.Modigliani 15.10.07
4
! Modified by C.Guirao 20.10.07
6
! NAME: baches_resolving_power.prg
7
! Compute the resolving power based on the spectrum of a calibrated
11
! - 1-dimensional FITS/BDF image, wavelength calibrated, with the spectrum
13
! - MIDAS table FITS/TBL with the XSTART and XEND columns of well
14
! defined 1000 single lines of thorium (default thar_1000lines.fit)
17
! How was the file "thar_300.fits" generated? It was initiated with
18
! the spectrum of a very good thorium lamp, e..g thorium_wrm, by ploting
19
! small intervals and identifying with the Thorium Atlas single, strong and
20
! isolated lines. The following MIDAS commands were used:
21
! INDISK/FITS thorium_wrm.fits thar_lines
23
! PLOT/AXES 3900,4000 0,1000
24
! OVERPLOT thorium_wrm
25
! CENTER/GAUS GCURSOR thar_lines EMISSION A
27
! And select with the cursor, left and right of well defined single lines
28
! (no bend) and rather isoloted from other lines.
30
! This generates a thar_lines with the following columns
31
! SHOW/TABL thar_lines
32
! Col.# 1:START Unit:WAVELENGTH Format:F10.3 R*4
33
! Col.# 2:END Unit:WAVELENGTH Format:F10.3 R*4
34
! Col.# 3:CENTER Unit:WAVELENGTH Format:F10.3 R*4
35
! Col.# 4:INT_START Unit:FLUX Format:G15.5 R*4
36
! Col.# 5:INT_END Unit:FLUX Format:G15.5 R*4
37
! Col.# 6:INT_PEAK Unit:FLUX Format:G15.5 R*4
38
! Col.# 7:INT_FIT Unit:FLUX Format:G15.5 R*4
39
! Col.# 8:FWHM Unit:WAVELENGTH Format:F10.3 R*4
41
! By hand, repeat this sequence increasing 100 Angstroms interval, i.e:
42
! PLOT/AXES 4000,4100 0,1000
43
! OVERPLOT thorium_wrm
44
! CENTER/GAUS GCURSOR thar_lines EMISSION A
46
! After completing the whole spectral range, rename START and END columns
47
! into XSTART and XEND with MIDAS commands:
49
! NAME/COLUMN thar_lines :START :XSTART
50
! NAME/COLUMN thar_lines :END :XEND
52
! And convert it to FITS:
54
! OUTDISK/FITS thar_lines.tbl thorium.fit
57
! - MIDAS table (basename of input)R.fit: e.g.
58
! th1_wrm.fit generates th1_wrmR.fit
59
! - If DISPLAY set, it will plot the Resolving Power of all lines, and
60
! generates a PostScript file, e.g. th1_wrmR.ps
63
! b with bias subtraction
64
! d with dark-current subtraction
65
! f with flat-field division
66
! 1 averaged to one-dimensional image
67
! w calibrated in wavelength
68
! r rebined in wavelength
69
! s calibrated in flux with a standard star
71
! R MIDAS table with computed R (resolving power)
74
! RESOLV/BACHES th1_wrm.fit
77
! Typically after the calibration of a thorium lamp (th1.fit):
78
! Midas 001> CALIBRATE/BACHES ff1.fit th1.fit
79
! Midas 002> PIPELINE/BACHES th1.fit
80
! Midas 003> RESOLV/BACHES th1_wrm.fit
82
!*******************************************************************************
83
! Set ECHO/FULL for debugging purposes
87
! p1 REQUIRED: FITS or BDF 1-dimension calibrated spectrum of a thorium lamp
88
! p2 OPTIONAL: FITS or TBL MIDAS table with thorium lines identified with
89
! XSTART and XEND columns. (See REMARKS)
90
DEFINE/PARAM p1 ? I "Enter 1-dimensional image already calibrated of a thorium lamp? "
91
DEFINE/PARAM p2 thar_1000lines tbl "Enter a table of identified thorium lines with XSTART XEND"
92
DEFINE/PARAM p3 2 n "Enter input kappa (kappa-sigma clip)"
93
DEFINE/PARAM p4 5 n "Enter input number of iterations"
95
DEFINE/LOCA lamp/c/1/80 {p1}
96
DEFINE/LOCA thar_lines/c/1/80 {p2}
97
DEFINE/LOCA table/c/1/80
98
DEFINE/LOCA mean/d/1/1 0
99
DEFINE/LOCA std/d/1/1 0
100
DEFINE/LOCA kappa/i/1/1 {p3}
101
DEFINE/LOCA iter/i/1/1 {p4}
102
DEFINE/LOCA it/i/1/1 0
105
! Other local definitions
107
DEFINE/LOCA frame/c/1/40
108
DEFINE/LOCA basename/c/1/40 "" ? +lower_levels
109
DEFINE/LOCA ext/c/1/10 "" ? +lower_levels
112
! Gets basename and extension of 1dim file
117
! Convert input 1dim FITS format into MIDAS BDF format
120
IF ext .ne. ".bdf" THEN
121
INDISK/FITS {lamp} {frame}
126
! Convert input FITS format into MIDAS TBL format
128
INDISK/FITS MID_HOME:contrib/baches/demo/{thar_lines}.fit {thar_lines}
131
CENTER/GAUS {lamp},{thar_lines} {table}
132
COMPUTE/TABL {table} resol_power=:XCEN/:XFWHM
133
NAME/COLU {table} :XCEN "Angstroms"
134
OUTDISK/FITS {table}.tbl {table}.fit
137
STATIS/TABL {table} :resol_power >Null
140
SELECT/TABL {table} :resol_power.gt.({mean}-{kappa}*{std}).and.:resol_power.lt.({mean}+{kappa}*{std})
143
STATIS/TABL {table} :resol_power >Null
149
PLOT/TABL {table} :XCEN :resol_power
150
LABEL/GRAP "{table}" 5,5,mm 0 1 1
153
$ mv postscript.ps {table}.ps
155
! READ/TABL {table} :XCEN,resol_power >{table}.txt
157
WRITE/OUT "Resolving power computed in MIDAS table: {table}.fit"
158
WRITE/OUT "Postscript file generated in {table}.ps"
159
WRITE/OUT "Average (kappa-sigma-cleaned) resolution power: {mean} +/- {std}"
161
! Clean all temporary files.