ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/proj/flatfield/off_flat_IDL/selectnames_fsn.pro
Revision: 1.1
Committed: Fri Feb 18 00:26:40 2011 UTC (12 years, 7 months ago) by richard
Branch: MAIN
CVS Tags: Ver_6-0, Ver_6-1, Ver_6-2, Ver_6-3, Ver_6-4, Ver_9-1, Ver_5-14, Ver_5-13, Ver_LATEST, Ver_9-3, Ver_9-41, Ver_9-2, Ver_8-8, Ver_8-2, Ver_8-3, Ver_8-0, Ver_8-1, Ver_8-6, Ver_8-7, Ver_8-4, Ver_8-5, Ver_7-1, Ver_7-0, Ver_9-5, Ver_9-4, Ver_8-10, Ver_8-11, Ver_8-12, Ver_9-0, HEAD
Log Message:
IDL package to calculate offpoint flatfield, dark frames, and bad pixel lists from spacecraft offpoints
2011.02.17

File Contents

# Content
1 pro selectnames_fsn,names,series, first,last,nfiles,keepdup=keepdup
2
3 ; keepdup ne zero keeps duplicates
4
5 if (n_elements(keepdup) eq 0) then keepdup=0
6
7
8 dir='DS'
9
10 if (dir eq '') then begin
11 spawn,'hostname',host
12 res=stregex(host(0),'.edu',/fold_case,/boolean)
13 if res then begin
14 dir='DRMS'
15 endif else begin
16 spawn,'ls -1td /hmi0/egse/logs/200* | head -1',help
17 dir=help(0)
18 end
19 end
20
21 if ((dir eq 'DRMS') or (dir eq 'WD') or (dir eq 'DS') or (dir eq 'lev0d') or (dir eq 'lev0e') or (dir eq 'lev0d_test') or (dir eq 'lev0f') or (dir eq 'lev0') or (dir eq 'lev1a_nrt')) then begin
22 if (dir eq 'DS') then begin
23 ds=series
24 end
25
26 ; first=0l
27 ; read,first,prompt='First FSN: '
28 ; last=0l
29 ; read,last,prompt='Last FSN: '
30 if (dir eq 'DRMS') then begin
31 spawn,'show_info ds=hmi_ground.lev0\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,EXTRA_INT_B,T_OBS seg=file -p -r -q',list
32 spawn,'echo $$',pid
33 openw,lun,'/tmp/show_'+pid,/append,/get_lun
34 printf,lun,list
35 printf,lun
36 close,lun
37 nlist=n_elements(list)
38 rec=lonarr(nlist)
39 fsn=lonarr(nlist)
40 miss=lonarr(nlist)
41 tobs=strarr(nlist)
42 names=strarr(nlist)
43 for i=0,nlist-1 do begin
44 help=strsplit(list(i),/extract)
45 rec(i)=help(0)
46 fsn(i)=help(1)
47 miss(i)=help(2)
48 tobs(i)=help(3)
49 names(i)=help(4)
50 end
51 endif else if (dir eq 'lev0d') then begin
52 spawn,'show_info ds=hmi.lev0d\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
53 nlist=n_elements(list)
54 rec=lonarr(nlist)
55 fsn=lonarr(nlist)
56 miss=lonarr(nlist)
57 tobs=strarr(nlist)
58 names=strarr(nlist)
59 for i=0,nlist-1 do begin
60 help=strsplit(list(i),/extract)
61 rec(i)=help(0)
62 fsn(i)=help(1)
63 miss(i)=help(2)
64 tobs(i)=help(3)
65 names(i)=help(4)+'/image.fits'
66 end
67 endif else if (dir eq 'lev0e') then begin
68 spawn,'show_info ds=hmi.lev0e\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
69 nlist=n_elements(list)
70 rec=lonarr(nlist)
71 fsn=lonarr(nlist)
72 miss=lonarr(nlist)
73 tobs=strarr(nlist)
74 names=strarr(nlist)
75 for i=0,nlist-1 do begin
76 help=strsplit(list(i),/extract)
77 rec(i)=help(0)
78 fsn(i)=help(1)
79 miss(i)=help(2)
80 tobs(i)=help(3)
81 names(i)=help(4)+'/image.fits'
82 end
83 endif else if (dir eq 'lev0f') then begin
84 spawn,'show_info ds=hmi.lev0f\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
85 nlist=n_elements(list)
86 rec=lonarr(nlist)
87 fsn=lonarr(nlist)
88 miss=lonarr(nlist)
89 tobs=strarr(nlist)
90 names=strarr(nlist)
91 for i=0,nlist-1 do begin
92 help=strsplit(list(i),/extract)
93 rec(i)=help(0)
94 fsn(i)=help(1)
95 miss(i)=help(2)
96 tobs(i)=help(3)
97 names(i)=help(4)+'/image.fits'
98 end
99 endif else if (dir eq 'lev0') then begin
100 spawn,'show_info ds=hmi.lev0\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
101 nlist=n_elements(list)
102 rec=lonarr(nlist)
103 fsn=lonarr(nlist)
104 miss=lonarr(nlist)
105 tobs=strarr(nlist)
106 names=strarr(nlist)
107 for i=0,nlist-1 do begin
108 help=strsplit(list(i),/extract)
109 rec(i)=help(0)
110 fsn(i)=help(1)
111 miss(i)=help(2)
112 tobs(i)=help(3)
113 names(i)=help(4)+'/image.fits'
114 end
115 endif else if (dir eq 'lev1a_nrt') then begin
116 spawn,'show_info ds=hmi.lev1a_nrt\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
117 nlist=n_elements(list)
118 rec=lonarr(nlist)
119 fsn=lonarr(nlist)
120 miss=lonarr(nlist)
121 tobs=strarr(nlist)
122 names=strarr(nlist)
123 for i=0,nlist-1 do begin
124 help=strsplit(list(i),/extract)
125 rec(i)=help(0)
126 fsn(i)=help(1)
127 miss(i)=help(2)
128 tobs(i)=help(3)
129 names(i)=help(4)+'/image.fits'
130 end
131 endif else if (dir eq 'lev0d_test') then begin
132 spawn,'show_info ds=su_production.lev0d_test\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
133 nlist=n_elements(list)
134 rec=lonarr(nlist)
135 fsn=lonarr(nlist)
136 miss=lonarr(nlist)
137 tobs=strarr(nlist)
138 names=strarr(nlist)
139 for i=0,nlist-1 do begin
140 help=strsplit(list(i),/extract)
141 rec(i)=help(0)
142 fsn(i)=help(1)
143 miss(i)=help(2)
144 tobs(i)=help(3)
145 names(i)=help(4)+'/image.fits'
146 end
147 endif else if (dir eq 'DS') then begin
148 spawn,'show_info ds='+ds+'\['+strcompress(string(first)+'-'+string(last),/remove_all)+'\] key=FSN,MISSVALS,T_OBS -p -r -q',list
149 nlist=n_elements(list)
150 rec=lonarr(nlist)
151 fsn=lonarr(nlist)
152 miss=lonarr(nlist)
153 tobs=strarr(nlist)
154 names=strarr(nlist)
155 for i=0,nlist-1 do begin
156 help=strsplit(list(i),/extract)
157 rec(i)=help(0)
158 fsn(i)=help(1)
159 miss(i)=help(2)
160 tobs(i)=help(3)
161 names(i)=help(4)+'/image.fits'
162 end
163 end else begin ; WD
164 wdname='qqq'
165 read,wdname,prompt='File to read from: '
166 if (wdname eq '') then wdname='/hmi0/egse/logs/wdlog'
167 ; spawn,'wc -l ' +wdname,help
168 spawn,'grep -v # '+wdname+' | wc -l ',help
169 nlist0=long(help[0])
170 rec0=lonarr(nlist0)
171 fsn0=lonarr(nlist0)
172 names0=strarr(nlist0)
173 fname='qqq'
174 openr,1,wdname
175 for i=0,nlist0-1 do begin
176 repeat begin
177 readf,1,fname
178 endrep until (stregex(fname,'#') eq -1)
179 rec0(i)=i
180 fsplit=strsplit(fname,'/.',/extract)
181 fsn0(i)=long((fsplit)[n_elements(fsplit)-2])
182 names0(i)=fname
183 end
184 close,1
185 w=where((fsn0 ge first) and (fsn0 le last),nlist)
186 sw=w(sort(fsn0(w)))
187 rec=rec0(sw)
188 fsn=fsn0(sw)
189 miss=lonarr(nlist)
190 tobs=strarr(nlist)
191 names=names0(sw)
192 fname='qqq'
193 for i=0,nlist-1 do begin
194 fname=names(i)
195 q=readfits(fname,hdr,nslice=0,/silent)
196 miss(i)=sxpar(hdr,'MISSVALS')
197 tobs(i)=sxpar(hdr,'DATE')
198 end
199 end
200 hfsn=histogram(fsn,min=0)
201 w=where(hfsn ne 0,nfiles)
202 if ((nfiles ne nlist) and (keepdup eq 0)) then begin
203 print,'Duplicates found'
204 ix=lonarr(nfiles)
205 for i=0,nfiles-1 do begin
206 ii=w(i)
207 w1=where(fsn eq ii,n1)
208 if (n1 eq 1) then begin ; Only one record number with this FSN
209 ix(i)=w1
210 endif else begin
211 ; w0=w1(where(miss(w1) eq 0,n0))
212 ww=where(miss(w1) eq 0,n0)
213 if (n0 ne 0) then w0=w1(ww)
214 if (n0 eq 0) then begin ; No good ones.
215 print,'All bad. Taking latest for FSN',ii
216 ix(i)=where(rec eq max(rec(w1))) ; Take latest file
217 end
218 if (n0 eq 1) then begin ; Only one good one.
219 print,'Taking only complete image for FSN',ii
220 ix(i)=w1(where(miss(w1) eq 0))
221 end
222 if (n0 gt 1) then begin ; Multiple good ones.
223 print,'Several good images. Taking latest for FSN',ii
224 ix(i)=w0(where(rec eq max(rec(w0)))) ; Take latest file
225 end
226 end
227 end
228 names=names(ix)
229 miss=miss(ix)
230 end
231 nfiles=nlist
232 print,'Found',nfiles,' files'
233 end else begin ; regular directory
234 dir=dir+'/'
235 spawn,'ls -1 '+dir,list0
236 repeat begin
237 name='qqq'
238 read,name,prompt='First file: '
239 if (name eq '') then name='i_.*\.fit'
240 whit=where(stregex(list0,name,/boolean) ne 0,nhit)
241 if (nhit eq 0) then begin
242 print,'No matches'
243 endif else begin
244 list=list0(whit)
245 if (nhit eq 1) then print,'Found file: '+list(0)
246 if (nhit ge 2) then begin
247 print,'Found multiple files:'
248 print,list
249 end
250 end
251 endrep until (nhit eq 1)
252 ifirst=whit(0)
253
254 repeat begin
255 name='qqq'
256 read,name,prompt='Last file: '
257 if (name eq '') then name='i_.*\.fit'
258 whit=where(stregex(list0,name,/boolean) ne 0,nhit)
259 if (nhit eq 0) then begin
260 print,'No matches'
261 endif else begin
262 list=list0(whit)
263 if (nhit eq 1) then print,'Found file: '+list(0)
264 if (nhit ge 2) then begin
265 print,'Found multiple files:'
266 print,list
267 end
268 end
269 endrep until (nhit eq 1)
270 ilast=whit(0)
271
272 names=dir+list0(ifirst:ilast)
273 nfiles=ilast-ifirst+1
274 print,'Found',nfiles,' files'
275 end
276
277 end
278