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

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