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

Last change on this file since 17120 was 17094, checked in by Daniela Dorner, 11 years ago
usage of getdates function, prepared script to be used in RunMoreNights.sh, cleanup
  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#!/bin/bash
2
3# script to fill moon information to DB
4# doesn't need raw files
5# probably doesn't run at ISDC (FACT++/moon missing)
6
7# option whether to fill all row or only those where information is missing
8# $doupdate might be given as environment variable
9if [ "$doupdate" = "" ]
10then
11 doupdate="yes" # update all entries (needed when new fields have been added)
12 doupdate="no" # fill only entries which are not yet existing (default)
13fi
14
15source `dirname $0`/../Sourcefile.sh
16printprocesslog "INFO starting $0 with option doupdate="$doupdate
17
18# get dates
19if [ "$certaindate" != "" ]
20then
21 getdates $certaindate
22else
23 # get all night
24 #getdates "all"
25 # get last 6 nights
26 getdates 6
27fi
28
29printprocesslog "INFO processing the following night(s): "${dates[@]}
30
31# do filling of aux data
32for date in ${dates[@]}
33do
34 runnumber=`echo $date | sed -e 's/\///g'`
35 if [ $runnumber -lt 20111115 ]
36 then
37 continue
38 fi
39 printprocesslog "INFO processing date "$date
40 #echo "INFO processing date "$date
41
42 # get file numbers from DB
43 # but only for not-corrupted files
44 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND NOT ISNULL(fRunStart) "
45 if [ "$doupdate" = "no" ]
46 then
47 query=$query" AND ISNULL(fMoonDisk) "
48 fi
49 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query
50 filenumbers=( `sendquery` )
51 if [ ${#filenumbers} -eq 0 ]
52 then
53 printprocesslog "INFO No files found in the DB for night "$date
54 continue
55 fi
56
57 # fill auxiliary information for files
58 for filenum in ${filenumbers[@]}
59 do
60 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
61
62 # get input info from DB
63 # query 999 in case value is empty to easily recognize this case
64 query="SELECT if (isnull(fRightAscension), 999, fRightAscension), "
65 query=$query" if (isnull(fDeclination), 999, fDeclination), "
66 query=$query" fRunStart from RunInfo "
67 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
68 info=( `sendquery` )
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
78 # build query to update runinfo in DB
79 query="UPDATE RunInfo SET fSunZenithDistance="${lightinfo[2]}", fMoonDisk="${lightinfo[4]}
80 query=$query", fMoonZenithDistance="${lightinfo[5]}
81 if [ "${info[0]}" != "999" ] && [ "${info[1]}" != "999" ]
82 then
83 query=$query", fAngleToMoon="${lightinfo[6]}
84 query=$query", fAngleToSun="${lightinfo[7]}
85 fi
86 # add where condition
87 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
88
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.