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

Last change on this file since 19424 was 19424, checked in by dorner, 3 months ago
added comments and functionality to fill only corrected R750 and not reference values
  • Property svn:executable set to *
File size: 3.5 KB
Line 
1#!/bin/bash
2
3# setup
4sqlpw=/home/$USER/.mysql.pw.op
5dbname=factdata
6# fill only corrected R750
7short="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.0 #89
124       )
125
126# fill reference values
127echo ""
128echo "Filling the reference values for the corrected R750 for "${#rates[@]}" periods to the DB..."
129for (( i=0; i < ${#rates[@]} ; i++)) 
130do
131   if [ "${rates[$i]}" = "0.0" ]
132   then 
133      rate="NULL"
134   else
135      rate=${rates[$i]}
136   fi
137   query="UPDATE RunInfo SET fR750Ref="$rate" WHERE fPeriod="$i
138   #echo $query
139   mysql --defaults-file=$sqlpw -u operator -h 10.0.100.21 $dbname -s -e "$query" 
140done
141
142# several periods are split:
143#   update the values for those
144# 71b
145query="UPDATE RunInfo SET fR750Ref=250.0 WHERE fPeriod=71 AND fNight>20170726"
146mysql --defaults-file=$sqlpw -s -e "$query" 
147# 69b
148query="UPDATE RunInfo SET fR750Ref=253.0 WHERE fPeriod=69 AND fNight>20170524"
149mysql --defaults-file=$sqlpw -s -e "$query" 
150# 60a
151query="UPDATE RunInfo SET fR750Ref=239.3 WHERE fPeriod=60 AND fNight<20170901"
152mysql --defaults-file=$sqlpw -s -e "$query" 
153# 46a
154query="UPDATE RunInfo SET fR750Ref=271 WHERE fPeriod=46 AND fNight<20150716"
155mysql --defaults-file=$sqlpw -s -e "$query" 
156# 24b
157query="UPDATE RunInfo SET fR750Ref=286.2 WHERE fPeriod=24 AND fNight>20131003"
158mysql --defaults-file=$sqlpw -s -e "$query" 
159
160
161echo ""
162echo "Done"
163
Note: See TracBrowser for help on using the repository browser.