-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindTurbine.mc2
1546 lines (1314 loc) · 65.5 KB
/
WindTurbine.mc2
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// @endpoint https://resverianaliz.aydemyenilenebilir.com.tr:8889/api/v0/exec
// @theme dark-blue
{
//'type' 'flex'
'title' 'Wind Turbine'
'cellHeight' 100
'options' {
'scheme' 'BELIZE'
'timeZone' 'Europe/Istanbul'
//'showErrors' true
'showLoader' true
}
'vars' {
'plant' 'Yalova'
'TurbineId' '1'
'startDate' [ NOW 7 d - ISO8601 'T' SPLIT 0 GET '21:00:00Z' ] 'T' JOIN TOTIMESTAMP //NOW 7 d - // 1658308294000000 // NOW
'endDate' NOW //1658913094000000 //604800000000
'myreadtoken' '4vM.a2aMxhl2qCB88Gutar8jXe4R4cqp.QaYYHtumjJg9DCHgXXY1_qIoBhzeh6PIdfX9KLtgeK1O0YHXcr0qA2ZPQrLAurl_PbQAkNjvy3WNq4fNEv434rOXWMsGq55X4qYtTOCtx53bqFwUXsRr6.B3sKF1YE1At8iEE2RyxC9RYOnS7UT4F'
'status' 'No Data'
}
'tiles' [
{
'title' 'Plant'
'x' 0 'y' 0 'w' 1 'h' 1
'type' 'input:list'
'macro' <%
[ $myreadtoken '~.*' { 'type' 'Wind' } ] FINDSETS STACKTOLIST 1 GET 'plant' GET LSORT 'listOfPlants' STORE
{
'data' $listOfPlants
'globalParams' { 'input' { 'value' $plant 'showButton' true } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'plant' ] 'selector' 'plant' } ] // Event definition
}
%>
}
{
'title' 'Turbine'
'x' 1 'y' 0 'w' 1 'h' 1
'type' 'input:list'
'options' { 'eventHandler' 'type=(variable),tag=(plant)' }
'macro' <%
[ $myreadtoken '~.*' { 'plant' $plant } ] FINDSETS STACKTOLIST 1 GET 'TurbineId' GET <% TOLONG %> SORTBY 'listOfTurbines' STORE
{
'data' $listOfTurbines
'globalParams' { 'input' { 'value' $TurbineId 'showButton' true } } // the initial selected value coming from global vars
'events' [ { 'type' 'variable' 'tags' [ 'TurbineId' ] 'selector' 'TurbineId' } ] // Event definition
}
%>
}
{
'title' 'Start Date'
'x' 2 'y' 0 'w' 2 'h' 1
'type' 'input:date'
'macro' <%
{
'data' [ NOW 8 d - ISO8601 'T' SPLIT 0 GET '21:00:00Z' ] 'T' JOIN TOTIMESTAMP
'globalParams' { 'input' { 'showButton' true } }
'events' [
{ 'type' 'variable' 'tags' [ 'startDate' ] 'selector' 'startDate' }
]
}
%>
}
{
'title' 'End Date'
'x' 4 'y' 0 'w' 2 'h' 1
'type' 'input:date'
'macro' <%
{
'data' [ NOW ISO8601 'T' SPLIT 0 GET '20:59:59Z' ] 'T' JOIN TOTIMESTAMP
'globalParams' { 'input' { 'showButton' true } }
'events' [
{ 'type' 'variable' 'tags' [ 'endDate' ] 'selector' 'endDate' }
]
}
%>
}
{
'title' 'Active / Site Power'
'options' { //'autoRefresh' 10 // only selected dates,
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
'unit' ' kW'
}
'x' 6 'y' 0 'w' 2 'h' 1
'type' 'linear-gauge'
'macro' <%
[ $myreadtoken '~ACTIVE_POWER.*' { 'plant' $plant 'type' 'Wind' }
//NOW 1 d
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'total_data' STORE
[ $total_data bucketizer.last 0 0 1 ] BUCKETIZE [ SWAP [] reducer.sum ] REDUCE [ SWAP bucketizer.sum 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'total_power' STORE
[ $myreadtoken '~ACTIVE_POWER.*' { 'plant' $plant 'type' 'Wind' 'TurbineId' $TurbineId }
//NOW -1
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'data' STORE
[ $data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'turbine_power' STORE
<% $turbine_power 0 == %> <% 0.001 'turbine_power' STORE %>
<% $turbine_power 'turbine_power' STORE %>
1 SWITCH
<'
%.2f
'>
[ $turbine_power TODOUBLE ] STRINGFORMAT 'turbine_power' STORE
<'
%.2f
'>
[ $total_power TODOUBLE ] STRINGFORMAT 'total_power' STORE
{
'data' $turbine_power
'params' [
{ 'maxValue' $total_power }
]
'globalParams' { 'gauge' { 'horizontal' true } }
}
%>
}
{
'title' 'Day / Total Generation'
'options' { // 'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'unit' 'MWh'
}
'x' 8 'y' 0 'w' 2 'h' 1
'type' 'display'
'macro' <%
[ $myreadtoken '~TOTAL_MWh.*' { 'TurbineId' $TurbineId 'plant' $plant }
//NOW 1 d
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'total_data' STORE
$total_data 0 GET LABELS 'manufacturer' GET 'manu' STORE
<% $manu 'Goldwind' == %> <%
NOW ->TSELEMENTS 'now_stamp' STORE
$now_stamp 0 GET 'year' STORE // year now
$now_stamp 1 GET 'month' STORE // value of this month
$now_stamp 2 GET 'day' STORE //day of today
[ $year $month $day ] TSELEMENTS-> ISO8601 'start' STORE
$total_data NOW $start TIMECLIP 0 GET VALUES 'values' STORE
<% $values [] == %> <% 0.0 'day_data' STORE %> <% $values -1 GET $values 0 GET - TODOUBLE 1000 / 'day_data' STORE %> IFTE // if no generation until midnight
[ $total_data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 1000 / 'total_data' STORE
%>
<% $manu 'Vestas' == %> <%
NOW ->TSELEMENTS 'now_stamp' STORE
$now_stamp 0 GET 'year' STORE // year now
$now_stamp 1 GET 'month' STORE // value of this month
$now_stamp 2 GET 'day' STORE //day of today
[ $year $month $day ] TSELEMENTS-> ISO8601 'start' STORE
$total_data NOW $start TIMECLIP 0 GET VALUES 'values' STORE
<% $values [] == %> <% 0.0 'day_data' STORE %> <% $values -1 GET $values 0 GET - TODOUBLE 1000 / 'day_data' STORE %> IFTE // if no generation until midnight
[ $total_data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 1000 / 'total_data' STORE
%>
<%
[ $myreadtoken '~DAY_MWh.*' { 'TurbineId' $TurbineId 'plant' $plant }
//NOW 1 d
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'day_data' STORE
[ $day_data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 'day_data' STORE
[ $total_data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 'total_data' STORE
%> 2 SWITCH
<'
%.2f
'>
[ $day_data ] STRINGFORMAT 'day_data' STORE
<'
%.2f
'>
[ $total_data ] STRINGFORMAT 'total_data' STORE
$day_data TOSTRING ' / ' + $total_data TOSTRING + 'data' STORE
$data
%>
}
{
'title' 'Status'
'options' { // 'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
'gauge.horizontal' false
}
'x' 11 'y' 0 'w' 1 'h' 1
'type' 'display'
'macro' <%
//fetch the most recent point of every GTS this token can access
[ $myreadtoken '~PLC_STATUS.*' { 'TurbineId' $TurbineId 'plant' $plant }
//NOW 7 d //
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'data' STORE
$data { '.app' '' '.uuid' '' } RELABEL 'data' STORE
[ $data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'status' STORE
$data 0 GET LABELS 'manufacturer' GET 'manu' STORE
<% $manu 'Goldwind' == %> <%
<% $status 0 == %> <% 'Inıtialization' 'status' STORE %>
<% $status 1 == %> <% 'Stop' 'status' STORE %>
<% $status 2 == %> <% 'Standstill' 'status' STORE %>
<% $status 3 == %> <% 'Starting' 'status' STORE %>
<% $status 4 == %> <% 'Run Up' 'status' STORE %>
<% $status 5 == %> <% 'Power Production' 'status' STORE %>
<% $status 6 == %> <% 'Service' 'status' STORE %>
<% 'fault' 'status' STORE %> 7 SWITCH
%>
<% $manu 'Sinovel' == %> <%
<% $status 0 == %> <% 'Start' 'status' STORE %>
<% $status 1 == %> <% 'Standby' 'status' STORE %>
<% $status 2 == %> <% 'Production' 'status' STORE %>
<% $status 3 == %> <% 'Error' 'status' STORE %>
<% $status 4 == %> <% 'Service' 'status' STORE %>
<% $status 5 == %> <% 'Low Temp.' 'status' STORE %>
<% $status 6 == %> <% 'High wind' 'status' STORE %>
<% 'offline' 'status' STORE %> 7 SWITCH
%>
<% $manu 'Vestas' == %> <%
<% $status 3 == %> <% 'Run' 'status' STORE %>
<% $status 2 == %> <% 'Pause' 'status' STORE %>
<% $status 1 == %> <% 'Stop' 'status' STORE %>
<% $status 4 == %> <% 'Emergency' 'status' STORE %>
<% 'offline' 'status' STORE %> 4 SWITCH
%>
<% %> 3 SWITCH
{
'data' $status
}
%>
}
{
'title' 'Temperature'
'type' 'linear-gauge'
'options' { // 'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
'unit' '°C'
'gauge' { 'horizontal' true }
}
'x' 10 'y' 0 'w' 1 'h' 1
'macro' <%
//fetch the most recent point of every GTS this token can access
[ $myreadtoken '~EnvTem' { 'TurbineId' $TurbineId 'plant' $plant }
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'data' STORE
$data { '.app' '' '.uuid' '' } RELABEL 'data' STORE
$data 0 GET MAX 'max_temp' STORE
$data 0 GET MIN 'min_temp' STORE
[ $data bucketizer.last 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 'temp' STORE
[ $data bucketizer.mean 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET TODOUBLE 'mean_temp' STORE
$temp 'tostring' STORE
<'
%.1f
'>
[ $tostring ] STRINGFORMAT 'temp' STORE
<'
%.1f
'>
[ $min_temp TODOUBLE ] STRINGFORMAT 'min_temp' STORE
<'
%.1f
'>
[ $max_temp TODOUBLE ] STRINGFORMAT 'max_temp' STORE
<'
%.1f
'>
[ $mean_temp TODOUBLE ] STRINGFORMAT 'mean_temp' STORE
{
'key' 'Mean:' $mean_temp + ' Min:' + $min_temp + ' Max:' + $max_temp +
'value' $temp
}
'data' STORE
{
'data' $data
'params' [ { 'maxValue' 100 } ]
'globalParams' {
'unit' '°C'
'gauge' { 'horizontal' true }
}
}
%>
}
{
'title' 'Wind Average'
'options' { // 'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 35
'unit' ' m/s'
'description' 'm/s'
}
'x' 0 'y' 1 'w' 2 'h' 2
'type' 'gauge'
'macro' <%
//fetch the most recent point of every GTS this token can access
[ $myreadtoken '~WIND_SPEED.*' { 'TurbineId' $TurbineId 'plant' $plant }
$startDate TOSTRING
$endDate TOSTRING
] FETCH 'wind_data' STORE
$wind_data 0 GET MAX 'max_wind' STORE
$wind_data 0 GET MIN 'min_wind' STORE
[ $wind_data bucketizer.mean 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'wind_avg' STORE //average wind
$wind_avg 'tostring' STORE
<'
%.1f
'>
[ $tostring ] STRINGFORMAT 'data' STORE
<'
%.1f
'>
[ $min_wind TODOUBLE ] STRINGFORMAT 'min_wind' STORE
<'
%.1f
'>
[ $max_wind TODOUBLE ] STRINGFORMAT 'max_wind' STORE
{
'key' 'Min:' $min_wind + ' Max:' + $max_wind +
'value' $data
}
'data' STORE
{
'data' $data
}
%>
}
{
'title' 'Time Availability'
'options' { //'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
}
'x' 2 'y' 1 'w' 2 'h' 2
'type' 'gauge'
'macro' <%
//fetch the most recent point of every GTS this token can access
[ $myreadtoken 'PLC_STATUS' { 'plant' $plant 'TurbineId' $TurbineId }
// $start $end
//NOW '2023-12-10T00:00:00.000Z' TOTIMESTAMP //will be changed after usak reconnects
//NOW 2 d
$startDate TOSTRING $endDate TOSTRING
] FETCH 'data' STORE
$data { '.app' '' '.uuid' '' 'type' '' } RELABEL 'data' STORE //relabel the atributes
NOW "lastBucket" STORE
1 m "bucketSpan" STORE // 1 minute
//'2023-12-10T00:00:00.000Z' TOTIMESTAMP "start" STORE // count = ((end - start) / bucketspan) + 1
NOW 2 d - "start" STORE // count = ((end - start) / bucketspan) + 1
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $data bucketizer.last $lastBucket $bucketSpan $bucketCount ] BUCKETIZE FILLPREVIOUS FILLNEXT 'bucket' STORE
//$bucket NOW $today TIMECLIP 'bucket' STORE //take last 24 hours
$data 0 GET LABELS 'manufacturer' GET 'manu' STORE
<% $manu 'Sinovel' == %>
<% [ $bucket [] { 'manufacturer' 'Sinovel' } filter.bylabels ] FILTER VALUES FLATTEN 'ylvlist' STORE
$ylvlist SIZE 'total_ylv' STORE
$ylvlist <% DROP 1 == %> LFILTER SIZE 'standby_ylv' STORE
$ylvlist <% DROP 2 == %> LFILTER SIZE 'prod_ylv' STORE
$prod_ylv TODOUBLE $standby_ylv TODOUBLE + $total_ylv TODOUBLE / 100 * 'avail' STORE
%> IFT
<% $manu 'Vestas' == %>
<% [ $bucket [] { 'manufacturer' 'Vestas' } filter.bylabels ] FILTER VALUES FLATTEN 'vslist' STORE
$vslist SIZE 'total_vs' STORE
$vslist <% DROP 2 == %> LFILTER SIZE 'pause' STORE
$vslist <% DROP 3 == %> LFILTER SIZE 'run' STORE
$run TODOUBLE $pause TODOUBLE + $total_vs TODOUBLE / 100 * 'avail' STORE
%> IFT
<% $manu 'Goldwind' == %>
<%
[ $bucket [] { 'manufacturer' 'Goldwind' } filter.bylabels ] FILTER VALUES FLATTEN 'uskgwlist' STORE
$uskgwlist SIZE 'total_uskgw' STORE
$uskgwlist <% DROP 2 == %> LFILTER SIZE 'standby_uskgw' STORE
$uskgwlist <% DROP 3 == %> LFILTER SIZE 'start_uskgw' STORE
$uskgwlist <% DROP 4 == %> LFILTER SIZE 'run_uskgw' STORE
$uskgwlist <% DROP 5 == %> LFILTER SIZE 'prod_uskgw' STORE
$run_uskgw TODOUBLE $standby_uskgw TODOUBLE + $start_uskgw TODOUBLE + $prod_uskgw TODOUBLE + $total_uskgw TODOUBLE / 100 * 'avail' STORE
%> IFT
$avail 'tostring' STORE
<'
%.2f
'>
[ $tostring ] STRINGFORMAT 'data' STORE
$data
%>
}
{
'title' 'Current / Best Curve'
'options' { //'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
}
'x' 4 'y' 1 'w' 2 'h' 2
'type' 'gauge'
'macro' <%
//fetch active power for filtering operation
[ $myreadtoken '~(ACTIVE_POWER|WIND_SPEED).*' { 'plant' $plant 'TurbineId' $TurbineId }
//NOW 3 d
$startDate TOSTRING $endDate TOSTRING
] FETCH { '.app' '' '.uuid' '' } RELABEL 'inputs' STORE //get all wind speed for a period
$inputs LASTTICK "lastBucket" STORE
10 m "bucketSpan" STORE // 1 minute
$inputs FIRSTTICK "start" STORE // count = ((end - start) / bucketspan) + 1
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $inputs bucketizer.mean $lastBucket $bucketSpan $bucketCount ] BUCKETIZE 'bucket' STORE
$bucket [ NaN NaN NaN 0 ] FILLVALUE SORT 'bucket' STORE // fill all empty ticks with zero
$bucket 0 GET 'wind' STORE
$bucket 1 GET 'pow' STORE
// calculate turbine perf according to vendor power curve
// get best curve of the selected turbine
{ 'token' $myreadtoken
'class' '~(WIND_SPEED|ACTIVE_POWER).*'
'labels' { 'plant' $plant 'TurbineId' $TurbineId }
// 'start' MAXLONG
'end' NOW
'timespan' MAXLONG d
//'sample' 0.5
'timestep' 10 m
} FETCH 'x' STORE
//[ $myreadtoken '~(WIND_SPEED|ACTIVE_POWER).*' { 'plant' $plant 'TurbineId' $TurbineId }
//$startDate TOSTRING
//$endDate TOSTRING
// NOW MAXLONG ] FETCH 'x' STORE
// fill zeros for empty power values and align timeticks
$x LASTTICK "xlastBucket" STORE
10 m "xbucketSpan" STORE // 10 minute
$x FIRSTTICK "xstart" STORE // count = ((end - start) / bucketspan) + 1
$xlastBucket $xstart - $xbucketSpan / TOLONG 1 + "xbucketCount" STORE
[ $x bucketizer.mean $xlastBucket $xbucketSpan $xbucketCount ] BUCKETIZE [ 0.0 0.0 0 0.0 ] FILLVALUE SORT 'x' STORE
// find both zeros for service time
[ $x 0.0 mapper.eq 0 0 0 ] MAP 'zeros' STORE
$zeros 0 GET $zeros 1 GET + TICKLIST 'serviceticks' STORE
$x 0 GET $serviceticks REMOVETICK 'xwind' STORE
$x 1 GET $serviceticks REMOVETICK 'xpower' STORE
[ $xwind $xpower ] 'x' STORE
$x NONEMPTY [ SWAP bucketizer.mean 0 10 m 0 ] BUCKETIZE NOW 4 w - 4 w 0 0 ".chunkid" false CHUNK 'chunk' STORE //here we create 1 week chunks of 10 m data
$chunk 0 GET 'windlist' STORE
$chunk 1 GET 'powerlist' STORE
[] 'energy' STORE
[] 'curves' STORE
0 $windlist SIZE 1 - <% 'i' STORE
//create curve of the turbine
$windlist $i GET 100 * 'bestwind' STORE
$windlist $i GET LABELS '.chunkid' GET 'name' STORE
$powerlist $i GET 'bestpow' STORE
$bestwind VALUES FLATTEN // ticks
[] [] [] // latitudes, longitudes and elevations
$bestpow VALUES FLATTEN // values
MAKEGTS
$name RENAME 3000 2850 TIMECLIP 'bestdata' STORE
//[ $bestdata bucketizer.mean 0 50 0 ] BUCKETIZE INTERPOLATE SORT 2000 1850 TIMECLIP 'curve' STORE
$bestdata DEDUP SORT 55 50 0 1 RLOWESS [ SWAP bucketizer.last 0 50 0 ] BUCKETIZE 3000 2850 TIMECLIP 'curve' STORE // rlowess curve
$curves $curve APPEND 'curves' STORE
$energy [ $curve bucketizer.sum 0 0 1 ] BUCKETIZE APPEND 'energy' STORE
%> FOR
$energy VALUES FLATTEN LSORT -1 GET 'big' STORE
[ $energy $big mapper.eq 0 0 0 ] MAP NONEMPTY 0 GET NAME 'class' STORE
[ $curves [] $class filter.byclass ] FILTER 0 GET 'bestcurve' STORE
$bestcurve NAME TOLONG ISO8601 'T' SPLIT 0 GET 'time' STORE
$bestcurve $time RENAME 'bestcurve' STORE
[ $bestcurve bucketizer.mean 0 1 0 ] BUCKETIZE INTERPOLATE SORT 'bestcurve' STORE
//create curve of the turbine
$wind 100 * 'wind' STORE
$wind VALUES FLATTEN // ticks
[] [] [] // latitudes, longitudes and elevations
$pow VALUES FLATTEN // values
MAKEGTS
'data' RENAME 'data' STORE
[ $data bucketizer.mean 0 10 0 ] BUCKETIZE SORT 'turbinecurve' STORE
//calculate expected power with theoretical curve
[] 'values' STORE
$wind SIZE 1 - 'len' STORE
0 $len <% 'i' STORE
$bestcurve $wind VALUES $i GET ATTICK 0 GET -1 GET 'value' STORE //for theoretical put instead bestcurve
<% $value NULL == %> <% 0 'value' STORE %>
<% $value 'value' STORE %> 1 SWITCH
$values [ $value ] APPEND 'values' STORE
%> FOR
$wind TICKLIST
[] [] []
$values
MAKEGTS 'Expected' RENAME 'expected' STORE
[ $pow bucketizer.sum 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'generated' STORE
[ $expected bucketizer.sum 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'expected' STORE
$generated $expected - TODOUBLE 60 / 'loss' STORE
//$generated $loss + 'total' STORE
//$generated $total / 100 * 'energy_avail' STORE
$generated $expected / 100 * 'energy_avail' STORE
$energy_avail 'tostring' STORE
<'
%.2f
'>
[ $tostring ] STRINGFORMAT 'energy_avail' STORE
<'
%.2f
'>
[ $loss ] STRINGFORMAT 'loss' STORE
'Difference:' $loss + 'loss' STORE
{
'key' $loss ' kwh' +
'value' $energy_avail
}
'data' STORE
{
'data' $data
}
%>
}
{
'title' 'Current / Vendor Curve'
'options' { //'autoRefresh' 10
'eventHandler' 'type=variable,tag=(TurbineId|plant|startDate|endDate)'
'maxValue' 100
}
'x' 6 'y' 1 'w' 2 'h' 2
'type' 'gauge'
'macro' <%
//fetch active power for filtering operation
[ $myreadtoken '~(ACTIVE_POWER|WIND_SPEED).*' { 'plant' $plant 'TurbineId' $TurbineId }
//NOW 3 d
$startDate TOSTRING $endDate TOSTRING
] FETCH { '.app' '' '.uuid' '' } RELABEL 'inputs' STORE //get all wind speed for a period
$inputs LASTTICK "lastBucket" STORE
10 m "bucketSpan" STORE // 1 minute
$inputs FIRSTTICK "start" STORE // count = ((end - start) / bucketspan) + 1
$lastBucket $start - $bucketSpan / TOLONG 1 + "bucketCount" STORE
[ $inputs bucketizer.mean $lastBucket $bucketSpan $bucketCount ] BUCKETIZE 'bucket' STORE
$bucket [ NaN NaN NaN 0 ] FILLVALUE SORT 'bucket' STORE // fill all empty ticks with zero
$bucket 0 GET 'wind' STORE
$bucket 1 GET 'pow' STORE
// calculate turbine perf according to vendor power curve
//'curve' STORE
$wind LABELS 'manufacturer' GET 'manu' STORE
<% $manu 'Sinovel' == %>
<% [ $myreadtoken '~curve.*' { 'Manufacturer' 'Sinovel' 'Model' 'SN1500' } NOW MAXLONG ] FETCH 'simTurbine' STORE
[ $simTurbine bucketizer.mean 0 1 0 ] BUCKETIZE INTERPOLATE SORT 'curve' STORE // interpolate the empty points
%> IFT
<% $manu 'Vestas' == %>
<% [ $myreadtoken '~curve.*' { 'Manufacturer' 'Vestas' 'Model' 'V112' } NOW MAXLONG ] FETCH 'simTurbine' STORE
[ $simTurbine bucketizer.mean 0 1 0 ] BUCKETIZE INTERPOLATE SORT 'curve' STORE // interpolate the empty points
%> IFT
<% $manu 'Goldwind' == %>
<% [ $myreadtoken '~curve.*' { 'Manufacturer' 'Goldwind' 'Model' 'GW165-6MW' } NOW MAXLONG ] FETCH 'simTurbine' STORE
[ $simTurbine bucketizer.mean 0 1 0 ] BUCKETIZE INTERPOLATE SORT 'curve' STORE // interpolate the empty points
%> IFT
//create curve of the turbine
$wind 100 * 'wind' STORE
$wind VALUES FLATTEN // ticks
[] [] [] // latitudes, longitudes and elevations
$pow VALUES FLATTEN // values
MAKEGTS
'data' RENAME 'data' STORE
[ $data bucketizer.mean 0 10 0 ] BUCKETIZE SORT 'turbinecurve' STORE
//calculate expected power with theoretical curve
[] 'values' STORE
$wind SIZE 1 - 'len' STORE
0 $len <% 'i' STORE
$curve $wind VALUES $i GET ATTICK 0 GET -1 GET 'value' STORE //for theoretical put instead bestcurve
<% $value NULL == %> <% 0 'value' STORE %>
<% $value 'value' STORE %> 1 SWITCH
$values [ $value ] APPEND 'values' STORE
%> FOR
$wind TICKLIST
[] [] []
$values
MAKEGTS 'Expected' RENAME 'expected' STORE
[ $pow bucketizer.sum 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'generated' STORE
[ $expected bucketizer.sum 0 0 1 ] BUCKETIZE VALUES 0 GET 0 GET 'expected' STORE
$generated $expected - TODOUBLE 60 / 'loss' STORE
//$generated $loss + 'total' STORE
//$generated $total / 100 * 'energy_avail' STORE
$generated $expected / 100 * 'energy_avail' STORE
$energy_avail 'tostring' STORE
<'
%.2f
'>
[ $tostring ] STRINGFORMAT 'energy_avail' STORE
<'
%.2f
'>
[ $loss ] STRINGFORMAT 'loss' STORE
'Difference:' $loss + 'loss' STORE
{
'key' $loss ' kwh' +
'value' $energy_avail
}
'data' STORE
{
'data' $data
}
%>
}
{
'title' 'Wind Direction'
'options' { //'autoRefresh' 10
'eventHandler' 'type=(variable|zoom|focus),tag=(TurbineId|plant|startDate|endDate)'
'showRangeSelector' true
}
'x' 8 'y' 1 'w' 4 'h' 4
'type' 'bar-polar' 'macro' <%
[ $myreadtoken '~(WIND_SPEED|WIND_DIRECTION).*' { 'plant' $plant 'TurbineId' $TurbineId }
$startDate TOSTRING
$endDate TOSTRING
//NOW 1 d
] FETCH 'data' STORE
$data { '.app' '' '.uuid' '' } RELABEL 'data' STORE
[ $data 0 GET bucketizer.last 0 10 m 0 ] BUCKETIZE 0 GET FILLPREVIOUS FILLNEXT SORT VALUES 'degrees' STORE //align times
[ $data 1 GET bucketizer.last 0 10 m 0 ] BUCKETIZE 0 GET FILLPREVIOUS FILLNEXT SORT VALUES 'speed' STORE // align times
/*
subtract 180 for sinovel scada
$data 0 GET LABELS 'manufacturer' GET 'manu' STORE
<% $manu 'Sinovel' == %> <% $degrees <% DROP 180 - %> LMAP 'degrees' STORE %> IFT
*/
$degrees SIZE 1 - 'len' STORE //total number of data
//define variables
0 'n02' STORE 0 'n24' STORE 0 'n46' STORE 0 'n68' STORE 0 'n810' STORE 0 'n1012' STORE 0 'n1214' STORE 0 'n1416' STORE 0 'n1618' STORE 0 'n1820' STORE 0 'n20+' STORE
0 'nne02' STORE 0 'nne24' STORE 0 'nne46' STORE 0 'nne68' STORE 0 'nne810' STORE 0 'nne1012' STORE 0 'nne1214' STORE 0 'nne1416' STORE 0 'nne1618' STORE 0 'nne1820' STORE 0 'nne20+' STORE
0 'ne02' STORE 0 'ne24' STORE 0 'ne46' STORE 0 'ne68' STORE 0 'ne810' STORE 0 'ne1012' STORE 0 'ne1214' STORE 0 'ne1416' STORE 0 'ne1618' STORE 0 'ne1820' STORE 0 'ne20+' STORE
0 'ene02' STORE 0 'ene24' STORE 0 'ene46' STORE 0 'ene68' STORE 0 'ene810' STORE 0 'ene1012' STORE 0 'ene1214' STORE 0 'ene1416' STORE 0 'ene1618' STORE 0 'ene1820' STORE 0 'ene20+' STORE
0 'e02' STORE 0 'e24' STORE 0 'e46' STORE 0 'e68' STORE 0 'e810' STORE 0 'e1012' STORE 0 'e1214' STORE 0 'e1416' STORE 0 'e1618' STORE 0 'e1820' STORE 0 'e20+' STORE
0 'ese02' STORE 0 'ese24' STORE 0 'ese46' STORE 0 'ese68' STORE 0 'ese810' STORE 0 'ese1012' STORE 0 'ese1214' STORE 0 'ese1416' STORE 0 'ese1618' STORE 0 'ese1820' STORE 0 'ese20+' STORE
0 'se02' STORE 0 'se24' STORE 0 'se46' STORE 0 'se68' STORE 0 'se810' STORE 0 'se1012' STORE 0 'se1214' STORE 0 'se1416' STORE 0 'se1618' STORE 0 'se1820' STORE 0 'se20+' STORE
0 'sse02' STORE 0 'sse24' STORE 0 'sse46' STORE 0 'sse68' STORE 0 'sse810' STORE 0 'sse1012' STORE 0 'sse1214' STORE 0 'sse1416' STORE 0 'sse1618' STORE 0 'sse1820' STORE 0 'sse20+' STORE
0 's02' STORE 0 's24' STORE 0 's46' STORE 0 's68' STORE 0 's810' STORE 0 's1012' STORE 0 's1214' STORE 0 's1416' STORE 0 's1618' STORE 0 's1820' STORE 0 's20+' STORE
0 'ssw02' STORE 0 'ssw24' STORE 0 'ssw46' STORE 0 'ssw68' STORE 0 'ssw810' STORE 0 'ssw1012' STORE 0 'ssw1214' STORE 0 'ssw1416' STORE 0 'ssw1618' STORE 0 'ssw1820' STORE 0 'ssw20+' STORE
0 'sw02' STORE 0 'sw24' STORE 0 'sw46' STORE 0 'sw68' STORE 0 'sw810' STORE 0 'sw1012' STORE 0 'sw1214' STORE 0 'sw1416' STORE 0 'sw1618' STORE 0 'sw1820' STORE 0 'sw20+' STORE
0 'wsw02' STORE 0 'wsw24' STORE 0 'wsw46' STORE 0 'wsw68' STORE 0 'wsw810' STORE 0 'wsw1012' STORE 0 'wsw1214' STORE 0 'wsw1416' STORE 0 'wsw1618' STORE 0 'wsw1820' STORE 0 'wsw20+' STORE
0 'w02' STORE 0 'w24' STORE 0 'w46' STORE 0 'w68' STORE 0 'w810' STORE 0 'w1012' STORE 0 'w1214' STORE 0 'w1416' STORE 0 'w1618' STORE 0 'w1820' STORE 0 'w20+' STORE
0 'wnw02' STORE 0 'wnw24' STORE 0 'wnw46' STORE 0 'wnw68' STORE 0 'wnw810' STORE 0 'wnw1012' STORE 0 'wnw1214' STORE 0 'wnw1416' STORE 0 'wnw1618' STORE 0 'wnw1820' STORE 0 'wnw20+' STORE
0 'nw02' STORE 0 'nw24' STORE 0 'nw46' STORE 0 'nw68' STORE 0 'nw810' STORE 0 'nw1012' STORE 0 'nw1214' STORE 0 'nw1416' STORE 0 'nw1618' STORE 0 'nw1820' STORE 0 'nw20+' STORE
0 'nnw02' STORE 0 'nnw24' STORE 0 'nnw46' STORE 0 'nnw68' STORE 0 'nnw810' STORE 0 'nnw1012' STORE 0 'nnw1214' STORE 0 'nnw1416' STORE 0 'nnw1618' STORE 0 'nnw1820' STORE 0 'nnw20+' STORE
// wind direction macros
<% $deg 22.5 < %> 'northlt' STORE <% $deg 337.5 > %> 'northgt' STORE //N 348.75 - 11.25
// <% $deg 11.25 > %> 'nnegt' STORE <% $deg 33.75 < %> 'nnelt' STORE //NNE 11.25 - 33.75
<% $deg 22.5 > %> 'negt' STORE <% $deg 67.5 < %> 'nelt' STORE //NE 33.75 - 56.25
// <% $deg 56.25 > %> 'enegt' STORE <% $deg 78.75 < %> 'enelt' STORE //ENE 56.25 - 78.75
<% $deg 67.5 > %> 'egt' STORE <% $deg 112.5 < %> 'elt' STORE //E 78.75 - 101.25
// <% $deg 101.25 > %> 'esegt' STORE <% $deg 123.75 < %> 'eselt' STORE //ESE 101.25 - 123.75
<% $deg 112.5 > %> 'segt' STORE <% $deg 157.5 < %> 'selt' STORE //SE 123.75 - 146.25
// <% $deg 146.25 > %> 'ssegt' STORE <% $deg 168.75 < %> 'sselt' STORE //SSE 146.25 - 168.75
<% $deg 157.5 > %> 'sgt' STORE <% $deg 202.5 < %> 'slt' STORE //S 168.75 - 191.25
// <% $deg 191.25 > %> 'sswgt' STORE <% $deg 213.75 < %> 'sswlt' STORE //SSW 191.25 - 213.75
<% $deg 202.5 > %> 'swgt' STORE <% $deg 247.5 < %> 'swlt' STORE //SW 213.75 - 236.25
// <% $deg 236.25 > %> 'wswgt' STORE <% $deg 258.75 < %> 'wswlt' STORE //WSW 236.25 - 258.75
<% $deg 247.5 > %> 'wgt' STORE <% $deg 292.5 < %> 'wlt' STORE //W 258.75 - 281.25
// <% $deg 281.25 > %> 'wnwgt' STORE <% $deg 303.75 < %> 'wnwlt' STORE //WNW 281.25 - 303.75
<% $deg 292.5 > %> 'nwgt' STORE <% $deg 337.5 < %> 'nwlt' STORE //NW 303.75 - 326.25
//<% $deg 326.25 > %> 'nnwgt' STORE <% $deg 348.75 < %> 'nnwlt' STORE //NNW 326.25 - 348.75
// wind speed macros
<% $spe 0.0 >= %> '02gt' STORE <% $spe 4 < %> '02lt' STORE //speed 0-2 m/s
// <% $spe 2.0 >= %> '24gt' STORE <% $spe 4 < %> '24lt' STORE //speed 2-4 m/s
<% $spe 4.0 >= %> '46gt' STORE <% $spe 8 < %> '46lt' STORE //speed 4-6 m/s
// <% $spe 6.0 >= %> '68gt' STORE <% $spe 8 < %> '68lt' STORE //speed 6-8 m/s
<% $spe 8.0 >= %> '810gt' STORE <% $spe 12 < %> '810lt' STORE //speed 8-10 m/s
// <% $spe 10.0 >= %> '1012gt' STORE <% $spe 12 < %> '1012lt' STORE //speed 10-12 m/s
<% $spe 12.0 >= %> '1214gt' STORE <% $spe 16 < %> '1214lt' STORE //speed 12-14 m/s
// <% $spe 14.0 >= %> '1416gt' STORE <% $spe 16 < %> '1416lt' STORE //speed 14-16 m/s
<% $spe 16.0 >= %> '1618gt' STORE <% $spe 20 < %> '1618lt' STORE //speed 16-18 m/s
// <% $spe 18.0 >= %> '1820gt' STORE <% $spe 20 < %> '1820lt' STORE //speed 18-20 m/s
<% $spe 20.0 >= %> '20gt' STORE <% $spe 50 < %> '20lt' STORE //speed 20+ m/s
//move along the list
0 $len <% 'i' STORE
$degrees $i GET 'deg' STORE
$speed $i GET 'spe' STORE
//define wind direction
<% [ @northlt @northgt ] OR %> <% //$deg TOSTRING 'N' +
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $n02 1 + 'n02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $n24 1 + 'n24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $n46 1 + 'n46' STORE %>
// <% [ @68gt @68lt ] AND %> <% $n68 1 + 'n68' STORE %>
<% [ @810gt @810lt ] AND %> <% $n810 1 + 'n810' STORE %>
// <% [ @1012gt @1012lt ] AND %> <% $n1012 1 + 'n1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $n1214 1 + 'n1214' STORE %>
// <% [ @1416gt @1416lt ] AND %> <% $n1416 1 + 'n1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $n1618 1 + 'n1618' STORE %>
// <% [ @1820gt @1820lt ] AND %> <% $n1820 1 + 'n1820' STORE %>
<% $n20+ 1 + 'n20+' STORE %>
5 SWITCH
%> // north
<% [ @negt @nelt ] AND %> <% //$deg TOSTRING 'NE' +
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $ne02 1 + 'ne02' STORE %> //$spe TOSTRING ' 02' +
// <% [ @24gt @24lt ] AND %> <% $ne24 1 + 'ne24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $ne46 1 + 'ne46' STORE %>
// <% [ @68gt @68lt ] AND %> <% $ne68 1 + 'ne68' STORE %>
<% [ @810gt @810lt ] AND %> <% $ne810 1 + 'ne810' STORE %>
// <% [ @1012gt @1012lt ] AND %> <% $ne1012 1 + 'ne1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $ne1214 1 + 'ne1214' STORE %>
// <% [ @1416gt @1416lt ] AND %> <% $ne1416 1 + 'ne1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $ne1618 1 + 'ne1618' STORE %>
// <% [ @1820gt @1820lt ] AND %> <% $ne1820 1 + 'ne1820' STORE %>
<% $ne20+ 1 + 'ne20+' STORE %>
5 SWITCH
%> //NE
<% [ @egt @elt ] AND %> <%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $e02 1 + 'e02' STORE %> //$spe TOSTRING ' 02' +
// <% [ @24gt @24lt ] AND %> <% $e24 1 + 'e24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $e46 1 + 'e46' STORE %>
//<% [ @68gt @68lt ] AND %> <% $e68 1 + 'e68' STORE %>
<% [ @810gt @810lt ] AND %> <% $e810 1 + 'e810' STORE %>
//<% [ @1012gt @1012lt ] AND %> <% $e1012 1 + 'e1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $e1214 1 + 'e1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $e1416 1 + 'e1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $e1618 1 + 'e1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $e1820 1 + 'e1820' STORE %>
<% $e20+ 1 + 'e20+' STORE %>
5 SWITCH
%> //E
<% [ @segt @selt ] AND %> <%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $se02 1 + 'se02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $se24 1 + 'se24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $se46 1 + 'se46' STORE %>
//<% [ @68gt @68lt ] AND %> <% $se68 1 + 'se68' STORE %>
<% [ @810gt @810lt ] AND %> <% $se810 1 + 'se810' STORE %>
//<% [ @1012gt @1012lt ] AND %> <% $se1012 1 + 'se1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $se1214 1 + 'se1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $se1416 1 + 'se1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $se1618 1 + 'se1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $se1820 1 + 'se1820' STORE %>
<% $se20+ 1 + 'se20+' STORE %>
5 SWITCH
%> //SE
<% [ @sgt @slt ] AND %> <%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $s02 1 + 's02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $s24 1 + 's24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $s46 1 + 's46' STORE %>
//<% [ @68gt @68lt ] AND %> <% $s68 1 + 's68' STORE %>
<% [ @810gt @810lt ] AND %> <% $s810 1 + 's810' STORE %>
// <% [ @1012gt @1012lt ] AND %> <% $s1012 1 + 's1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $s1214 1 + 's1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $s1416 1 + 's1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $s1618 1 + 's1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $s1820 1 + 's1820' STORE %>
<% $s20+ 1 + 's20+' STORE %>
5 SWITCH
%> //S
<% [ @swgt @swlt ] AND %> <%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $sw02 1 + 'sw02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $sw24 1 + 'sw24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $sw46 1 + 'sw46' STORE %>
//<% [ @68gt @68lt ] AND %> <% $sw68 1 + 'sw68' STORE %>
<% [ @810gt @810lt ] AND %> <% $sw810 1 + 'sw810' STORE %>
//<% [ @1012gt @1012lt ] AND %> <% $sw1012 1 + 'sw1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $sw1214 1 + 'sw1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $sw1416 1 + 'sw1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $sw1618 1 + 'sw1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $sw1820 1 + 'sw1820' STORE %>
<% $sw20+ 1 + 'sw20+' STORE %>
5 SWITCH
%> //SW
<% [ @wgt @wlt ] AND %> <%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $w02 1 + 'w02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $w24 1 + 'w24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $w46 1 + 'w46' STORE %>
//<% [ @68gt @68lt ] AND %> <% $w68 1 + 'w68' STORE %>
<% [ @810gt @810lt ] AND %> <% $w810 1 + 'w810' STORE %>
//<% [ @1012gt @1012lt ] AND %> <% $w1012 1 + 'w1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $w1214 1 + 'w1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $w1416 1 + 'w1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $w1618 1 + 'w1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $w1820 1 + 'w1820' STORE %>
<% $w20+ 1 + 'w20+' STORE %>
5 SWITCH
%> //W
//<% [ @nwgt @nwlt ] AND %>
<%
//define speed bucket
<% [ @02gt @02lt ] AND %> <% $nw02 1 + 'nw02' STORE %> //$spe TOSTRING ' 02' +
//<% [ @24gt @24lt ] AND %> <% $nw24 1 + 'nw24' STORE %> //$spe TOSTRING ' 24' +
<% [ @46gt @46lt ] AND %> <% $nw46 1 + 'nw46' STORE %>
// <% [ @68gt @68lt ] AND %> <% $nw68 1 + 'nw68' STORE %>
<% [ @810gt @810lt ] AND %> <% $nw810 1 + 'nw810' STORE %>
//<% [ @1012gt @1012lt ] AND %> <% $nw1012 1 + 'nw1012' STORE %>
<% [ @1214gt @1214lt ] AND %> <% $nw1214 1 + 'nw1214' STORE %>
//<% [ @1416gt @1416lt ] AND %> <% $nw1416 1 + 'nw1416' STORE %>
<% [ @1618gt @1618lt ] AND %> <% $nw1618 1 + 'nw1618' STORE %>
//<% [ @1820gt @1820lt ] AND %> <% $nw1820 1 + 'nw1820' STORE %>
<% $nw20+ 1 + 'nw20+' STORE %>
5 SWITCH
%> //NW
7 SWITCH
%> FOR
//convert to percent
$n02 TODOUBLE $len / TODOUBLE 100 * 'n02' STORE
//$n24 TODOUBLE $len / TODOUBLE 100 * 'n24' STORE
$n46 TODOUBLE $len / TODOUBLE 100 * 'n46' STORE
//$n68 TODOUBLE $len / TODOUBLE 100 * 'n68' STORE
$n810 TODOUBLE $len / TODOUBLE 100 * 'n810' STORE
//$n1012 TODOUBLE $len / TODOUBLE 100 * 'n1012' STORE
$n1214 TODOUBLE $len / TODOUBLE 100 * 'n1214' STORE
//$n1416 TODOUBLE $len / TODOUBLE 100 * 'n1416' STORE
$n1618 TODOUBLE $len / TODOUBLE 100 * 'n1618' STORE
//$n1820 TODOUBLE $len / TODOUBLE 100 * 'n1820' STORE
$n20+ TODOUBLE $len / TODOUBLE 100 * 'n20+' STORE
$ne02 TODOUBLE $len / TODOUBLE 100 * 'ne02' STORE
//$ne24 TODOUBLE $len / TODOUBLE 100 * 'ne24' STORE
$ne46 TODOUBLE $len / TODOUBLE 100 * 'ne46' STORE
//$ne68 TODOUBLE $len / TODOUBLE 100 * 'ne68' STORE
$ne810 TODOUBLE $len / TODOUBLE 100 * 'ne810' STORE
//$ne1012 TODOUBLE $len / TODOUBLE 100 * 'ne1012' STORE
$ne1214 TODOUBLE $len / TODOUBLE 100 * 'ne1214' STORE
//$ne1416 TODOUBLE $len / TODOUBLE 100 * 'ne1416' STORE
$ne1618 TODOUBLE $len / TODOUBLE 100 * 'ne1618' STORE
//$ne1820 TODOUBLE $len / TODOUBLE 100 * 'ne1820' STORE
$ne20+ TODOUBLE $len / TODOUBLE 100 * 'ne20+' STORE
$e02 TODOUBLE $len / TODOUBLE 100 * 'e02' STORE
//$e24 TODOUBLE $len / TODOUBLE 100 * 'e24' STORE
$e46 TODOUBLE $len / TODOUBLE 100 * 'e46' STORE
//$e68 TODOUBLE $len / TODOUBLE 100 * 'e68' STORE
$e810 TODOUBLE $len / TODOUBLE 100 * 'e810' STORE
//$e1012 TODOUBLE $len / TODOUBLE 100 * 'e1012' STORE
$e1214 TODOUBLE $len / TODOUBLE 100 * 'e1214' STORE
//$e1416 TODOUBLE $len / TODOUBLE 100 * 'e1416' STORE
$e1618 TODOUBLE $len / TODOUBLE 100 * 'e1618' STORE
//$e1820 TODOUBLE $len / TODOUBLE 100 * 'e1820' STORE
$e20+ TODOUBLE $len / TODOUBLE 100 * 'e20+' STORE
$se02 TODOUBLE $len / TODOUBLE 100 * 'se02' STORE
//$se24 TODOUBLE $len / TODOUBLE 100 * 'se24' STORE
$se46 TODOUBLE $len / TODOUBLE 100 * 'se46' STORE
//$se68 TODOUBLE $len / TODOUBLE 100 * 'se68' STORE
$se810 TODOUBLE $len / TODOUBLE 100 * 'se810' STORE
//$se1012 TODOUBLE $len / TODOUBLE 100 * 'se1012' STORE
$se1214 TODOUBLE $len / TODOUBLE 100 * 'se1214' STORE
//$se1416 TODOUBLE $len / TODOUBLE 100 * 'se1416' STORE
$se1618 TODOUBLE $len / TODOUBLE 100 * 'se1618' STORE
//$se1820 TODOUBLE $len / TODOUBLE 100 * 'se1820' STORE
$se20+ TODOUBLE $len / TODOUBLE 100 * 'se20+' STORE
$s02 TODOUBLE $len / TODOUBLE 100 * 's02' STORE
//$s24 TODOUBLE $len / TODOUBLE 100 * 's24' STORE
$s46 TODOUBLE $len / TODOUBLE 100 * 's46' STORE
//$s68 TODOUBLE $len / TODOUBLE 100 * 's68' STORE
$s810 TODOUBLE $len / TODOUBLE 100 * 's810' STORE
//$s1012 TODOUBLE $len / TODOUBLE 100 * 's1012' STORE
$s1214 TODOUBLE $len / TODOUBLE 100 * 's1214' STORE
//$s1416 TODOUBLE $len / TODOUBLE 100 * 's1416' STORE
$s1618 TODOUBLE $len / TODOUBLE 100 * 's1618' STORE
//$s1820 TODOUBLE $len / TODOUBLE 100 * 's1820' STORE
$s20+ TODOUBLE $len / TODOUBLE 100 * 's20+' STORE
$sw02 TODOUBLE $len / TODOUBLE 100 * 'sw02' STORE
//$sw24 TODOUBLE $len / TODOUBLE 100 * 'sw24' STORE
$sw46 TODOUBLE $len / TODOUBLE 100 * 'sw46' STORE
//$sw68 TODOUBLE $len / TODOUBLE 100 * 'sw68' STORE
$sw810 TODOUBLE $len / TODOUBLE 100 * 'sw810' STORE
//$sw1012 TODOUBLE $len / TODOUBLE 100 * 'sw1012' STORE
$sw1214 TODOUBLE $len / TODOUBLE 100 * 'sw1214' STORE
//$sw1416 TODOUBLE $len / TODOUBLE 100 * 'sw1416' STORE
$sw1618 TODOUBLE $len / TODOUBLE 100 * 'sw1618' STORE
//$sw1820 TODOUBLE $len / TODOUBLE 100 * 'sw1820' STORE
$sw20+ TODOUBLE $len / TODOUBLE 100 * 'sw20+' STORE
$w02 TODOUBLE $len / TODOUBLE 100 * 'w02' STORE
//$w24 TODOUBLE $len / TODOUBLE 100 * 'w24' STORE
$w46 TODOUBLE $len / TODOUBLE 100 * 'w46' STORE
//$w68 TODOUBLE $len / TODOUBLE 100 * 'w68' STORE
$w810 TODOUBLE $len / TODOUBLE 100 * 'w810' STORE
//$w1012 TODOUBLE $len / TODOUBLE 100 * 'w1012' STORE
$w1214 TODOUBLE $len / TODOUBLE 100 * 'w1214' STORE
//$w1416 TODOUBLE $len / TODOUBLE 100 * 'w1416' STORE
$w1618 TODOUBLE $len / TODOUBLE 100 * 'w1618' STORE
//$w1820 TODOUBLE $len / TODOUBLE 100 * 'w1820' STORE
$w20+ TODOUBLE $len / TODOUBLE 100 * 'w20+' STORE
$nw02 TODOUBLE $len / TODOUBLE 100 * 'nw02' STORE
//$nw24 TODOUBLE $len / TODOUBLE 100 * 'nw24' STORE
$nw46 TODOUBLE $len / TODOUBLE 100 * 'nw46' STORE
//$nw68 TODOUBLE $len / TODOUBLE 100 * 'nw68' STORE
$nw810 TODOUBLE $len / TODOUBLE 100 * 'nw810' STORE
//$nw1012 TODOUBLE $len / TODOUBLE 100 * 'nw1012' STORE
$nw1214 TODOUBLE $len / TODOUBLE 100 * 'nw1214' STORE
//$nw1416 TODOUBLE $len / TODOUBLE 100 * 'nw1416' STORE
$nw1618 TODOUBLE $len / TODOUBLE 100 * 'nw1618' STORE
//$nw1820 TODOUBLE $len / TODOUBLE 100 * 'nw1820' STORE
$nw20+ TODOUBLE $len / TODOUBLE 100 * 'nw20+' STORE
[ 'nw02' 'n02' 'ne02' 'e02' 'se02' 's02' 'sw02' 'w02' 'nw46' 'n46' 'ne46' 'e46' 'se46' 's46' 'sw46' 'w46' 'nw810' 'n810' 'ne810' 'e810' 'se810' 's810' 'sw810' 'w810' 'nw1214' 'n1214' 'ne1214' 'e1214' 'se1214' 's1214' 'sw1214' 'w1214' 'nw1618' 'n1618' 'ne1618' 'e1618' 'se1618' 's1618' 'sw1618' 'w1618' 'nw20+' 'n20+' 'ne20+' 'e20+' 'se20+' 's20+' 'sw20+' 'w20+' ] 'formatnames' STORE