1 | #!/bin/bash
|
---|
2 |
|
---|
3 | today=`date +%F`
|
---|
4 | logfile=/home/`whoami`/DataCheck/log/FillAuxData$today.log
|
---|
5 |
|
---|
6 | # steps:
|
---|
7 | # select run# from DB - no, date is given
|
---|
8 | # get daily files
|
---|
9 | # select file# from DB
|
---|
10 | # select start and stop from DB
|
---|
11 | # get info from files
|
---|
12 | # fill into into DB
|
---|
13 |
|
---|
14 |
|
---|
15 | doupdate="yes" # update all entries
|
---|
16 | doupdate="no" # fill only entries which are not yet existing
|
---|
17 |
|
---|
18 | echo "" >> $logfile 2>&1
|
---|
19 | echo "" >> $logfile 2>&1
|
---|
20 | echo "" >> $logfile 2>&1
|
---|
21 | echo `date`"executing "$0"..." >> $logfile 2>&1
|
---|
22 | echo "=====> doupdate: "$doupdate >> $logfile 2>&1
|
---|
23 |
|
---|
24 | password=`cat /home/fact/DataCheck/.pw`
|
---|
25 | if [ "$password" == "" ]
|
---|
26 | then
|
---|
27 | echo "please insert password in .pw file"
|
---|
28 | fi
|
---|
29 |
|
---|
30 | # setup to use ftools
|
---|
31 | export HEADAS=/opt/heasoft-6.11/x86_64-unknown-linux-gnu-libc2.13-0/
|
---|
32 | source $HEADAS/headas-init.sh
|
---|
33 |
|
---|
34 | # get last 2 nights
|
---|
35 | dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` )
|
---|
36 | dates=( "2011/11/23" )
|
---|
37 |
|
---|
38 | # do rsync for rawfiles of these dates
|
---|
39 | for date in ${dates[@]}
|
---|
40 | do
|
---|
41 | echo "" >> $logfile 2>&1
|
---|
42 | echo "" >> $logfile 2>&1
|
---|
43 | echo "" >> $logfile 2>&1
|
---|
44 | auxdir=/loc_data/aux/$date
|
---|
45 | runnumber=`echo $date | sed -e 's/\///g'`
|
---|
46 | echo `date`": processing files in "$auxdir >> $logfile 2>&1
|
---|
47 | # check if data are available from that night
|
---|
48 | if ! [ -d $auxdir ]
|
---|
49 | then
|
---|
50 | echo `date`": no data available in "$auxdir >> $logfile 2>&1
|
---|
51 | continue
|
---|
52 | fi
|
---|
53 |
|
---|
54 | # get daily fits files
|
---|
55 | trackingfile=$auxdir/$runnumber.DRIVE_CONTROL_TRACKING_POSITION.fits
|
---|
56 | if ! [ -e $trackingfile ]
|
---|
57 | then
|
---|
58 | echo $trackingfile" not found"
|
---|
59 | fi
|
---|
60 | triggerratefile=$auxdir/$runnumber.FTM_CONTROL_TRIGGER_RATES.fits
|
---|
61 | if ! [ -e $triggerratefile ]
|
---|
62 | then
|
---|
63 | echo $triggerratefile" not found"
|
---|
64 | fi
|
---|
65 | thresholdfile=$auxdir/$runnumber.FTM_CONTROL_STATIC_DATA.fits
|
---|
66 | if ! [ -e $thresholdfile ]
|
---|
67 | then
|
---|
68 | echo $thresholdfile" not found"
|
---|
69 | fi
|
---|
70 | biasvoltagefile=$auxdir/$runnumber.BIAS_CONTROL_VOLTAGE.fits
|
---|
71 | if ! [ -e $biasvoltagefile ]
|
---|
72 | then
|
---|
73 | echo $biasvoltagefile" not found"
|
---|
74 | fi
|
---|
75 | biascurrentsfile=$auxdir/$runnumber.BIAS_CONTROL_CURRENT.fits
|
---|
76 | if ! [ -e $biascurrentsfile ]
|
---|
77 | then
|
---|
78 | echo $biascurrentsfile" not found"
|
---|
79 | fi
|
---|
80 |
|
---|
81 | # get file numbers from DB
|
---|
82 | query1="SELECT fFileNumber from RunInfo WHERE fRunNumber="$runnumber
|
---|
83 | filenumbers=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query1" 2>> $logfile` )
|
---|
84 | for filenum in ${filenumbers[@]}
|
---|
85 | do
|
---|
86 | filenum=42
|
---|
87 | filenum=53
|
---|
88 | filenum=56
|
---|
89 | echo $filenum
|
---|
90 | #query2="SELECT fRunStart from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
91 | #starttime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query2" 2>> $logfile`
|
---|
92 | #query3="SELECT fRunStop from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
93 | #stoptime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query3" 2>> $logfile`
|
---|
94 | #echo "start: "$starttime
|
---|
95 | #echo "stop: "$stoptime
|
---|
96 | rawfile=/loc_data/raw/$date/$runnumber"_"`printf %03d $filenum`.fits
|
---|
97 | #/home/fact/FACT++/fitsdump -h -t Events $rawfile
|
---|
98 | mjdref=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
|
---|
99 | tstarti=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
|
---|
100 | tstartf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
|
---|
101 | tstart=`echo " $tstarti + $mjdref + $tstartf " | bc -l`
|
---|
102 | tstart2=`echo " $tstarti + $mjdref + $tstartf - 0.00011574 " | bc -l` # 10 sec
|
---|
103 | #tstart2=`echo " $tstarti + $mjdref + $tstartf - 0.000023148 " | bc -l` # 2 sec
|
---|
104 | tstopi=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTOPI' | grep -E -o '[0-9]{5}'`
|
---|
105 | tstopf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTOPF' | grep -E -o '0[.][0-9]+'`
|
---|
106 | tstop=`echo " $tstopi + $mjdref + $tstopf " | bc -l`
|
---|
107 | echo "tstart in mjd: "$tstart
|
---|
108 | echo "tstop in mjd: "$tstop
|
---|
109 |
|
---|
110 | # get information from tracking
|
---|
111 | echo $trackingfile
|
---|
112 | ramin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
|
---|
113 | ramax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
|
---|
114 | ramean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
|
---|
115 | decmin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
|
---|
116 | decmax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
|
---|
117 | decmean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
|
---|
118 | echo "ra: "$ramin" - "$ramean" - "$ramax
|
---|
119 | echo "dec: "$decmin" - "$decmean" - "$decmax
|
---|
120 |
|
---|
121 | # get information from trigger
|
---|
122 | echo $triggerratefile
|
---|
123 | #ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat -
|
---|
124 | ratemin=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
125 | ratemax=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
126 | ratemean=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
127 | ratemedian=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
128 | echo "rate: "$ratemin" - "$ratemedian" - "$ratemean" - "$ratemax
|
---|
129 |
|
---|
130 | # get information from trigger
|
---|
131 | echo $thresholdfile
|
---|
132 | echo "ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat -"
|
---|
133 | threshmin=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
134 | threshmax=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
135 | threshmean=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
136 | threshmedian=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
137 | echo "threshold: "$threshmin" - "$threshmedian" - "$threshmean" - "$threshmax
|
---|
138 | if [ "$threshmean" == "0" ]
|
---|
139 | then
|
---|
140 | echo "ftcopy $thresholdfile'[Time> '${tstart2}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat -"
|
---|
141 | threshmin=`ftcopy $thresholdfile'[Time> '${tstart2}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
142 | threshmax=`ftcopy $thresholdfile'[Time> '${tstart2}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
143 | threshmean=`ftcopy $thresholdfile'[Time> '${tstart2}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
144 | threshmedian=`ftcopy $thresholdfile'[Time> '${tstart2}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
145 | echo "threshold: "$threshmin" - "$threshmedian" - "$threshmean" - "$threshmax
|
---|
146 | # is this taking into account the 160 values in a row?
|
---|
147 | fi
|
---|
148 |
|
---|
149 | # get information from bias: Uref
|
---|
150 | echo $biasvoltagefile
|
---|
151 | echo "ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat -"
|
---|
152 | biasvoltrefmin=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
153 | biasvoltrefmax=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
154 | biasvoltrefmean=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
155 | biasvoltrefmedian=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
156 | echo "bias: "$biasvoltrefmin" - "$biasvoltrefmedian" - "$biasvoltrefmean" - "$biasvoltrefmax
|
---|
157 | if [ "$biasvoltmean" == "0" ]
|
---|
158 | then
|
---|
159 | echo "ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat -"
|
---|
160 | biasvoltrefmin=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
161 | biasvoltrefmax=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
162 | biasvoltrefmean=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
163 | biasvoltrefmedian=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col Uref;Time]' - | ftcopy -'[col Uref]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
164 | echo "bias: "$biasvoltrefmin" - "$biasvoltrefmedian" - "$biasvoltrefmean" - "$biasvoltrefmax
|
---|
165 | # is this taking into account the 160 values in a row?
|
---|
166 | fi
|
---|
167 |
|
---|
168 | # get information from bias: U
|
---|
169 | echo $biasvoltagefile
|
---|
170 | echo "ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat -"
|
---|
171 | biasvoltmin=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
172 | biasvoltmax=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
173 | biasvoltmean=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
174 | biasvoltmedian=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
175 | echo "bias: "$biasvoltmin" - "$biasvoltmedian" - "$biasvoltmean" - "$biasvoltmax
|
---|
176 | if [ "$biasvoltmean" == "0" ]
|
---|
177 | then
|
---|
178 | echo "ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat -"
|
---|
179 | biasvoltmin=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
180 | biasvoltmax=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
181 | biasvoltmean=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
182 | biasvoltmedian=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col U;Time]' - | ftcopy -'[col U]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'`
|
---|
183 | echo "bias: "$biasvoltmin" - "$biasvoltmedian" - "$biasvoltmean" - "$biasvoltmax
|
---|
184 | # is this taking into account the 160 values in a row?
|
---|
185 | fi
|
---|
186 |
|
---|
187 | # get information from bias: status
|
---|
188 | echo $biasvoltagefile
|
---|
189 | echo "ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat -"
|
---|
190 | biasstatmin=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'min' | grep -E -o '[0-9]'`
|
---|
191 | biasstatmax=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'max' | grep -E -o '[0-9]'`
|
---|
192 | biasstatmean=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]'`
|
---|
193 | biasstatmedian=`ftcopy $biasvoltagefile'[Time> '${tstart}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'median' | grep -E -o '[0-9]'`
|
---|
194 | echo "bias: "$biasstatmin" - "$biasstatmedian" - "$biasstatmean" - "$biasstatmax
|
---|
195 | if [ "$biasstatmean" == "0" ]
|
---|
196 | then
|
---|
197 | echo "ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat -"
|
---|
198 | biasstatmin=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'min' | grep -E -o '[0-9]'`
|
---|
199 | biasstatmax=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'max' | grep -E -o '[0-9]'`
|
---|
200 | biasstatmean=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]'`
|
---|
201 | biasstatmedian=`ftcopy $biasvoltagefile'[Time> '${tstart2}' && Time< '${tstop}'][col QoS;Time]' - | ftcopy -'[col QoS]' - | ftstat - | grep 'median' | grep -E -o '[0-9]'`
|
---|
202 | echo "bias: "$biasstatmin" - "$biasstatmedian" - "$biasstatmean" - "$biasstatmax
|
---|
203 | # is this taking into account the 160 values in a row?
|
---|
204 | fi
|
---|
205 |
|
---|
206 | exit
|
---|
207 | done
|
---|
208 |
|
---|
209 | done
|
---|
210 |
|
---|
211 |
|
---|