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

Last change on this file since 19594 was 19567, checked in by Daniela Dorner, 6 years ago
added values for new periods up to 95, fixed option doupdate
  • 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 )
138if [ ${#rates[@]} -lt $pmaxref ]
139then
140 ${#rates[@]}" "$pmaxref
141 "No new reference values available ("$pmaxref")"
142 exit
143fi
144
145# fill reference values
146echo ""
147echo "Filling the reference values for the corrected R750 for "${#rates[@]}" periods to the DB..."
148echo " Starting from period "$numstart
149for (( i=$numstart; i < ${#rates[@]} ; i++))
150do
151 echo "Filling P"$i
152 if [ "${rates[$i]}" = "0.0" ]
153 then
154 rate="NULL"
155 else
156 rate=${rates[$i]}
157 fi
158 query="UPDATE RunInfo SET fR750Ref="$rate" WHERE fPeriod="$i
159 echo " "$query
160 mysql --defaults-file=$sqlpw -s -e "$query"
161done
162
163if [ $numstart -gt 0 ]
164then
165 exit
166fi
167
168echo "Filling split periods..."
169# several periods are split:
170# update the values for those
171# 71b
172query="UPDATE RunInfo SET fR750Ref=250.0 WHERE fPeriod=71 AND fNight>20170726"
173 echo " "$query
174mysql --defaults-file=$sqlpw -s -e "$query"
175# 69b
176query="UPDATE RunInfo SET fR750Ref=253.0 WHERE fPeriod=69 AND fNight>20170524"
177 echo " "$query
178mysql --defaults-file=$sqlpw -s -e "$query"
179# 60a
180query="UPDATE RunInfo SET fR750Ref=239.3 WHERE fPeriod=60 AND fNight<20170901"
181 echo " "$query
182mysql --defaults-file=$sqlpw -s -e "$query"
183# 46a
184query="UPDATE RunInfo SET fR750Ref=271 WHERE fPeriod=46 AND fNight<20150716"
185 echo " "$query
186mysql --defaults-file=$sqlpw -s -e "$query"
187# 24b
188query="UPDATE RunInfo SET fR750Ref=286.2 WHERE fPeriod=24 AND fNight>20131003"
189 echo " "$query
190mysql --defaults-file=$sqlpw -s -e "$query"
191
192
193echo ""
194echo "Done"
195
Note: See TracBrowser for help on using the repository browser.