source: trunk/DataCheck/Processing/FillMoonInfo.sh@ 16959

Last change on this file since 16959 was 15220, checked in by Daniela Dorner, 12 years ago
updated FACT++ path
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/bash
2
3# option
4doupdate="yes" # update all entries (needed when new fields have been added)
5doupdate="no" # fill only entries which are not yet existing (default)
6
7source `dirname $0`/../Sourcefile.sh
8printprocesslog "INFO starting $0 with option doupdate="$doupdate
9
10#logfile=$runlogpath"/FillMoonInfo-"$datetime".log"
11#date >> $logfile
12
13# get last 3, 6 or 9 nights
14dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
15 `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
16# `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
17 )
18
19#dates=( `date +%Y/%m/%d --date="-228hour"` `date +%Y/%m/%d --date="-252hour"` `date +%Y/%m/%d --date="-276hour"` )
20
21#dates=( `find $auxdata -mindepth 3 -type d | sort -r | sed "s/\${auxdata_for_sed}//g" | sed -e 's/^\///'` )
22
23printprocesslog "INFO processing the following night(s): "${dates[@]}
24#echo `date`": processing the following night(s): "${dates[@]} #>> $logfile 2>&1
25
26# do filling of aux data
27for date in ${dates[@]}
28do
29 runnumber=`echo $date | sed -e 's/\///g'`
30 if [ $runnumber -lt 20111115 ]
31 then
32 continue
33 fi
34 printprocesslog "INFO processing date "$date
35 #echo "INFO processing date "$date
36
37 # get file numbers from DB
38 # but only for not-corrupted files
39 #query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND NOT ISNULL(fRightAscension) AND NOT ISNULL(fDeclination) "
40 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND NOT ISNULL(fRunStart) "
41 #query=$query" AND fRunTypeKEY=6 "
42 if [ "$doupdate" = "no" ]
43 then
44 query=$query" AND ISNULL(fMoonDisk) "
45 fi
46 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query
47 filenumbers=( `sendquery` )
48 if [ ${#filenumbers} -eq 0 ]
49 then
50 printprocesslog "INFO No files found in the DB for night "$date
51 continue
52 fi
53
54 # fill auxiliary information for files
55 for filenum in ${filenumbers[@]}
56 do
57 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
58 #echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` # >> $logfile 2>&1
59
60 # get input info from DB
61 # query 999 in case value is empty to easily recognize this case
62 query="SELECT if (isnull(fRightAscension), 999, fRightAscension), "
63 query=$query" if (isnull(fDeclination), 999, fDeclination), "
64 query=$query" fRunStart from RunInfo "
65 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
66 info=( `sendquery` )
67 #echo ${info[@]}
68 #echo "/home/fact/FACT++.db/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null"
69 if [ "${info[0]}" == "999" ] && [ "${info[1]}" == "999" ]
70 then
71 lightinfo=( `$factpath/moon "${info[2]} ${info[3]}" 2>/dev/null` )
72 else
73 lightinfo=( `$factpath/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null` )
74 fi
75 # return values of the programm
76 # timestamp sunzd moon-visible moondisk moonzd angletomoon angletosun
77 #echo ${lightinfo[@]}
78
79 # build query to update runinfo in DB
80 query="UPDATE RunInfo SET fSunZenithDistance="${lightinfo[2]}", fMoonDisk="${lightinfo[4]}
81 query=$query", fMoonZenithDistance="${lightinfo[5]}
82 if [ "${info[0]}" != "999" ] && [ "${info[1]}" != "999" ]
83 then
84 query=$query", fAngleToMoon="${lightinfo[6]}
85 query=$query", fAngleToSun="${lightinfo[7]}
86 fi
87 # add where condition
88 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
89 #echo $query
90 # send query to DB
91 sendquery >/dev/null
92 done
93done
94
95finish
96
97
Note: See TracBrowser for help on using the repository browser.