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

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