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

Last change on this file since 14900 was 14875, checked in by Daniela Dorner, 12 years ago
removed not needed logging and logfile, added comments
  • Property svn:executable set to *
File size: 3.6 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#dates=( `find $auxdata -mindepth 3 -type d | sort -r | sed "s/\${auxdata_for_sed}//g" | sed -e 's/^\///'` )
19
20printprocesslog "INFO processing the following night(s): "${dates[@]}
21#echo `date`": processing the following night(s): "${dates[@]} #>> $logfile 2>&1
22
23# do filling of aux data
24for date in ${dates[@]}
25do
26 runnumber=`echo $date | sed -e 's/\///g'`
27 if [ $runnumber -lt 20111115 ]
28 then
29 continue
30 fi
31 printprocesslog "INFO processing date "$date
32 #echo "INFO processing date "$date
33
34 # get file numbers from DB
35 # but only for not-corrupted files
36 #query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND NOT ISNULL(fRightAscension) AND NOT ISNULL(fDeclination) "
37 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND NOT ISNULL(fRunStart) "
38 #query=$query" AND fRunTypeKEY=6 "
39 if [ "$doupdate" = "no" ]
40 then
41 query=$query" AND ISNULL(fMoonDisk) "
42 fi
43 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query
44 filenumbers=( `sendquery` )
45 if [ ${#filenumbers} -eq 0 ]
46 then
47 printprocesslog "INFO No files found in the DB for night "$date
48 continue
49 fi
50
51 # fill auxiliary information for files
52 for filenum in ${filenumbers[@]}
53 do
54 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
55 #echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` # >> $logfile 2>&1
56
57 # get input info from DB
58 # query 999 in case value is empty to easily recognize this case
59 query="SELECT if (isnull(fRightAscension), 999, fRightAscension), "
60 query=$query" if (isnull(fDeclination), 999, fDeclination), "
61 query=$query" fRunStart from RunInfo "
62 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
63 info=( `sendquery` )
64 #echo ${info[@]}
65 #echo "/home/fact/FACT++.db/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null"
66 if [ "${info[0]}" == "999" ] && [ "${info[1]}" == "999" ]
67 then
68 lightinfo=( `/home/fact/FACT++.upgrade/moon "${info[2]} ${info[3]}" 2>/dev/null` )
69 else
70 lightinfo=( `/home/fact/FACT++.upgrade/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null` )
71 fi
72 # return values of the programm
73 # timestamp sunzd moon-visible moondisk moonzd angletomoon angletosun
74 #echo ${lightinfo[@]}
75
76 # build query to update runinfo in DB
77 query="UPDATE RunInfo SET fSunZenithDistance="${lightinfo[2]}", fMoonDisk="${lightinfo[4]}
78 query=$query", fMoonZenithDistance="${lightinfo[5]}
79 if [ "${info[0]}" != "999" ] && [ "${info[1]}" != "999" ]
80 then
81 query=$query", fAngleToMoon="${lightinfo[6]}
82 query=$query", fAngleToSun="${lightinfo[7]}
83 fi
84 # add where condition
85 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
86 #echo $query
87 # send query to DB
88 sendquery >/dev/null
89 done
90done
91
92finish
93
94
Note: See TracBrowser for help on using the repository browser.