-
Notifications
You must be signed in to change notification settings - Fork 0
/
ojfpostproc.py
2782 lines (2356 loc) · 110 KB
/
ojfpostproc.py
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
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 10 20:00:37 2012
@author: dave
"""
# STANDARD LIBRARY
from __future__ import division
import os
#import timeit
# COMMON 3TH PARTY
import numpy as np
import scipy.io
import scipy.integrate as integrate
#from matplotlib.figure import Figure
#from matplotlib.backends.backend_agg import FigureCanvasAgg as FigCanvas
#import matplotlib.font_manager as mpl_font
#from matplotlib.ticker import FormatStrFormatter
import matplotlib as mpl
#from matplotlib import tight_layout as tight_layout
import pylab as plt
# NOT SO COMMON 3TH PARTY
#from scikits.audiolab import play
import wafo
# CUSTOM
import plotting
import HawcPy
#import cython_func
#import ojfdesign
import bladeprop
import materials
import Simulations as sim
import misc
import ojfresult
import towercal
import bladecal
import yawcal
from ojfdb_dict import ojf_db
RESDATA_CAL_02 = 'data/raw/02/calibration/'
RESDATA_CAL_04 = 'data/raw/04/calibration/'
PROCESSING = 'processing/'
## make list containing all the files in the folder
#files = []
#for f in os.walk(power_res):
# files.append(f)
#
## load each file and merge into one airfoil_db dict
#for f in files[0][2]:
# if f.startswith('bemv') and f.endswith('.dat'):
# bem = np.loadtxt(power_res + f)
# plotaoa(bem, f, power_res +'aoa/')
# plotcpct(bem, f, power_res+'cpct/')
# plot_dM(bem, f, power_res+'load_dM/')
# plot_dF(bem, f, power_res+'load_dF/')
def _resistance_serie(ohms):
"""
"""
# eq_ohm_grid = np.ndarray()
x_range = np.arange(1,11)
R_range = np.arange(0.05, 5, 0.05)
# x: number of resistances in series
# R: resistance value of one unit
for x in x_range:
for R in R_range:
pass
return ohms.prod() / ohms.sum()
def example_simple():
respath = 'data/raw/02/2012-02-10/'
resfile = '0210_run_005_freeyaw_init_0_stiffblades_pwm1000.mat'
ojfmatfile = scipy.io.loadmat(respath+resfile)
# ojfmatfile file structure: dictionary with keys
# ['__version__', '__header__', 'run_005_freeyaw_init_0_sti','__globals__']
# __globals__ seems to be empty
# the actual data is behind the file name
L1 = ojfmatfile[ojfmatfile.keys()[2]]
# array([[ ([[(array([], dtype='<U1'), array([[4]], dtype=int32),
L2 = L1[0,0]
# >>> L2.dtype
# dtype([('X', '|O8'), ('Y', '|O8'), ('Description', '|O8'),
# ('RTProgram', '|O8'), ('Capture', '|O8')])
# --------------
# >>> L2['X'].dtype
# dtype([('Name', '|O8'), ('Type', '|O8'),('Data', '|O8'),('Unit', '|O8')])
time = L2['X']['Data'][0,0]
# --------------
# >>> L2['Y'].dtype
# dtype([('Name', '|O8'), ('Type', '|O8'),('Data', '|O8'),('Unit', '|O8'),
# ('XIndex', '|O8')])
channel = 0
data = L2['Y']['Data'][0,channel]
label = L2['Y']['Name'][0,channel]
# --------------
print time.shape, data.shape, label.shape
def psd_example():
"""
Example showing the effect of NFFT and Fs
"""
dt1 = 0.001
dt2 = 0.004
freq = 2
# omega = 10
# omega = 2*pi*f
# omega: angular frequency (rad/s)
# f: frequency (Hz)
# freq = omega / (2*np.pi)
omega = 2*np.pi*freq
time1 = np.arange(0,50,dt1)
time2 = np.arange(0,50,dt2)
data1 = np.sin(omega*time1) + (0.1*np.cos(omega*10*time1))
data2 = np.sin(omega*time2) + (0.1*np.cos(omega*10*time2))
plt.figure()
plt.plot(time1, data1)
plt.plot(time2, data2)
plt.figure()
# if you have 4* more points in data1, you will need to improve the
# accuracy and increase NFFT. Or is that the padding they refer to??
# NFFT: integer
# The number of data points used in each block for the FFT.
# Must be even; a power 2 is most efficient. The default value is 256.
# This should NOT be used to get zero padding, or the scaling of the
# result will be incorrect. Use pad_to for this instead.
Pxx1, freqs1 = plt.psd(data1, NFFT=4096, Fs=1/dt1, label='data1')
Pxx2, freqs2 = plt.psd(data2, NFFT=1024, Fs=1/dt2, label='data2')
plt.xlim(0, 50)
plt.legend()
###############################################################################
### CALIBRATION
###############################################################################
def compare_eigenfrq_ranges():
"""
See what happens when comparing a selected and full range
"""
# FOR THE BLADES
respath = 'data/raw/02/vibration/'
figpath = os.path.join(PROCESSING, 'eigenfrequencies/')
# there was only one vibriation test in Februari
# blade was just held tight at the root and then a deflection was
# imposed and suddenly released
resfile = '0213_run_099_straincalibration_blade12_tipdeflectionvibrations'
channels = [0,1,2,3]
blade = ojfresult.BladeStrainFile(respath+resfile)
blade.plot_channel(figpath=figpath, channel=channels)
# -----------------------------------------------------------------------
# compare results from selected range and full range
# selected range
pa4 = plotting.A4Tuned()
pa4.setup(figpath+resfile+'_COMPARE', nr_plots=4, grandtitle=resfile)
ax1 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 1)
ax2 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 2)
# make a numpy slice object
ss = np.r_[9200:11000]
ax1.plot(blade.time[ss], blade.data[ss,0])
Pxx, freqs = ax2.psd(blade.data[ss,0], NFFT=512, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax2.psd(blade.data[ss,0], NFFT=1024, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax2.psd(blade.data[ss,0], NFFT=2048, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax2.psd(blade.data[ss,0], NFFT=4096, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
ax2.set_xlim([0,20])
# full range
ss = np.r_[1:len(blade.time)]
ax3 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 3)
ax4 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 4)
ax3.plot(blade.time[ss], blade.data[ss,0])
#Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=512, Fs=blade.sample_rate)
#print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
#Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=1024, Fs=blade.sample_rate)
#print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=2048, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=4096, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=8192, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
Pxx, freqs = ax4.psd(blade.data[ss,0], NFFT=16384, Fs=blade.sample_rate)
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
ax4.set_xlim([0,20])
# ignore everything below 2Hz, give the highest peak
print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
pa4.save_fig()
# -----------------------------------------------------------------------
def eigenfreq_april():
"""
Frequency runs done in April for tower and blade
"""
nnfts = [8192,4096,2048]
nnfts = [2048]
respath = os.path.join('data/raw/', '04/vibration/')
figpath = os.path.join(PROCESSING, 'eigenfrequencies/')
# TOWER VIBRATIONS
resfile = '0405_run_248_towercal_destroy_fish_wire'
ds = ojfresult.DspaceMatFile(matfile=respath+resfile)
channels = ['Tower Strain Side-Side filtered',
'Tower Top acc X (SS)',
'Tower Strain For-Aft filtered',
'Tower Top acc Y (FA)']
ds.psd_plots(figpath, channels, nnfts=nnfts)
resfile = '0405_run_253_towervibrations'
ds = ojfresult.DspaceMatFile(matfile=respath+resfile)
eigenfreqs = ds.psd_plots(figpath, channels, nnfts=nnfts, saveresults=True)
# BLADE VIBRATIONS
#resfiles = ['257or258',
#'257or258-2',
#'0405_run_255or254a_bladecal_virbations_blade2',
#'0405_run_255or254_virbations_bladecal_blade2',
#'0405_run_257_bladecal_virbations_blad1']
#for resfile in resfiles:
#blade = ojfresult.BladeStrainFile(respath+resfile)
#eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts)
resfile = '257or258'
cn = ['flex B2 root','fles B2 30%',
'flex B1 root (excited)','flex B1 30% (excited)']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=cn, saveresults=True)
resfile = '257or258-2'
cn = ['flex B2 root (excited)','fles B2 30% (excited)',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=cn, saveresults=True)
resfile = '0405_run_255or254a_bladecal_virbations_blade2'
cn = ['flex B2 root (excited)','fles B2 30% (excited)',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=cn, saveresults=True)
resfile = '0405_run_255or254_virbations_bladecal_blade2'
cn = ['flex B2 root','fles B2 30%',
'flex B1 root (excited)','flex B1 30% (excited)']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=cn, saveresults=True)
resfile = '0405_run_257_bladecal_virbations_blad1'
cn = ['flex B2 root','fles B2 30%',
'flex B1 root (excited)','flex B1 30% (excited)']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=cn, saveresults=True)
def eigenfreq_februari():
"""
Plot all eigenfrequency test runs and determine the frequencies.
You do not need to slice-out the vibration area (or select only datapoints
for which the vibration is clearly present). Results are the same when
taking the whole data range.
"""
nnfts = [8192,4096,2048]
nnfts = [2048]
# FOR THE BLADES
respath = 'data/raw/02/vibration/'
figpath = os.path.join(PROCESSING, 'eigenfrequencies/')
# there was only one vibriation test in Februari
# blade was just held tight at the root and then a deflection was
# imposed and suddenly released
resfile = '0213_run_099_straincalibration_blade12_tipdeflectionvibrations'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
#Pxx, freqs = mpl.mlab.psd(blade.data[:,0], NFFT=8192, Fs=blade.sample_rate)
# maximum frequency
#print freqs[Pxx[[freqs.__ge__(2.5)]].argmax()]
def eigenfreq_august():
"""
Plot all eigenfrequency test runs and determine the frequencies.
You do not need to slice-out the vibration area (or select only datapoints
for which the vibration is clearly present). Results are the same when
taking the whole data range.
"""
nnfts = [8192,4096,2048]
nnfts = [2048]
# FOR THE BLADES
respath = 'data/raw/08_vibration/'
figpath = os.path.join(PROCESSING, 'eigenfrequencies/')
resfile = '500_trigger01_413314024'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '501_b1_stiff_trigger02_2664171792'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '502_b1_stiff_trigger03_504929400'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '503_b2_stiff_trigger01_507476419'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '504_b2_stiff_trigger02_2430537494'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '505_b2_stiff_trigger03_165311127'
#channels = [0,1,2,3]
channel_names = ['stiff B2 root','stiff B2 30%',
'stiff B1 root','stiff B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '506_b1_flex_trigger01_2990608704'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '507_b1_flex_trigger02_1468965218'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '508_b1_flex_trigger03_3392483542'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '509_b1_flex_trigger01_2199793801'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '510_b1_flex_trigger02_2059868129'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '511_b1_flex_trigger03_3824274622'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '512_b2_flex_trigger01_3962726656'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '513_b2_flex_trigger02_1803468531'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '514_b2_flex_trigger03_2354543381'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '515_b2_flex_trigger01_2423128572'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '516_b2_flex_trigger02_157778266'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
resfile = '517_b2_flex_trigger03_2028120981'
#channels = [0,1,2,3]
channel_names = ['flex B2 root','flex B2 30%',
'flex B1 root','flex B1 30%']
blade = ojfresult.BladeStrainFile(respath+resfile)
eigenfreqs = blade.psd_plots(figpath, [0,1,2,3], nnfts=nnfts,
channel_names=channel_names, fn_max=250, saveresults=True)
def eigenfreq_tower():
"""
Manually obtained from 0405_run_253_towervibrations
"""
path = os.path.join(PROCESSING, 'eigenfreq_damp_tower/')
# is 24.41 the tower or something else? Remember the vibration measurements
# where done on the complete wind turbine infrastructure
fn = np.array([4.39, 24.41, 30.76])
fname = 'eigenfreq_tower_ss'
np.savetxt(path+fname, fn)
fn = np.array([3.91, 24.41, 34.67])
fname = 'eigenfreq_tower_fa'
np.savetxt(path+fname, fn)
def eigenfreq_blade():
"""
Because the blade eigenfrequency analysis is not very clear to handle,
create manually the result files
"""
path = os.path.join(PROCESSING, 'eigenfreq_damp_blade/')
# blade 1 stiff
struct = 'stiff'
bladenr = 'B1'
fn = np.array([17.0, 74.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
bladenr = 'B2'
fn = np.array([17.0, 72.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
# blade 3 stiff
struct = 'stiff'
bladenr = 'B3'
fn = np.array([17.0, 73.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
# blade 1 flex
struct = 'flex'
bladenr = 'B1'
fn = np.array([12.0, 54.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
# blade 2 flex
struct = 'flex'
bladenr = 'B2'
fn = np.array([11.0, 54.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
# blade 3 flex
struct = 'flex'
bladenr = 'B3'
fn = np.array([12.0, 54.0])
fname = 'eigenfreq_%s_%s' % (struct, bladenr)
np.savetxt(path+fname, fn)
def february_calibration():
"""
Create all the calibration transformation polynomials for the February
session
"""
# -------------------------------------------------------------
# Blade Strain Calibration
# -------------------------------------------------------------
bladecal.feb_bladestrain_calibration()
# -------------------------------------------------------------
# Tower Calibration
# -------------------------------------------------------------
# bad calibration results mean no tower calibration for February
# -------------------------------------------------------------
# Yaw calibration
# -------------------------------------------------------------
yawcal.feb_yawlaser_calibration()
def april_calibration():
"""
All the calibrations for the April session
"""
# -------------------------------------------------------------
# Yaw calibration
# -------------------------------------------------------------
yawcal.apr_yawlaser_calibration()
# -------------------------------------------------------------
# Tower calibration
# -------------------------------------------------------------
towercal.all_tower_calibrations()
# -------------------------------------------------------------
# Blade calibration
# -------------------------------------------------------------
bladecal.apr_bladestrain_calibration()
def blade_extension_drag():
"""
Blade extension calibration tests executed at Risoe
"""
#bc = BladeCalibration()
#bc.extension()
#bc.drag()
# get all the data points
#bc.extension2()
# load all the bc.extension2 generated data
figpath = os.path.join(PROCESSING, 'BladeStrainCalExt/')
#stiff_B2_ch1 = np.loadtxt(figpath+'stiff_B2_ch1_allpoints')
#stiff_B2_ch2 = np.loadtxt(figpath+'stiff_B2_ch2_allpoints')
#flex_B2_ch3 = np.loadtxt(figpath+'flex_B2_ch3_allpoints')
#flex_B2_ch4 = np.loadtxt(figpath+'flex_B2_ch4_allpoints')
## and plot them
#plt.plot(stiff_B2_ch1[1,:], stiff_B2_ch1[0,:], 'bo')
delta_ch1 = np.loadtxt(figpath+'delta_ch1')
delta_ch2 = np.loadtxt(figpath+'delta_ch2')
delta_ch3 = np.loadtxt(figpath+'delta_ch3')
plt.figure(1)
plt.plot(delta_ch1[0,:], delta_ch1[1,:], 'b^', label='root 7xx stiff')
plt.plot(delta_ch2[0,:], delta_ch2[1,:], 'r^', label='30 7xx stiff')
plt.plot(delta_ch3[0,:], delta_ch3[1,:], 'gv', label='root 7xx flex')
plt.grid()
plt.legend(bbox_to_anchor=(1.0, 1.1), ncol=2)
plt.xlabel('kg')
plt.ylabel('strain/kg')
ff = np.loadtxt(figpath+'ext_703_flex_B2_ch3_deltas')
print ff
ff = np.loadtxt(figpath+'ext_704_flex_B2_ch3_deltas')
print ff
ff = np.loadtxt(figpath+'ext_705_flex_B2_ch3_deltas')
print ff
def blade_extension_3():
"""
Final and last attempt to get the blade strain extensional influence
"""
#bc = BladeCalibration()
#bc.extension3_flex()
#bc.extension3_stiff()
# load all the bc.extension3 generated data
figpath = os.path.join(PROCESSING, 'BladeStrainCalExt/')
#delta_ch1 = np.loadtxt(figpath+'delta_ch1_8xx')
#delta_ch2 = np.loadtxt(figpath+'delta_ch2_8xx')
delta_ch3 = np.loadtxt(figpath+'delta_ch3_8xx')
delta_ch4 = np.loadtxt(figpath+'delta_ch4_8xx')
#plt.figure(2)
#plt.plot(delta_ch1[0,:], delta_ch1[1,:], 'bo', label='root B2 stiff')
#plt.plot(delta_ch2[0,:], delta_ch2[1,:], 'rs', label='30 B2 stiff')
plt.plot(delta_ch3[0,:], delta_ch3[1,:], 'g>', label='root 8xx flex')
plt.plot(delta_ch4[0,:], delta_ch4[1,:], 'y<', label='30 8xx flex')
plt.grid()
plt.legend(bbox_to_anchor=(1.0, 1.1), ncol=2)
plt.xlabel('kg')
plt.ylabel('strain/kg')
#ff = np.loadtxt(figpath+'ext_703_flex_B2_ch3_deltas')
#print ff
#ff = np.loadtxt(figpath+'ext_704_flex_B2_ch3_deltas')
#print ff
#ff = np.loadtxt(figpath+'ext_705_flex_B2_ch3_deltas')
#print ff
def plot_sync_blade_strain_dspace():
"""
Plots to illustrate the syncing between dspace and blade strain and its
importance.
"""
figpath = os.path.join(PROCESSING, 'sync_dspace_bladestrain/')
respath = 'database/symlinks_all/'
# illustrate the drifting of dSPACE and MicroStrain clocks, high rpm
resfile = '0404_run_223_9.0ms_dc1_flexies_fixyaw_highrpm'
res = ojfresult.ComboResults(respath, resfile, sync=False)
res.overlap_pulse(figpath)
res._sync_strain_dspace(checkplot=False)
res.overlap_pulse(figpath)
# illustrate the drifting of dSPACE and MicroStrain clocks, low rpm
resfile = '0404_run_212_9.0ms_dc0.6_flexies_fixyaw_lowrpm'
res = ojfresult.ComboResults(respath, resfile, sync=False)
res.overlap_pulse(figpath)
res._sync_strain_dspace(checkplot=False)
res.overlap_pulse(figpath)
# high rpm with free yawing
r='0405_run_288_9.0ms_dc0_flexies_freeyawforced_yawerrorrange_fastside_highrpm'
res = ojfresult.ComboResults(respath, r, sync=False)
res.overlap_pulse(figpath)
res._sync_strain_dspace(checkplot=False, min_h=0.20)
res.overlap_pulse(figpath)
res.dashboard_a3(figpath)
###############################################################################
### BLADE TESTS
###############################################################################
def structural_prop():
"""
Based on st_from_etanna, but supplemented in order to have all data
available for more advanced mass distribution estimations.
It generates cross sectional data for the airfoil full of foam,
a hybrid model where airfoil and etanna beam are merged together, and
the etanna only model.
this function was used to generate data during the ojf post
processing phase
Blade structural details tuned based on the experimental data: cg,
eigenfrequency, mass including foam, stiffness from experiment
An early version of this method lives in ojfdesign.structural_prop()
"""
# desnity of the foam is 35 or 70 kg/m3. We used the heavier foam, but
# that's probably only internally in the beam box.
# It was the 70 that failed to come of the mould nicely and Nic
# had to fall back to the 200 one. I remember him saying: "if only there
# was a 120-150 or something, than it would have probably worked just fine"
rho_foam = 200 # consistent with the PVC_H200 material density
# load the general blade layout
quasi_dat = 'data/model/blade_hawtopt/'
blade = np.loadtxt(quasi_dat + 'blade.dat')
blade[:,0] = blade[:,0] - blade[0,0]
blade = misc._linear_distr_blade(blade)
twist = blade[:,2]
# prepare the st object
md = sim.ModelData(silent=False)
file_path = quasi_dat
file_name = 'from-etanna-to-hawc2.st'
md.prec_float = ' 10.06f'
md.prec_exp = ' 10.4e'
#md.load_st(file_path, file_name)
# headers for the st_k are
sti = HawcPy.ModelData.st_headers
# calculate the case for the airfoil shape full of foam
figpath = quasi_dat + 'foamonly_cross/'
bl = bladeprop.Blade(figpath=figpath, plot=False)
# blade: [r, chord, t/c, twist]
s822, t822 = bladeprop.S822_coordinates()
s823, t823 = bladeprop.S823_coordinates()
airfoils = ['S823', s823, t823, 'S822', s822, t822]
#['S823','S822']
blade_hr, volume, area, x_na, y_na, Ixx, Iyy, st_arr, strainpos \
= bl.build(blade[:,[0,1,3,2]],airfoils,res=None,step=None,\
plate=False, tw1_t=0, tw2_t=0)
# and save in st-array format
st_airf = np.ndarray((len(area),19))
st_airf[:,:] = st_arr
# material properties from PVC foam
#st_airf[:,sti.E] = materials.Materials().cores['PVC_H200'][1]
st_airf[:,sti.G] = materials.Materials().cores['PVC_H200'][3]
# the chord
st_airf[:,sti.r] = blade[:,0]
# set shear factor
st_airf[:,sti.k_x] = 0.7 # k_x what is shear coefficient for a plate?
st_airf[:,sti.k_y] = 0.7 # k_y
# set the pitch angle correct so that the structrural part is straight
st_airf[:,sti.pitch] = twist
# and safe to a file
np.savetxt(quasi_dat + 'airfoil-foam-only.st', st_airf, fmt='%16.12f')
# -------------------------------------------------------------------
# and write to a nicely formatted st file
m_airf_tot = integrate.trapz(st_airf[:,1], x=blade[:,0], axis=-1)
# comments are placed in an iterable (tuple or list)
details = md.column_header_line
details += 'Blade foam only, volume %2.6f m3' % (volume)
details += ' mass: %.5f kg\n' % (m_airf_tot)
# and write to a nicely formatted st file
# '07-00-0' : set number line in one peace
# '07-01-a' : comments for set-subset nr 07-01 (str)
# '07-01-b' : subset nr and number of data points, should be
# autocalculate every time you generate a file
# '07-01-d' : data for set-subset nr 07-01 (ndarray(n,19))
md.st_dict = dict()
md.st_dict['007-003-a'] = details
md.st_dict['007-003-b'] = '$3 18 Blade foam only\n'
md.st_dict['007-003-d'] = st_airf
r = blade[:,0]
# the sets 37 and 38 are the beams final form
for k in [41, 42]:
# on the etanna st-37 and st-38, the core of the beam is filled
# with 70 kg/m3 foam. However, this is only accounted for by the
# cross sectional area and the mass. Other parameters are not
# affected: no stiffness or moment of inertia contributions.
# st-41 and st-42 are the same as 37/38, 39/40, but now A and m
# only take the laminate into account. The latter is the correct
# approach. Otherwise the extensional stiffness EA is way too high
# and the radius of gyration is also incorrect.
print 'converting to st format: ' + 'result-st-'+str(k)
# for an octave saved text file
tp = 'data/model/cross_section_modeling/'
data = np.loadtxt(tp+'result-st-'+str(k), skiprows=5)
st_beam = data[:,0:19]
# determine plate thickness. Used in modeller: tply = 0.1524e-3 as
# ply thickness
if k == 41:
tw_t = 0.1524e-3*8
elif k == 42:
tw_t = 0.1524e-3*2
else:
tw_t = 0
# first row is actually the chord, get rid of that. It should be radius
st_beam[:,sti.r] = blade[:,0]
# set shear factor
st_beam[:,sti.k_x] = 0.7 # k_x what is shear coefficient for a plate?
st_beam[:,sti.k_y] = 0.7 # k_y
# set the pitch angle correct so that the structrural part is straight
st_beam[:,sti.pitch] = twist
# correct mass: add foam for the airfoil shape, LE coordinates
#figpath = quasi_dat + 'foambeam_st%i_cross_LE/' %k
# half chord point coordinates
figpath = quasi_dat + 'foambeam_st%i_cross_c2/' %k
bl = bladeprop.Blade(figpath=figpath, plot=True)
s822, t822 = bladeprop.S822_coordinates()
s823, t823 = bladeprop.S823_coordinates()
airfoils = ['S823', s823, t823, 'S822', s822, t822]
# blade: [r, chord, t/c, twist]
blade_hr, volume, area, x_na, y_na, Ixx, Iyy, st_arr, strainpos \
= bl.build(blade[:,[0,1,3,2]], airfoils, res=None,step=None,\
plate=True, tw1_t=tw_t, tw2_t=tw_t, st_arr_tw=st_beam)
#blade_hr : radial stations, [radius, chord, t/c, twist]
# hybrid model: merge foam only and beam together
st_hybr = st_arr.copy()
# -------------------------------------------------------------------
# ORIGINAL BEAM FIBRE ONLY
# and write to a nicely formatted st file
m_beam_tot = integrate.trapz(st_beam[:,1], x=r, axis=-1)
# comments are placed in an iterable (tuple or list)
details = md.column_header_line
details += 'from Etanna, source file: result-st-%i\n' % (k)
details += 'beam mass: %.5f kg\n' % (m_beam_tot)
details += 'ORIGINAL ETANNA OUTPUT\n'
details += 'Here we assume that A,m of the beam only includes'
details += 'the laminate. Internal foam is ignored for the beam'
details += 'but included with the airfoil foam.\n'
details += 'Note that this holds a small error: beam foam'
details += 'was lighter than the airfoil foil.\n'
if k == 41: ii=4
else: ii=8
md.st_dict['007-%03i-a' % (ii)] = details
md.st_dict['007-%03i-b' % (ii)] = '$%i 18\n' % (ii)
md.st_dict['007-%03i-d' % (ii)] = st_beam.copy()
# and safe to a normal array txt file too
filename = 'st-%i-beam.txt' % k
np.savetxt(quasi_dat + filename, st_beam, fmt='%16.12f')
# save the strain gauges positions as well
filename = 'strainpos-%i-beam.txt' % k
np.savetxt(quasi_dat + filename, strainpos, fmt='%16.12f')
# -------------------------------------------------------------------
# SAVE THE HYBRID APPROACH
## and write to a nicely formatted st file
#m_hybr_tot = integrate.trapz(st_hybr[:,1], x=r, axis=-1)
## comments are placed in an iterable (tuple or list)
#details = ['from Etanna, source file: result-st-%i' % (k)]
#details[0] += '\nhybrid mass: %.5f kg' % (m_hybr_tot)
#details[0] += '\nFor the hybrid beam and foam are added together'
#details[0] += ' where Ixx, Iyy, rx, ry, Ip, A are scaled with the'
#details[0] += ' ratio between E,G of foam and laminate'
#st_dict['001' + '01' + '-' + '03' + '-data'] = st_hybr
#st_dict['001' + '01' + '-' + '03' + '-comments'] = details
## and safe to a normal array txt file too
#filename = 'st-%i-hybrid.txt' % k
#np.savetxt(quasi_dat + filename, st_hybr, fmt='%16.12f')
# -------------------------------------------------------------------
# VERSION WITH CORRECTED BLADE MASS
# also create mass inbalances:
# Blade 1 stiff 202.34
# Blade 2 stiff 198.1
# Blade 3 stiff 222.7
st_arr_cor = st_airf.copy()
# WRONG FIRST TIME: it is the other way around: 41 is the FLEX BLADE
# > it is corrected now
if k == 42:
ii = 5
m_goal = 0.20234
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 1 STIFF CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii)] = details
md.st_dict['007-%03i-b' % (ii)] = '$%i 18\n' % (ii)
md.st_dict['007-%03i-d' % (ii)] = st_arr_cor.copy()
m_goal = 0.1981
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 2 STIFF CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii+1)] = details
md.st_dict['007-%03i-b' % (ii+1)] = '$%i 18\n' % (ii+1)
md.st_dict['007-%03i-d' % (ii+1)] = st_arr_cor.copy()
m_goal = 0.2227
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 3 STIFF CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii+2)] = details
md.st_dict['007-%03i-b' % (ii+2)] = '$%i 18\n' % (ii+2)
md.st_dict['007-%03i-d' % (ii+2)] = st_arr_cor.copy()
# Blade 1 flex 162.6
# Blade 2 flex 150.7
# Blade 3 flex 141.12
elif k == 41:
ii=9
m_goal = 0.1626
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 1 FLEX CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii)] = details
md.st_dict['007-%03i-b' % (ii)] = '$%i 18\n' % (ii)
md.st_dict['007-%03i-d' % (ii)] = st_arr_cor.copy()
m_goal = 0.1507
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 2 FLEX CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii+1)] = details
md.st_dict['007-%03i-b' % (ii+1)] = '$%i 18\n' % (ii+1)
md.st_dict['007-%03i-d' % (ii+1)] = st_arr_cor.copy()
m_goal = 0.14112
dm = (m_goal - (m_airf_tot + m_beam_tot))/r[-1]
st_arr_cor[:,sti.m] = st_airf[:,sti.m] + st_beam[:,sti.m] + dm
m_cor = integrate.trapz(st_arr_cor[:,sti.m], x=r, axis=-1)
details = md.column_header_line
details += 'BLADE 3 FLEX CORRECTED: stiffness foam only, \n'
details += 'mass=beam+foam+correction=%3.6f kg ' % m_cor
details += '(should match %3.6f)\n' % m_goal
details += 'beam: Etanna source file: result-st-%i\n' % (k)
md.st_dict['007-%03i-a' % (ii+2)] = details
md.st_dict['007-%03i-b' % (ii+2)] = '$%i 18\n' % (ii+2)
md.st_dict['007-%03i-d' % (ii+2)] = st_arr_cor.copy()
else:
raise UserWarning, 'what st set are you talking about? %i ??' % k
# start plotting -----------------------------------------------------
# Compare the beam, foam only and hybrid models
figfile = 'st-%i-beam-hybrid-airfoil' % k
pa4 = plotting.A4Tuned()
pa4.setup(quasi_dat+figfile, nr_plots=7, grandtitle=figfile)
ax1 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 1)
ax2 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 2)
ax3 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 3)
ax4 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 4)
ax5 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 5)
ax6 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 6)
ax7 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 7)
#ax8 = pa4.fig.add_subplot(pa4.nr_rows, pa4.nr_cols, 8)
#ax1.set_title('area')
ax1.plot(r, st_beam[:,sti.A], 'bx-', label='$A_{beam}$')
ax1.plot(r, st_airf[:,sti.A], 'rs-', label='$A_{foam}$')
ax1.plot(r, st_hybr[:,sti.A], 'go-', label='$A_{hybrid}$')
ax1.legend()
ax1.grid(True)
#ax2.set_title('mass')
ax2.plot(r, st_beam[:,sti.m], 'bx-', label='$m_{beam}$')
ax2.plot(r, st_airf[:,sti.m], 'rs-', label='$m_{foam}$')
ax2.plot(r, st_hybr[:,sti.m], 'go-', label='$m_{hybrid}$')
ax2.plot(r, st_arr_cor[:,sti.m], 'yo-', label='$m_{cor}$')
ax2.legend()