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_CURRENTS.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 | echo $filenum
|
---|
88 | #query2="SELECT fRunStart from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
89 | #starttime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query2" 2>> $logfile`
|
---|
90 | #query3="SELECT fRunStop from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
91 | #stoptime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query3" 2>> $logfile`
|
---|
92 | #echo "start: "$starttime
|
---|
93 | #echo "stop: "$stoptime
|
---|
94 | rawfile=/loc_data/raw/$date/$runnumber"_"`printf %03d $filenum`.fits
|
---|
95 | #/home/fact/FACT++/fitsdump -h -t Events $rawfile
|
---|
96 | mjdref=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
|
---|
97 | tstarti=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
|
---|
98 | tstartf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
|
---|
99 | tstart=`echo " $tstarti + $mjdref + $tstartf " | bc -l`
|
---|
100 | tstopi=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTOPI' | grep -E -o '[0-9]{5}'`
|
---|
101 | tstopf=`/home/fact/FACT++/fitsdump -h -t Events $rawfile 2>/dev/null | grep 'TSTOPF' | grep -E -o '0[.][0-9]+'`
|
---|
102 | tstop=`echo " $tstopi + $mjdref + $tstopf " | bc -l`
|
---|
103 | echo "tstart in mjd: "$tstart
|
---|
104 | echo "tstop in mjd: "$tstop
|
---|
105 |
|
---|
106 | # get information from tracking
|
---|
107 | echo $trackingfile
|
---|
108 | ramin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
|
---|
109 | ramax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
|
---|
110 | ramean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
|
---|
111 | decmin=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'min' | grep -E -o '[0-9][.][0-9]+'`
|
---|
112 | decmax=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'max' | grep -E -o '[0-9][.][0-9]+'`
|
---|
113 | decmean=`ftcopy $trackingfile'[Time> '${tstart}' && Time< '${tstop}'][col Dec;Time]' - | ftcopy -'[col Dec]' - | ftstat - | grep 'mean' | grep -E -o '[0-9][.][0-9]+'`
|
---|
114 | echo "ra: "$ramin" - "$ramean" - "$ramax
|
---|
115 | echo "dec: "$decmin" - "$decmean" - "$decmax
|
---|
116 |
|
---|
117 | # get information from trigger
|
---|
118 | echo $triggerratefile
|
---|
119 | #ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat -
|
---|
120 | 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]+'`
|
---|
121 | 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]+'`
|
---|
122 | 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]+'`
|
---|
123 | echo "rate: "$ratemin" - "$ratemean" - "$ratemax
|
---|
124 |
|
---|
125 | # get information from trigger
|
---|
126 | echo $thresholdfile
|
---|
127 | echo "ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat -"
|
---|
128 | threshmin=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]+'`
|
---|
129 | threshmax=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]+'`
|
---|
130 | threshmean=`ftcopy $thresholdfile'[Time> '${tstart}' && Time< '${tstop}'][col PatchThresh;Time]' - | ftcopy -'[col PatchThresh]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]+'`
|
---|
131 | echo "rate: "$threshmin" - "$threshmean" - "$threshmax
|
---|
132 |
|
---|
133 |
|
---|
134 | exit
|
---|
135 | done
|
---|
136 |
|
---|
137 | done
|
---|
138 |
|
---|
139 |
|
---|