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

Last change on this file since 17890 was 17597, checked in by Daniela Dorner, 11 years ago
give warning about missing files only when runinfo in DB available
  • 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 # proceed only if there are files available
51 filenumbers=( `sendquery` )
52 if [ ${#filenumbers} -eq 0 ]
53 then
54 printprocesslog "INFO No files found in the DB for night "$date
55 continue
56 fi
57
58 # fill auxiliary information for files
59 for filenum in ${filenumbers[@]}
60 do
61 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum`
62
63 # get input info from DB
64 # query 999 in case value is empty to easily recognize this case
65 query="SELECT if (isnull(fRightAscension), 999, fRightAscension), "
66 query=$query" if (isnull(fDeclination), 999, fDeclination), "
67 query=$query" fRunStart from RunInfo "
68 query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
69 info=( `sendquery` )
70 if [ "${info[0]}" == "999" ] && [ "${info[1]}" == "999" ]
71 then
72 lightinfo=( `$factpath/moon "${info[2]} ${info[3]}" 2>/dev/null` )
73 else
74 lightinfo=( `$factpath/moon "${info[2]} ${info[3]}" --ra=${info[0]} --dec=${info[1]} 2>/dev/null` )
75 fi
76 # return values of the programm
77 # timestamp sunzd moon-visible moondisk moonzd angletomoon angletosun
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
90 #echo $query
91 # send query to DB
92 sendquery >/dev/null
93 done
94done
95
96finish
97
98
Note: See TracBrowser for help on using the repository browser.