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

Last change on this file since 14476 was 14195, checked in by Daniela Dorner, 12 years ago
added (script to insert info on light conditions to database)
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1#!/bin/bash
2
3# option
4doupdate="yes" # update all entries (needed when new fields have been added)
5#doupdate="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 )
18dates=( `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=$query" AND fRunTypeKEY=6 "
37 if [ "$doupdate" = "no" ]
38 then
39 query=$query" AND ISNULL(fMoonDisk) "
40 fi
41 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query
42 filenumbers=( `sendquery` )
43 if [ ${#filenumbers} -eq 0 ]
44 then
45 printprocesslog "INFO No files found in the DB for night "$date
46 continue
47 fi
48
49 # fill auxiliary information for files
50 for filenum in ${filenumbers[@]}
51 do
52 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
53 echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` >> $logfile 2>&1
54
55 # get input info from DB
56 query="SELECT fRightAscension, fDeclination, fRunStart from RunInfo "
57 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
58 info=( `sendquery` )
59 echo ${info[@]}
60 #echo "/home/fact/FACT++.db/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null"
61 lightinfo=( `/home/fact/FACT++.db/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null` )
62 echo ${lightinfo[@]}
63
64 # build query to update runinfo in DB
65 query="UPDATE RunInfo SET fSunZenithDistance="${lightinfo[2]}", fMoonDisk="${lightinfo[4]}", fMoonZenithDistance="${lightinfo[5]}", fAngleToMoon="${lightinfo[6]}
66 # add where condition
67 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
68 echo $query
69
70 # send query to DB
71 sendquery >/dev/null
72 done
73done
74
75finish
76
77
Note: See TracBrowser for help on using the repository browser.