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

« back to all changes in this revision

Viewing changes to contrib/baches/proc/baches_resolving_power.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: baches_resolving_power.prg,v 1.3 2011-04-06 14:02:41 midasmgr Exp $
 
2
!
 
3
! AUTHOR: A.Modigliani 15.10.07
 
4
!         Modified by C.Guirao 20.10.07
 
5
!
 
6
! NAME: baches_resolving_power.prg
 
7
!    Compute the resolving power based on the spectrum of a calibrated 
 
8
!    thorium lamp
 
9
!
 
10
! INPUT:
 
11
!   - 1-dimensional FITS/BDF image, wavelength calibrated, with the spectrum 
 
12
!     a of thorium lamp
 
13
!   - MIDAS table FITS/TBL with the XSTART and XEND columns of well 
 
14
!     defined 1000 single lines of thorium (default thar_1000lines.fit)
 
15
!
 
16
! REMARKS: 
 
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
 
22
!   CREA/GRAPH
 
23
!   PLOT/AXES 3900,4000 0,1000
 
24
!   OVERPLOT thorium_wrm
 
25
!   CENTER/GAUS GCURSOR thar_lines EMISSION A
 
26
!
 
27
! And select with the cursor, left and right of well defined single lines 
 
28
! (no bend) and rather isoloted from other lines.
 
29
!
 
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
 
40
!
 
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
 
45
!
 
46
! After completing the whole spectral range, rename START and END columns
 
47
! into XSTART and XEND with MIDAS commands:
 
48
!
 
49
!   NAME/COLUMN thar_lines :START :XSTART
 
50
!   NAME/COLUMN thar_lines :END :XEND
 
51
!
 
52
! And convert it to FITS:
 
53
 
54
!   OUTDISK/FITS thar_lines.tbl thorium.fit
 
55
!
 
56
! OUTPUT:
 
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
 
61
!
 
62
! SUFIX CONVENTION:
 
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
 
70
!   m all orders merged
 
71
!   R MIDAS table with computed R (resolving power)
 
72
!
 
73
! USAGE:
 
74
!   RESOLV/BACHES th1_wrm.fit
 
75
!
 
76
! EXAMPLES:
 
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 
 
81
!
 
82
!*******************************************************************************
 
83
! Set ECHO/FULL for debugging purposes
 
84
! ECHO/FULL   
 
85
 
86
! INPUT PARAMS:
 
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"
 
94
 
 
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
 
103
 
 
104
!
 
105
! Other local definitions
 
106
!
 
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
 
110
 
 
111
!
 
112
! Gets basename and extension of 1dim file
 
113
!
 
114
 FILE/BACHES {lamp}
 
115
 frame = basename
 
116
!
 
117
! Convert input 1dim FITS format into MIDAS BDF format
 
118
!
 
119
! ECHO/FULL
 
120
 IF ext .ne. ".bdf" THEN
 
121
   INDISK/FITS {lamp} {frame}
 
122
 ENDIF
 
123
 lamp = frame
 
124
 
 
125
!
 
126
! Convert input FITS format into MIDAS TBL format
 
127
!
 
128
 INDISK/FITS MID_HOME:contrib/baches/demo/{thar_lines}.fit {thar_lines}
 
129
 
 
130
 table = lamp + "R"
 
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
 
135
 
 
136
 DO it = 1 {iter}
 
137
  STATIS/TABL  {table} :resol_power >Null
 
138
  mean = outputr(3)
 
139
  std = outputr(4)
 
140
  SELECT/TABL {table} :resol_power.gt.({mean}-{kappa}*{std}).and.:resol_power.lt.({mean}+{kappa}*{std})
 
141
 ENDDO
 
142
 
 
143
 STATIS/TABL  {table} :resol_power >Null
 
144
 mean = outputr(3)
 
145
 std = outputr(4)
 
146
 CREATE/GRAP
 
147
 SET/GRAP pmode=0
 
148
! SET/GRAP pmode=2
 
149
 PLOT/TABL {table} :XCEN :resol_power
 
150
 LABEL/GRAP "{table}" 5,5,mm 0 1 1
 
151
 
 
152
 COPY/GRAP postscript
 
153
 $ mv postscript.ps {table}.ps
 
154
 
 
155
! READ/TABL {table} :XCEN,resol_power >{table}.txt
 
156
 
 
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}"
 
160
!
 
161
! Clean all temporary files.
 
162
!
 
163
! CLEAN/BACHES
 
164
!
 
165
 ECHO/OFF