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/15" )
|
---|
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 | biascontrolfile=$auxdir/$runnumber.BIAS_CONTROL_VOLTAGE.fits
|
---|
71 | if ! [ -e $biascontrolfile ]
|
---|
72 | then
|
---|
73 | echo $biascontrolfile" not found"
|
---|
74 | fi
|
---|
75 |
|
---|
76 | # get file numbers from DB
|
---|
77 | query1="SELECT fFileNumber from RunInfo WHERE fRunNumber="$runnumber
|
---|
78 | filenumbers=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query1" 2>> $logfile` )
|
---|
79 | for filenum in ${filenumbers[@]}
|
---|
80 | do
|
---|
81 | echo $filenum
|
---|
82 | query2="SELECT fRunStart from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
83 | starttime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query2" 2>> $logfile`
|
---|
84 | query3="SELECT fRunStop from RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenum
|
---|
85 | stoptime=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -s -e "$query3" 2>> $logfile`
|
---|
86 | echo "start: "$starttime
|
---|
87 | echo "stop: "$stoptime
|
---|
88 | echo $trackingfile
|
---|
89 | ftcopy $trackingfile'[Time>55889.1][col Ra]' - | ftstat -
|
---|
90 |
|
---|
91 | exit
|
---|
92 | # notes:
|
---|
93 | # ftcopy /loc_data/aux/2011/11/23/20111123.BIAS_CONTROL_NOMINAL.fits'[Time>55889.1][col Time]' - | ftstat -
|
---|
94 | # ftcopy /loc_data/aux/2011/11/15/20111115.DRIVE_CONTROL_TRACKING_POSITION.fits'[Time>55880.8 && Time< 55880.9][col Ra;Time]' - | ftcopy -'[col Ra]' - | ftstat -
|
---|
95 | done
|
---|
96 |
|
---|
97 | done
|
---|
98 |
|
---|
99 |
|
---|