-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenergyScenario.php
executable file
·206 lines (182 loc) · 3.33 KB
/
energyScenario.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/local/bin/php -q
<?
$pCurves[0]='BWC Excel-R';
$pCurves[1]='APRS WT10';
$pCurves[2]='APRS WT14';
$pCurves[3]='APRS HR3';
/* BWC Excel-R 7.5kW
index is m/s bin
value is kilowatts output
*/
$powerCurve[0]=array(
0=>0.00,
1=>0.00,
2=>0.00,
3=>0.00,
4=>0.22,
5=>0.70,
6=>1.45,
7=>2.24,
8=>3.20,
9=>4.26,
10=>5.40,
11=>6.58,
12=>7.02,
13=>7.02,
14=>7.02,
15=>6.14,
16=>4.39,
17=>2.37,
18=>2.63,
19=>2.63,
20=>2.63, /* BWC power curve in WindCad ends at this point. Assuming furled and production will remain constant */
21=>2.63,
22=>2.63,
23=>2.63,
24=>2.63,
25=>2.63,
26=>2.63,
27=>2.63,
28=>2.63,
29=>2.63,
30=>2.63,
31=>2.63,
32=>2.63,
33=>2.63,
34=>2.63,
35=>2.63,
36=>2.63,
37=>2.63,
38=>2.63,
39=>2.63,
40=>2.63
);
/* APRS World WT10 24 volt charging 24 volt battery
Not an official power curve ... just based on 24 hours of data from before 2014-02-12
SELECT ROUND(windAverageMS0) AS windMS, ROUND(AVG(pRectifier)) AS power FROM view_A3351 WHERE packet_date >= DATE_SUB(now(),INTERVAL 24 HOUR) GROUP BY windMS;
index is m/s bin
value is kilowatts output
*/
$powerCurve[1]=array(
0=>0.00,
1=>0.00,
2=>0.00,
3=>0.00,
4=>0.00,
5=>0.011,
6=>0.028,
7=>0.051,
8=>0.078,
9=>0.109,
10=>0.141,
11=>0.175,
12=>0.218,
13=>0.266,
14=>0.328,
15=>0.402,
16=>0.402,
17=>0.402,
18=>0.402,
19=>0.402,
20=>0.402,
21=>0.402,
22=>0.402,
23=>0.402,
24=>0.402,
25=>0.402
);
/* APRS World WT14 72 volt charging 48 volt battery
Not an official power curve ... data from e-mail to Tod Hanley on 2013-03-30
index is m/s bin
value is kilowatts output
*/
$powerCurve[2]=array(
0=>0.00,
1=>0.00,
2=>0.00,
3=>0.00,
4=>0.00,
5=>0.042,
6=>0.075,
7=>0.108,
8=>0.145,
9=>0.207,
10=>0.256,
11=>0.313,
12=>0.366,
13=>0.375,
14=>0.379,
15=>0.379,
16=>0.379,
17=>0.379,
18=>0.379,
19=>0.379,
20=>0.379,
21=>0.379,
22=>0.379,
23=>0.379,
24=>0.379,
25=>0.379
);
/* APRS World HR3W
index is m/s bin
value is kilowatts output
*/
$powerCurve[3]=array(
0=>0.00,
1=>0.00,
2=>0.00,
3=>0.00,
4=>0.10,
5=>0.25,
6=>0.40,
7=>0.60,
8=>1.00,
9=>1.35,
10=>1.75,
11=>2.00,
12=>2.50,
13=>3.00,
14=>3.00,
15=>3.00,
16=>2.85,
17=>2.10,
18=>1.85,
19=>1.00,
20=>0.25,
21=>0.12,
22=>0,
23=>0,
24=>0,
25=>0
);
//print_r($powerCurve);
$startDay=1;
$endDay=366;
$table=$_SERVER['argv'][1];
$samplesPerHour=$_SERVER['argv'][2];
$year=$_SERVER['argv'][3];
$powerCurveToUse=$_SERVER['argv'][4];
$db=mysql_connect("localhost","root","roadtoad");
mysql_select_db("powerCurve");
for ( $day=$startDay ; $day<=$endDay ; $day++ ) {
$kwhDay=0.0;
$date='';
/* get hours per wind speed bin */
$sql=sprintf("SELECT LEFT(packet_date,10) AS day, ROUND(windspeedMS) AS binMS,COUNT(*)/%s AS hours FROM %s WHERE DAYOFYEAR(packet_date)=%d AND YEAR(packet_date)=%d GROUP BY binMS",$samplesPerHour,$table,$day,$year);
$q=mysql_query($sql,$db);
while ( $r=mysql_fetch_array($q,MYSQL_ASSOC) ) {
// printf("day=%s bin=%s hours=%s\n",$r['day'],$r['binMS'],$r['hours']);
if ( ! array_key_exists($r['binMS'],$powerCurve[$powerCurveToUse]) ) {
printf("ERROR: bin for %s does not exist\n",$r['binMS']);
continue;
}
/* energy is powerCurve[binMS] * hours */
$kwhDay += $powerCurve[$powerCurveToUse][$r['binMS']]*$r['hours'];
$date=$r['day'];
}
if ( '' == $date )
continue;
printf("%s, %0.2f\n",$date,$kwhDay);
}
?>