1 | #!/bin/bash
|
---|
2 |
|
---|
3 | source `dirname $0`/../Sourcefile.sh
|
---|
4 | printprocesslog "INFO starting "$0
|
---|
5 |
|
---|
6 | # setup to use ftools
|
---|
7 | source $HEADAS/headas-init.sh
|
---|
8 |
|
---|
9 | logfile=$runlogpath"/FillRatescan-"$datetime".log"
|
---|
10 | date >> $logfile
|
---|
11 |
|
---|
12 | # this script doesn't need variable $doupdate
|
---|
13 | # filling is done by macro and update is always done
|
---|
14 |
|
---|
15 | # get last 3, 6 or 9 nights
|
---|
16 | dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
|
---|
17 | # `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
|
---|
18 | # `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
|
---|
19 | )
|
---|
20 | #dates=( `find -L $ziprawdata -mindepth 3 -type d | sort -r | sed "s/\${ziprawdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
|
---|
21 |
|
---|
22 | #dates=( "2013/01/31" )
|
---|
23 |
|
---|
24 | printprocesslog "INFO processing the following night(s): "${dates[@]}
|
---|
25 | echo `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1
|
---|
26 |
|
---|
27 | #echo ${dates[@]}
|
---|
28 |
|
---|
29 | cd $mars
|
---|
30 |
|
---|
31 | # do filling of aux data
|
---|
32 | for date in ${dates[@]}
|
---|
33 | do
|
---|
34 | auxdir=$auxdata/$date
|
---|
35 | runnumber=`echo $date | sed -e 's/\///g'`
|
---|
36 |
|
---|
37 | # check if aux files are available from that night
|
---|
38 | if ! [ -d $auxdir ]
|
---|
39 | then
|
---|
40 | printprocesslog "INFO no data available in "$auxdir
|
---|
41 | continue
|
---|
42 | else
|
---|
43 | printprocesslog "INFO processing files in "$auxdir
|
---|
44 | fi
|
---|
45 |
|
---|
46 | ratescanfile=$auxdir/$runnumber.RATE_SCAN_DATA.fits
|
---|
47 | printprocesslog "INFO processing "$ratescanfile
|
---|
48 | echo "INFO processing "$ratescanfile >> $logfile 2>&1
|
---|
49 | if ! [ -e $ratescanfile ]
|
---|
50 | then
|
---|
51 | rawdir=$rawdata/$date
|
---|
52 | # check if raw files are available from that night
|
---|
53 | if ! [ -d $rawdir ]
|
---|
54 | then
|
---|
55 | printprocesslog "INFO "$ratescanfile" not found."
|
---|
56 | else
|
---|
57 | printprocesslog "WARN "$ratescanfile" not found."
|
---|
58 | fi
|
---|
59 | continue
|
---|
60 | else
|
---|
61 | ratescannumerrors=`fverify $ratescanfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`
|
---|
62 | if [ $ratescannumerrors -gt 0 ]
|
---|
63 | then
|
---|
64 | printprocesslog "WARN for $ratescanfile fverify returned "$ratescannumerrors" error(s)."
|
---|
65 | fi
|
---|
66 | fi
|
---|
67 |
|
---|
68 | printprocesslog "INFO run fillratescan.C for night "$runnumber
|
---|
69 | echo "run fillratescan.C for night "$runnumber >> $logfile 2>&1
|
---|
70 | check1=`root -q -b -l fact/processing/fillratescan.C\("\"$ratescanfile"\"\,kFALSE\) | tee $logfile | intgrep`
|
---|
71 | case $check1 in
|
---|
72 | 1) printprocesslog "INFO fillratescan.C was successfully for night "$runumber" (check1=$check1)."
|
---|
73 | ;;
|
---|
74 | 0) printprocesslog "WARN connection to DB failed (check1=$check1)."
|
---|
75 | ;;
|
---|
76 | *) printprocesslog "ERROR fillratescan.C failed for night "$runumber" (check1=$check1)."
|
---|
77 | ;;
|
---|
78 | esac
|
---|
79 |
|
---|
80 |
|
---|
81 | done
|
---|
82 |
|
---|
83 | finish
|
---|
84 |
|
---|
85 |
|
---|