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

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