aboutsummaryrefslogtreecommitdiff
path: root/scripts/calfuse.wavecal
blob: eae465307ad2d495464b3d52f1a44cd1b638d70a (plain) (blame)
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
#!/usr/local/bin/tcsh -f
#******************************************************************************
#*              Johns Hopkins University 
#*              Center For Astrophysical Sciences
#*              FUSE
#******************************************************************************
#*
#* Synopsis:    calfuse.wavecal file_name 
#*
#* Description: Shell script for processing FUSE Ver 3.0 time-tagged exposures.
#*		All messages are written to stdout or stderr.
#*
#*		WARNING: THIS VERSION IS OPTIMIZED FOR PROCESSING WAVELENGTH
#*		CALIBRATION DATA!!!
#*
#* Arguments:   char    file_name	File name to process is 1st command-
#*                                      line argument
#*
#* Returns:     Exit codes:
#*			0		Successful execution
#*			
#*
#* Environment variables:  CF_CALDIR    Path to directory which contains the
#*                                      calibration files.
#*                         CF_IDLDIR    Path to CalFUSE IDL directory
#*                         CF_PIPELINE  Flag to determine if CALFUSE
#*                                      is running as part of the JHU 
#*                                      pipeline.
#*
#* History:     02/26/03   1.1   peb    Begin work on V3.0
#*		03/19/03   1.2   wvd	Add IDL plots
#*              03/31/03   1.3   peb    Add cf_ttag_countmap/gainmap programs
#*                                      and changed the timestamp format to be
#*                                      similar to cf_timestamp
#*		05/16/03   1.4   wvd	Distinguish between TTAG and HIST files.
#*					Changed name to calfuse.csh
#*		05/22/03   1.5   wvd	Direct STDERR to trailer file.
#*              06/03/03   1.6   rdr    Incorporated bad pixel map
#*              06/09/03   1.7   rdr    Do not screen on timing flags for HIST
#*                                      data processed behind the firewall
#*		07/31/03   1.8   wvd	Check error status before exiting.
#*		09/15/03   1.9   wvd	Write BEGIN and END stmts to logfile.
#*		12/08/03   1.10  wvd	For HIST data, always call
#*					cf_extract_spectra and cf_bad_pixels
#*					with -s option.
#*		12/21/03   1.13  wvd	Remove underscore from idf and bpm
#*					filenames.
#*		04/22/04   1.12  wvd	Change name of trailer file to
#*					{$froot}.trl
#*		05/12/04   1.13  wvd	Remove cf_ttag_countmap and
#*					cf_ttag_gainmap from pipeline.
#*		06/01/04   1.14  wvd	For HIST data, no longer need to call
#*					cf_extract_spectra with -s option.
#*		06/03/04   1.15  wvd	Screening step now follows "Convert
#*					to FARF."
#*
#*****************************************************************************/

set idf     = ${1:s/raw/idf/}
set froot   = ${1:s/raw.fit//}
set logfile = {$froot}.trl
set ttag    = `echo $froot | grep -c ttag` 

# Put a time stamp in the log file (the OPUS trailer file).
if $ttag then
    echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Begin  TTAG file $1"
    echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Begin TTAG file $1" >>& $logfile
else
    echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Begin  HIST file $1"
    echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Begin HIST file $1" >>& $logfile
endif

set cfstat=0

# Step 1  --  Generate Intermediate Data File
if $ttag then
    cf_ttag_init            $1    $idf    >>& $logfile
    set cfstat=$status
else
    cf_hist_init            $1    $idf    >>& $logfile
    set cfstat=$status
endif

# Step 2  --  Convert to FARF
if ! $cfstat then
    cf_convert_to_farf        $idf    >>& $logfile
    set cfstat=$status
endif

# Step 3  --  Screen photons
if ! $cfstat then
    cf_screen_photons         $idf    >>& $logfile
    set cfstat=$status
endif

# Step 4  --  Remove motions
if ! $cfstat then
    cf_remove_motions         $idf    >>& $logfile
    set cfstat=$status
endif

# Step 5  --  Assign wavelength	- SAVE ASTIG-CORRECTED X ARRAY
if ! $cfstat then
    cf_assign_wavelength  -w  $idf    >>& $logfile
    set cfstat=$status
endif

if ! $cfstat then
	if ($?CF_IDLDIR) then
		idlplot_rate.pl {$froot}	>>& $logfile
                idlplot_spex.pl {$froot}        >>& $logfile
	endif
endif

# Step 6  --  Flux calibrate
if ! $cfstat then
    cf_flux_calibrate         $idf    >>& $logfile
    set cfstat=$status
endif

if ! $cfstat then
  echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Finish data file $1"
  echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Finish data file $1" >>& $logfile
else
  echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Error processing $1"
  echo `date '+%Y %b %e %T'` "calfuse.wavecal-1.15: Error processing $1" >>& $logfile
endif
exit($cfstat)

#******************************************************************************