| 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 dates
|
|---|
| 16 | if [ "$certaindate" != "" ]
|
|---|
| 17 | then
|
|---|
| 18 | checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'\|'^[0-9][0-9][0-9]$'`
|
|---|
| 19 | if [ "$checkstring" = "" ]
|
|---|
| 20 | then
|
|---|
| 21 | echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)"
|
|---|
| 22 | finish
|
|---|
| 23 | fi
|
|---|
| 24 | getdates $certaindate
|
|---|
| 25 | else
|
|---|
| 26 | # get all night
|
|---|
| 27 | #getdates "all"
|
|---|
| 28 | # get last 6 nights
|
|---|
| 29 | getdates 6
|
|---|
| 30 | fi
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | printprocesslog "INFO processing the following night(s): "${dates[@]}
|
|---|
| 34 | echo `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1
|
|---|
| 35 |
|
|---|
| 36 | #echo ${dates[@]}
|
|---|
| 37 |
|
|---|
| 38 | cd $mars
|
|---|
| 39 |
|
|---|
| 40 | # do filling of aux data
|
|---|
| 41 | for date in ${dates[@]}
|
|---|
| 42 | do
|
|---|
| 43 | auxdir=$auxdata/$date
|
|---|
| 44 | runnumber=`echo $date | sed -e 's/\///g'`
|
|---|
| 45 |
|
|---|
| 46 | # check if aux files are available from that night
|
|---|
| 47 | if ! [ -d $auxdir ]
|
|---|
| 48 | then
|
|---|
| 49 | printprocesslog "INFO no data available in "$auxdir
|
|---|
| 50 | continue
|
|---|
| 51 | else
|
|---|
| 52 | printprocesslog "INFO processing files in "$auxdir
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 | ratescanfile=$auxdir/$runnumber.RATE_SCAN_DATA.fits
|
|---|
| 56 | printprocesslog "INFO processing "$ratescanfile
|
|---|
| 57 | echo "INFO processing "$ratescanfile >> $logfile 2>&1
|
|---|
| 58 | if ! [ -e $ratescanfile ]
|
|---|
| 59 | then
|
|---|
| 60 | rawdir=$rawdata/$date
|
|---|
| 61 | # check if raw files are available from that night
|
|---|
| 62 | if ! [ -d $rawdir ]
|
|---|
| 63 | then
|
|---|
| 64 | printprocesslog "INFO "$ratescanfile" not found."
|
|---|
| 65 | else
|
|---|
| 66 | printprocesslog "WARN "$ratescanfile" not found."
|
|---|
| 67 | fi
|
|---|
| 68 | continue
|
|---|
| 69 | # else
|
|---|
| 70 | # ratescannumerrors=`fverify $ratescanfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`
|
|---|
| 71 | # if [ $ratescannumerrors -gt 0 ]
|
|---|
| 72 | # then
|
|---|
| 73 | # printprocesslog "WARN for $ratescanfile fverify returned "$ratescannumerrors" error(s)."
|
|---|
| 74 | # fi
|
|---|
| 75 | fi
|
|---|
| 76 |
|
|---|
| 77 | printprocesslog "INFO run fillratescan.C for night "$runnumber
|
|---|
| 78 | echo "run fillratescan.C for night "$runnumber >> $logfile 2>&1
|
|---|
| 79 | check1=`root -q -b -l fact/processing/fillratescan.C\("\"$ratescanfile"\"\,kFALSE\) | tee $logfile | intgrep`
|
|---|
| 80 | case $check1 in
|
|---|
| 81 | 1) printprocesslog "INFO fillratescan.C was successfully for night "$runumber" (check1=$check1)."
|
|---|
| 82 | ;;
|
|---|
| 83 | 0) printprocesslog "WARN connection to DB failed (check1=$check1)."
|
|---|
| 84 | ;;
|
|---|
| 85 | *) printprocesslog "ERROR fillratescan.C failed for night "$runumber" (check1=$check1)."
|
|---|
| 86 | ;;
|
|---|
| 87 | esac
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | done
|
|---|
| 91 |
|
|---|
| 92 | finish
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|