forked from rasimcoe/FIREHOSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirehose_ld.pro
executable file
·634 lines (505 loc) · 23.6 KB
/
firehose_ld.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
PRO fire_event, ev
COMMON share, splitrow, splitrow_wid, arcmode, flatmode, objmode, extmode, clobber
COMPILE_OPT hidden
func_name = "fire_event"
widget_control, ev.id, get_uvalue=uval ;event handler
;; Programming Note: uvalue here should really be uname! This would have freed up the uvalue slot
;; to be used for other parameter values of any type (whereas uname has to be a string). We'll live
;; with the current convention...
IF N_ELEMENTS(uval) EQ 1 AND size(uval, /type) NE 8 THEN CASE uval OF
'list':
'tab':
;; MENU Buttons
'quit': BEGIN
ans = dialog_message("Quit firehose? ", /Question, /center)
if (ans EQ "Yes") then begin
WIDGET_CONTROL, ev.TOP, /DESTROY
return
endif else begin
WIDGET_CONTROL, ev.top, get_uvalue=s
endelse
END
'raw_pick': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
path=DIALOG_PICKFILE(/Directory, /must_exist, $
title='Please choose raw data directory', path=inipath)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( path ) EQ 1 ) then begin
break
endif else begin
;figure out which setup dir, send the path back to the top
WIDGET_CONTROL, s.raw_wid, set_value=path
spawn, 'pwd', cwd
endelse
END
'redux_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.redux_wid, get_value=inipath
;pick reductions data directory
path=DIALOG_PICKFILE(/Directory, /must_exist, title='Choose reductions data directory', path=inipath)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( path ) EQ 1 ) then begin
break
endif else begin
WIDGET_CONTROL, s.redux_wid, set_value=path
spawn, 'pwd', cwd
endelse
END
'obj_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
;pick reductions data directory
files=DIALOG_PICKFILE(/must_exist, title='Choose Object Files', path=inipath)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( files ) EQ 1 ) then begin
break
endif else begin
for ii=0, n_elements(files)-1 do begin
arr = strsplit(files[ii],"/",/extract)
files[ii] = arr[n_elements(arr)-1]
endfor
WIDGET_CONTROL, s.object_wid, set_value=files
endelse
END
'sky_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
;pick reductions data directory
files=DIALOG_PICKFILE(/must_exist, title='Choose Sky Model File', path=inipath)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( files ) EQ 1 ) then begin
break
endif else begin
for ii=0, n_elements(files)-1 do begin
arr = strsplit(files[ii],"/",/extract)
files[ii] = arr[n_elements(arr)-1]
endfor
WIDGET_CONTROL, s.sky_wid, set_value=files
endelse
END
'arc_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
;pick reductions data directory
files=DIALOG_PICKFILE(/must_exist, title='Choose Arc File', path=inipath)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( files ) EQ 1 ) then begin
break
endif else begin
for ii=0, n_elements(files)-1 do begin
arr = strsplit(files[ii],"/",/extract)
files[ii] = arr[n_elements(arr)-1]
endfor
WIDGET_CONTROL, s.arc_wid, set_value=files
endelse
END
'bflt_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
;pick reductions data directory
files=DIALOG_PICKFILE(/must_exist, title='Choose BLUE Flats', path=inipath, /multiple_files)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( files ) EQ 1 ) then begin
break
endif else begin
for ii=0, n_elements(files)-1 do begin
arr = strsplit(files[ii],"/",/extract)
files[ii] = arr[n_elements(arr)-1]
endfor
WIDGET_CONTROL, s.bflt_wid, set_value=files
endelse
END
'rflt_pick': BEGIN ;; user edits raw dir using browse button
;get IDs from the main widget
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.raw_wid, get_value=inipath
;pick reductions data directory
files=DIALOG_PICKFILE(/must_exist, title='Choose RED Flats', path=inipath, /multiple_files)
;; Check if path is null string (will be true if user hits 'Cancel')
if( is_empty( files ) EQ 1 ) then begin
break
endif else begin
for ii=0, n_elements(files)-1 do begin
arr = strsplit(files[ii],"/",/extract)
files[ii] = arr[n_elements(arr)-1]
endfor
WIDGET_CONTROL, s.rflt_wid, set_value=files
endelse
END
'do_trace': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.rflt_wid, get_value=redflat
WIDGET_CONTROL, s.raw_wid, get_value=rawdir
WIDGET_CONTROL, s.redux_wid, get_value=reduxdir
if (FILE_TEST(strtrim(reduxdir,2)+'/Flat',/DIR) EQ 0) then begin
cmd = "mkdir "+strtrim(reduxdir,2)+'/Flat'
spawn, cmd
endif
redflat = strsplit(redflat, 's', /extract)+'s' ;kludge
if (FILE_TEST(rawdir+'/'+redflat[0])) then begin
tmp = strsplit(redflat[0],'_', /extract)
slitfile = strtrim(reduxdir,2)+'/Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
fire_slitmask, strtrim(rawdir, 2)+redflat[0], slitfile, minslit=50, $
nmed=5, y1=500, y2=2000, nfind=1
xatv, slitfile, /block, min=-1, max=2
endif
END
'do_flat': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.rflt_wid, get_value=redflat
WIDGET_CONTROL, s.bflt_wid, get_value=blueflat
WIDGET_CONTROL, s.arc_wid, get_value=arcfile
WIDGET_CONTROL, s.raw_wid, get_value=rawdir
WIDGET_CONTROL, s.redux_wid, get_value=reduxdir
blueflat = strsplit(blueflat, 's', /extract)+'s' ;kludge
redflat = strsplit(redflat, 's', /extract)+'s' ;kludge
if (FILE_TEST(strtrim(reduxdir,2)+'Flat',/DIR) EQ 0) then begin
cmd = "mkdir "+strtrim(reduxdir,2)+'/Flat'
spawn, cmd
endif else begin
; Construct file name for arc image
tmp = strsplit(arcfile,'_', /extract)
wavefile = strtrim(reduxdir,2)+'Arcs/ArcImg_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for slits
tmp = strsplit(redflat[0],'_', /extract)
slitfile = strtrim(reduxdir,2)+'Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
pixflatfile = strtrim(reduxdir,2)+'Flat/PixFlat_'+strtrim(tmp[n_elements(tmp)-1],2)
if (FILE_TEST(rawdir+redflat[0]) AND $
FILE_TEST(rawdir+blueflat[0])) then begin
tmp = strsplit(redflat[0],'_', /extract)
Flat = strtrim(reduxdir,2)+'Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
if (flatmode EQ 0) then begin
chk = 0
endif else begin
chk = 1
endelse
if ((size(splitrow))[0] EQ 1) then splitrow = splitrow[0]
fire_superflat_ld, blue=blueflat, red=redflat, $
raw=rawdir, slitfile=slitfile, splitrow=splitrow, $
outpix=pixflatfile, $
wavefile=wavefile, CHK=chk
endif
endelse
END
'do_arc': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.arc_wid, get_value=arcfile
WIDGET_CONTROL, s.raw_wid, get_value=rawdir
WIDGET_CONTROL, s.redux_wid, get_value=reduxdir
WIDGET_CONTROL, s.rflt_wid, get_value=redflat
linelist = 'NeAr_fire2.lst'
redflat = strsplit(redflat, 's', /extract)+'s' ;kludge
if (FILE_TEST(strtrim(reduxdir,2)+'Arcs',/DIR) EQ 0) then begin
cmd = "mkdir "+strtrim(reduxdir,2)+'/Arcs'
spawn, cmd
endif
; Construct file name for arc image
tmp = strsplit(arcfile,'_', /extract)
wavefile = strtrim(reduxdir,2)+'Arcs/ArcImg_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for slits
tmp = strsplit(redflat[0],'_', /extract)
slitfile = strtrim(reduxdir,2)+'Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
fire_wavesolve_ld, rawdir+arcfile, wavefile, slitfile=slitfile, $
linelist=linelist, /chk
END
'do_findobj': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.arc_wid, get_value=arcfile
WIDGET_CONTROL, s.object_wid, get_value=scifile
WIDGET_CONTROL, s.sky_wid, get_value=skyfile
WIDGET_CONTROL, s.raw_wid, get_value=rawdir
WIDGET_CONTROL, s.redux_wid, get_value=reduxdir
WIDGET_CONTROL, s.rflt_wid, get_value=redflat
redflat = strsplit(redflat, 's', /extract)+'s' ;kludge
linelist = 'NeAr_fire2.lst'
if (FILE_TEST(strtrim(reduxdir,2)+'Object',/DIR) EQ 0) then begin
cmd = "mkdir "+strtrim(reduxdir,2)+'/Object'
spawn, cmd
endif
if (FILE_TEST(strtrim(reduxdir,2)+'Final',/DIR) EQ 0) then begin
cmd = "mkdir "+strtrim(reduxdir,2)+'/Final'
spawn, cmd
endif
; Construct file name for science object image
scifile = rawdir+scifile
if (strlen(skyfile) NE 0) then begin
skyfile = rawdir+skyfile
endif
; Construct file name for arc image
tmp = strsplit(arcfile,'_', /extract)
wavefile = strtrim(reduxdir,2)+'Arcs/ArcImg_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for slits
tmp = strsplit(redflat[0],'_', /extract)
slitfile = strtrim(reduxdir,2)+'Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
pixflatfile = strtrim(reduxdir,2)+'Flat/PixFlat_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for output
tmp = strsplit(scifile,'_', /extract)
outfile = strtrim(reduxdir,2)+'Final/F_'+strtrim(tmp[n_elements(tmp)-1],2)
if (objmode GT 0) then begin
chk = 1
if (objmode EQ 2) then begin
interactive = 1 ; User forced aperture
endif
if (objmode EQ 3) then begin
interactive = 2 ; user initial guess aperture
endif
endif else begin
chk = 0
endelse
if (file_test(skyfile) EQ 0) then begin
fire_findobj_ld, scifile, outfile, slitfile=slitfile, $
wavefile=wavefile, pixflatfile=pixflatfile, $
illumflatfile=illumflatfile, /nohelio, CHK=chk, $
/trcchk,$
/noshift, interactive=interactive
endif else begin
fire_findobj_ld, scifile, outfile, slitfile=slitfile, $
wavefile=wavefile, pixflatfile=pixflatfile, $
illumflatfile=illumflatfile, /nohelio, CHK=chk, $
/trcchk,skyframe=skyfile, $
/noshift, interactive=interactive
endelse
END
'do_extract': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.arc_wid, get_value=arcfile
WIDGET_CONTROL, s.object_wid, get_value=scifile
WIDGET_CONTROL, s.raw_wid, get_value=rawdir
WIDGET_CONTROL, s.redux_wid, get_value=reduxdir
WIDGET_CONTROL, s.rflt_wid, get_value=redflat
redflat = strsplit(redflat, 's', /extract)+'s' ;kludge
; Construct file name for science object image
scifile = rawdir+scifile
; Construct file name for arc image
tmp = strsplit(arcfile,'_', /extract)
wavefile = strtrim(reduxdir,2)+'/Arcs/ArcImg_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for slits
tmp = strsplit(redflat[0],'_', /extract)
slitfile = strtrim(reduxdir,2)+'/Flat/Slit_'+strtrim(tmp[n_elements(tmp)-1],2)
pixflatfile = strtrim(reduxdir,2)+'/Flat/PixFlat_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for output
tmp = strsplit(scifile,'_', /extract)
outfile = strtrim(reduxdir,2)+'/Final/F_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for output of structure
obj_filename = strtrim(reduxdir,2)+'/Object/ObjStr_'+strtrim(tmp[n_elements(tmp)-1],2)
; Construct file name for SpeX-style output
; (i.e. input for xtellcor)
spexfile = strtrim(reduxdir,2)+'/Object/Spec_'+strtrim(tmp[n_elements(tmp)-1],2)
if (extmode EQ 0) then begin
boxcar = 0
nolocal = 0
endif else begin
boxcar = (extmode GT 0) ? 1 : 0
nolocal = (extmode EQ 2) ? 1 : 0
endelse
fire_extract_ld, scifile, outfile, slitfile=slitfile, $
wavefile=wavefile, pixflatfile=pixflatfile, $
illumflatfile=illumflatfile, /nohelio, /chk, /trcchk,$
/noshift, /nozap, spex_filename=spexfile, obj_filename=obj_filename $
,BOXCAR=boxcar, NOLOCAL=nolocal, islit=1
END
'set_prefs': BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
firehose_ld_setprefs, s
END
ELSE: BEGIN
WIDGET_CONTROL, ev.top, get_uvalue=s
; stop
END
ENDCASE
WIDGET_CONTROL, ev.top, get_uvalue=s
WIDGET_CONTROL, s.redux_wid, get_value=reduxpath
END
;;-----------------------------------------------------------------
pro firehose_ld_setprefs_event, ev
common share
WIDGET_CONTROL, ev.top, get_uvalue = state, /no_copy
WIDGET_CONTROL, ev.id, get_uvalue = uval
case uval of
'quit_prefs' : begin
widget_control, ev.top, /destroy
return
end
'arc_dropbox' : begin
arcmode = ev.index
return
END
'obj_dropbox' : begin
objmode = ev.index
return
END
'flat_dropbox' : begin
flatmode = ev.index
return
END
'ext_dropbox' : begin
extmode = ev.index
return
END
'edit_splitrow' : begin
widget_control, splitrow_wid, get_value=tmp
splitrow = tmp
return
end
'set_clob': begin
clobber = ev.select
return
end
else:
endcase
WIDGET_CONTROL, ev.top, set_uvalue = state, /no_copy
return
end
pro firehose_ld_setprefs, state
common share
prefsbase = WIDGET_BASE( title = 'FIREHOSE Preferences', /column, $
xoffset=xoffset,yoffset=yoffset)
arcbase = WIDGET_BASE(prefsbase, title = 'Arc Solution Preferences', /column, /frame)
msg = WIDGET_LABEL(arcbase, Value='Arc Line Identification')
st1 = widget_base(arcbase, /row)
text = widget_label(st1, Value="User Interaction: ")
arc_options = ["Fully Automated", "User Reidentify"]
arcchoose = WIDGET_COMBOBOX(st1, uname='slit_tab',Value=arc_options, uval='arc_dropbox')
WIDGET_CONTROL, arcchoose, set_combobox_select=arcmode
wpix_help = widget_button(st1,value="?", uval='wpix_help')
flatbase = WIDGET_BASE(prefsbase, title = 'Flat Fielding Preferences', /column, /frame)
msg = WIDGET_LABEL(flatbase, Value='Flat Field Preferences')
ft1 = widget_base(flatbase, /row)
text = widget_label(ft1, Value="User Interaction: ")
flat_options = ["Fully Automated", "User Inspect"]
flatchoose = WIDGET_COMBOBOX(ft1, uname='slit_tab',Value=flat_options, uval='flat_dropbox')
WIDGET_CONTROL, flatchoose, set_combobox_select=flatmode
wpix_help = widget_button(ft1,value="?", uval='flat_help')
ft2 = widget_base(flatbase, /row)
text = wIdget_label(ft2, Value="Red/Blue transition row: ")
splitrow_wid = widget_text(ft2, Value=strtrim(splitrow,2), xsize=7, /editable, /all_events, uvalue='edit_splitrow')
splitrow_help = widget_button(ft2,value="?", uval='splitrow_help')
objbase = WIDGET_BASE(prefsbase, title = 'Object Finding Preferences', /column, /frame)
msg = WIDGET_LABEL(objbase, Value='Object Finding Preferences')
ot1 = widget_base(objbase, /row)
text = widget_label(ot1, Value="User Interaction: ")
obj_options = ["Fully Automated", "Inspect Results", "User Specify", "User Initial Guess"]
objchoose = WIDGET_COMBOBOX(ot1, uname='obj_options',Value=obj_options, uval='obj_dropbox')
WIDGET_CONTROL, objchoose, set_combobox_select=objmode
obj_help = widget_button(ot1,value="?", uval='obj_help')
extbase = WIDGET_BASE(prefsbase, title = 'Extraction Preferences', /column, /frame)
msg = WIDGET_LABEL(extbase, Value='Extraction Preferences')
et1 = widget_base(extbase, /row)
text = widget_label(et1, Value="Extraction style: ")
ext_options = ["Optimal Weighting", "Boxcar (with local skysub)","Boxcar (no local skysub)"]
extchoose = WIDGET_COMBOBOX(et1, uname='ext_options',Value=ext_options, uval='ext_dropbox')
WIDGET_CONTROL, extchoose, set_combobox_select=extmode
ext_help = widget_button(et1,value="?", uval='ext_help')
clobbase = WIDGET_BASE(prefsbase, title = 'Clobber', /col, /frame)
msg = WIDGET_LABEL(clobbase, Value='Overwrite existing extractions?')
cb1 = widget_base(clobbase, /row, /nonexclusive)
clobberbt = WIDGET_BUTTON(cb1, Value='Clobber', uname='clob', uvalue='set_clob', TOOLTIP='Delete files.')
widget_control, clobberbt, Set_Button=clobber ;Keep 'not loud' as a default
prefsquit = WIDGET_BUTTON(prefsbase, Value='Exit Prefs', uvalue='quit_prefs')
WIDGET_CONTROL, prefsbase, set_uval=state
WIDGET_CONTROL, prefsbase, /realize
xmanager, 'firehose_ld_setprefs', prefsbase
END
;;-----------------------------------------------------------------
;;-----------------------------------------------------------------
;;-----------------------------------------------------------------
;Main program
PRO firehose_ld
COMMON share, splitrow, splitrow_wid, arcmode, flatmode, objmode, extmode, clobber
main = widget_base(/Col, Title='FIREHOSE Low-Dispersion', MBAR=bar) ; main base
;; MENU BUTTONS
;; File
menu1 = WIDGET_BUTTON(bar, VALUE='File', /MENU)
bquit = WIDGET_BUTTON(menu1, VALUE='Quit', uvalue='quit', accelerator="Ctrl+Q")
;; Options
menu2 = WIDGET_BUTTON(bar, VALUE='Options', /MENU)
bpwd = WIDGET_BUTTON(menu2, VALUE='Preferences', uvalue='set_prefs')
;; ;; Display
;; menu3 = WIDGET_BUTTON(bar, VALUE='Display', /MENU)
;; bpwd = WIDGET_BUTTON(menu3, VALUE='Current working directory', uvalue='pwd')
;; braw = WIDGET_BUTTON(menu3, VALUE='Current Raw data directory', uvalue='raw_pick', accelerator="Ctrl+D")
;; bcontents = WIDGET_BUTTON(menu3, VALUE='Contents', uvalue='pwd', /MENU)
;; barcsdir = WIDGET_BUTTON(bcontents, VALUE='Arcs/', uvalue='arcsdir')
;; bfinaldir = WIDGET_BUTTON(bcontents, VALUE='Final/', uvalue='finaldir')
;; bflatdir = WIDGET_BUTTON(bcontents, VALUE='Flat/', uvalue='flatdir')
;; bobjectdir = WIDGET_BUTTON(bcontents, VALUE='Object/', uvalue='objectdir')
;; btimesaved = WIDGET_BUTTON(menu3, VALUE='Time firestrct last saved', uvalue='timesaved')
;; Help
bhelp = WIDGET_BUTTON(bar, Value='Help', /help)
babout = WIDGET_BUTTON(bhelp, VALUE='About FIREHOSE', uvalue='about')
bwebsite = WIDGET_BUTTON(bhelp, VALUE='FIRE website', uvalue='website')
bfirehelp = WIDGET_BUTTON(bhelp, Value='Help with Sections', uvalue='fire help', /MENU)
bhelpsetup = WIDGET_BUTTON(bfirehelp, Value='Setup', uvalue='setup help')
bhelptrace = WIDGET_BUTTON(bfirehelp, Value='Trace', uvalue='trace help')
bhelpflats = WIDGET_BUTTON(bfirehelp, Value='Flats', uvalue='flats help')
bhelpstructure = WIDGET_BUTTON(bfirehelp, Value='Structure', uvalue='structure help')
bhelpextract = WIDGET_BUTTON(bfirehelp, Value='Extract', uvalue='extract help')
bhelptelluric = WIDGET_BUTTON(bfirehelp, Value='Telluric', uvalue='telluric help')
bhelpcombine = WIDGET_BUTTON(bfirehelp, Value='Combine', uvalue='combine help')
bhelpquicklook = WIDGET_BUTTON(bfirehelp, Value='Quicklook', uvalue='quicklook help')
bhotkeys = WIDGET_BUTTON(bhelp, Value='Hot keys list', uvalue='hot keys')
;------------------------------------------------
wt1a = Widget_base(main, /row)
spawn, "pwd", reduxdir
reduxdir = reduxdir+"/"
spawn, "cd ..; pwd", backdir
if (file_test(backdir+"/Raw") GT 0) then begin
rawdir = backdir+"/Raw/"
endif
setup_label = WIDGET_LABEL(wt1a, Value='Raw Directory ')
raw_wid = WIDGET_TEXT(wt1a, /editable, xsize=35, value=rawdir, uname='rawdir')
setupbt = WIDGET_BUTTON(wt1a, Value='Browse', uval='raw_pick')
wt1b = Widget_base(main, /row)
redux_label = WIDGET_LABEL(wt1b, Value='Redux Directory ')
redux_wid = WIDGET_TEXT(wt1b, /editable, xsize=35, value=reduxdir, uvalue='reduxdir')
reduxbt = WIDGET_BUTTON(wt1b, Value='Browse', uvalue='redux_pick')
wt1c = Widget_base(main, /row)
obj_label = WIDGET_LABEL(wt1c, Value='Object File ')
object_wid = WIDGET_TEXT(wt1c, /editable, xsize=35, value=object, uvalue='objfile')
objectbt = WIDGET_BUTTON(wt1c, Value='Browse', uvalue='obj_pick')
wt1c2 = Widget_base(main, /row)
sky_label = WIDGET_LABEL(wt1c2, Value='Sky (optional) ')
sky_wid = WIDGET_TEXT(wt1c2, /editable, xsize=35, value=object, uvalue='skyfile')
skybt = WIDGET_BUTTON(wt1c2, Value='Browse', uvalue='sky_pick')
wt1d = Widget_base(main, /row)
arc_label = WIDGET_LABEL(wt1d, Value='Arc File ')
arc_wid = WIDGET_TEXT(wt1d, /editable, xsize=35, value=arc_list, uvalue='arcfile')
arcbt = WIDGET_BUTTON(wt1d, Value='Browse', uvalue='arc_pick')
wt1e = Widget_base(main, /row)
bflat_label = WIDGET_LABEL(wt1e, Value='Blue Flat File ')
bflt_wid = WIDGET_TEXT(wt1e, /editable, xsize=35, value=bflat_list, uvalue='bfltfile')
bflatbt = WIDGET_BUTTON(wt1e, Value='Browse', uvalue='bflt_pick')
wt1f = Widget_base(main, /row)
rflat_label = WIDGET_LABEL(wt1f, Value='Red Flat File ')
rflt_wid = WIDGET_TEXT(wt1f, /editable, xsize=35, value='', uvalue='rfltfile')
rflatbt = WIDGET_BUTTON(wt1f, Value='Browse', uvalue='rflt_pick')
wt1g = Widget_base(main, /col)
tracebt = WIDGET_BUTTON(wt1g, Value='Trace Slit', uvalue='do_trace')
doarcbt = WIDGET_BUTTON(wt1g, Value='Solve Arc', uvalue='do_arc')
mkflatbt = WIDGET_BUTTON(wt1g, Value='Make Flat', uvalue='do_flat')
fndobjbt = WIDGET_BUTTON(wt1g, Value='Find Object', uvalue='do_findobj')
extractbt = WIDGET_BUTTON(wt1g, Value='Extract', uvalue='do_extract')
widget_control, main, /realize ; create the widgets
; object = ''
; bflat = ''
; rflat = ''
; arc = ''
arcmode = 1
flatmode = 1
splitrow = 1150
objmode = 1
extmode = 0
clobber = 0
state = {raw_wid:raw_wid,redux_wid:redux_wid, object_wid:object_wid, sky_wid:sky_wid, bflt_wid:bflt_wid, rflt_wid:rflt_wid,arc_wid:arc_wid}
widget_control, main, set_uvalue = state
;I think this makes the draw window the spot for plotting
;widget_control, draw, get_value=window
;wset, window
xmanager, 'fire', main , /no_block ; wait for events
END