source: trunk/DataCheck/Tools/fill_r750.sh@ 19628

Last change on this file since 19628 was 19628, checked in by Daniela Dorner, 5 years ago
added new periods
  • Property svn:executable set to *
File size: 4.2 KB
Line 
1#!/bin/bash
2
3# setup
4sqlpw=/home/$USER/.mysql.pw.op
5dbname=factdata
6#doupdate=92
7
8query="SELECT Max(fPeriod) FROM RunInfo WHERE NOT ISNULL(fR750Cor)"
9pmaxcor=`mysql --defaults-file=$sqlpw -s -e "$query" `
10echo "fR750Cor is already filled up to P"$pmaxcor
11
12query="SELECT Max(fPeriod) FROM RunInfo WHERE NOT ISNULL(fR750Ref)"
13pmaxref=`mysql --defaults-file=$sqlpw -s -e "$query" `
14echo "fR750Ref is already filled up to P"$pmaxref
15
16if [ "$doupdate" == "" ]
17then
18 numstart=$pmaxref
19else
20 numstart=$doupdate
21fi
22
23
24
25# setup for zd- and th-correction:
26zd="cos(fZenithDistanceMean/180*Pi())"
27min="TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn/60"
28cor="pow("$zd", 1.94)*exp((1-1/"$zd")*0.331)*exp(2.39*(1-"$zd"))"
29
30# fill corrected R750
31echo ""
32echo "Filling the corrected R750 to the DB..."
33query="UPDATE RunInfo SET "
34query=$query" fR750Cor=round(fNumThreshold750/("$min")/("$cor"),2) "
35query=$query" WHERE fRunTypeKey=1 AND NOT (("$min")/("$cor"))=0 "
36query=$query" AND fPeriod>="$numstart
37echo $query
38mysql --defaults-file=$sqlpw -s -e "$query"
39
40# reference values for corrected R750
41rates=( 0.0 # 0
42 0.0 # 1
43 0.0 # 2
44 0.0 # 3
45 0.0 # 4
46 0.0 # 5
47 0.0 # 6
48 260.6 # 7
49 265.2 # 8
50 270.9 # 9
51 291.0 #10
52 253.1 #11
53 254.5 #12
54 239.3 #13
55 248.7 #14
56 245.5 #15
57 265.4 #16
58 250.1 #17
59 257.4 #18
60 253.6 #19
61 276.4 #20
62 268.5 #21
63 261.9 #22
64 255.7 #23
65 268.7 #24a
66 284.4 #25
67 274.8 #26
68 271.1 #27
69 270.0 #28
70 0.0 #29
71 248.2 #30
72 248.2 #31
73 284.4 #32
74 284.1 #33
75 273.8 #34
76 263.4 #35
77 258.3 #36
78 277.0 #37
79 275.5 #38
80 283.8 #39
81 284.7 #40
82 292.3 #41
83 292.2 #42
84 276.5 #43
85 276.8 #44
86 272.9 #45
87 249.1 #46b
88 249.5 #47
89 250.4 #48
90 255.1 #49
91 266.7 #50
92 266.0 #51
93 268.0 #52
94 258.9 #53
95 246.2 #54
96 243.9 #55
97 240.6 #56
98 244.8 #57
99 246.8 #58
100 239.3 #59
101 247.3 #60b
102 248.2 #61
103 261.5 #62
104 259.6 #63
105 248.6 #64
106 253.1 #65
107 248.1 #66
108 237.4 #67
109 233.6 #68
110 288.9 #69a
111 253.0 #70
112 232.9 #71a
113 238.7 #72
114 223.7 #73
115 215.7 #74
116 248.2 #75
117 250.6 #76
118 254.2 #77
119 247.4 #78
120 254.6 #79
121 248.3 #80
122 244.0 #81
123 247.3 #82
124 245.2 #83
125 236.0 #84
126 233.4 #85
127 248.1 #86
128 254.6 #87
129 251.5 #88
130 249.4 #89
131 251.9 #90
132 249.4 #91
133 241.8 #92
134 244.3 #93
135 240.9 #94
136 240.1 #95
137 240.6 #96
138 228.7 #97
139 )
140if [ ${#rates[@]} -lt $pmaxref ]
141then
142 ${#rates[@]}" "$pmaxref
143 "No new reference values available ("$pmaxref")"
144 exit
145fi
146
147# fill reference values
148echo ""
149echo "Filling the reference values for the corrected R750 for "${#rates[@]}" periods to the DB..."
150echo " Starting from period "$numstart
151for (( i=$numstart; i < ${#rates[@]} ; i++))
152do
153 echo "Filling P"$i
154 if [ "${rates[$i]}" = "0.0" ]
155 then
156 rate="NULL"
157 else
158 rate=${rates[$i]}
159 fi
160 query="UPDATE RunInfo SET fR750Ref="$rate" WHERE fPeriod="$i
161 echo " "$query
162 mysql --defaults-file=$sqlpw -s -e "$query"
163done
164
165if [ $numstart -gt 0 ]
166then
167 exit
168fi
169
170echo "Filling split periods..."
171# several periods are split:
172# update the values for those
173# 71b
174query="UPDATE RunInfo SET fR750Ref=250.0 WHERE fPeriod=71 AND fNight>20170726"
175 echo " "$query
176mysql --defaults-file=$sqlpw -s -e "$query"
177# 69b
178query="UPDATE RunInfo SET fR750Ref=253.0 WHERE fPeriod=69 AND fNight>20170524"
179 echo " "$query
180mysql --defaults-file=$sqlpw -s -e "$query"
181# 60a
182query="UPDATE RunInfo SET fR750Ref=239.3 WHERE fPeriod=60 AND fNight<20170901"
183 echo " "$query
184mysql --defaults-file=$sqlpw -s -e "$query"
185# 46a
186query="UPDATE RunInfo SET fR750Ref=271 WHERE fPeriod=46 AND fNight<20150716"
187 echo " "$query
188mysql --defaults-file=$sqlpw -s -e "$query"
189# 24b
190query="UPDATE RunInfo SET fR750Ref=286.2 WHERE fPeriod=24 AND fNight>20131003"
191 echo " "$query
192mysql --defaults-file=$sqlpw -s -e "$query"
193
194
195echo ""
196echo "Done"
197
Note: See TracBrowser for help on using the repository browser.