-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpiv_bfield_figures.m~
720 lines (543 loc) · 17.1 KB
/
piv_bfield_figures.m~
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
function piv_bfield_figures(OPTIONS, dir_case)
disp('');
disp('-----------------------------------------------------------------------------------');
disp(' ______ _ ');
disp('| ____(_) ');
disp('| |__ _ __ _ _ _ _ __ ___ ___ ');
disp('| __| | |/ _` | | | | .__/ _ \/ __|');
disp('| | | | (_| | |_| | | | __/\__ \');
disp('|_| |_|\__, |\__,_|_| \___||___/');
disp(' __/ | ');
disp(' |___/ ');
disp(['making figures. dir_case: ' dir_case]);
disp('-----------------------------------------------------------------------------------');
disp('');
dir_figures = [dir_case filesep 'figures'];
% Define limits of colorbar scaling, this is flow dependent
% clims_Umag = [1000 4000]; % in pixel world
clims_Umag = [OPTIONS.inflow*(1 - OPTIONS.inflow*0.7) OPTIONS.inflow*(1 - OPTIONS.inflow*1.3)]; % in meters world
% clims_u = [-2000 2000];
clims_u = [\OPTIONS.inflow*0.7 0.7];
% define some colormaps
% pmkmp_maps = {'IsoAZ' 'IsoAZ180' 'Edge' 'Swtth' 'LinLhot' 'LinearL' 'IsoAZ'};
cmap_LinLHot = flipud(pmkmp(11, 'LinLhot'));
cmap_bipolar = bipolar(21, 0.80);
% set some default font sizes
set(0,'defaultAxesFontSize', 24);
set(0,'defaultlinelinewidth',4)
% determine units for axis labels
if OPTIONS.T_inv == 1 && isempty(OPTIONS.mmpp)
% pixels / second
units_speed = ' (pixels / second)';
else
% meters / second
units_speed = ' (meters / second)';
end
% .mat files of raw, and filtered and transformed vectors
files = dir([dir_case filesep 'vectors' filesep 'raw' filesep '*.mat']);
fnames = sort_nat({files.name}, 'ascend'); % sort the file list with natural ordering
fnames_raw = fnames(:); % reshape into a nicer list
files = dir([dir_case filesep 'vectors' filesep 'instantaneous' filesep '*.mat']);
fnames = sort_nat({files.name}, 'ascend'); % sort the file list with natural ordering
fnames_inst = fnames(:); % reshape into a nicer list
files = dir([dir_case filesep 'vectors' filesep 'fluctuating' filesep '*.mat']);
fnames = sort_nat({files.name}, 'ascend'); % sort the file list with natural ordering
fnames_fluct = fnames(:); % reshape into a nicer list
%% plot instantaneous variables
parfor n = 1:numel(fnames_inst)
%% Load in the variables to plot
% load the .mat file of raw vectors
RAW = load([dir_case filesep 'vectors' filesep 'raw' filesep fnames_raw{n}]);
pkh = RAW.pkh;
snr = RAW.snr;
% load the .mat file of instantaneous, filtered and transformed data
POST = load([dir_case filesep 'vectors' filesep 'instantaneous' filesep fnames_inst{n}]);
x = POST.x;
y = POST.y;
fu = POST.fu;
fv = -1 .* post.fv; % because flow in images is going up-to-down
fwz = post.fwz;
%% velocity magnitude
hFig = init_figure([]);
Umag = sqrt(post.fu.^2 + post.fv.^2);
contourf(post.x, post.y, Umag);
colormap(cmap_LinLHot)
title(['velocity magnitude ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_Umag)
saveas(hFig, [dir_figures filesep 'velocity_mag__' sprintf('%5.5d',n)], 'png')
%% velocity U
hFig = init_figure([]);
contourf(x, y, fu);
colormap(cmap_bipolar)
colorbar;
title(['crossflow velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_u)
caxis(clims_u)
saveas(hFig, [dir_figures filesep 'velocity_u__' sprintf('%5.5d',n)], 'png')
%% velocity V
hFig = init_figure([]);
contourf(x, y, fv);
colormap(cmap_LinLHot)
colorbar;
title(['streamwise velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_Umag)
saveas(hFig, [dir_figures filesep 'velocity_v__' sprintf('%5.5d',n)], 'png')
%% Vorticity
hFig = init_figure([]);
contourf(x, y, fwz);
colormap(cmap_bipolar)
colorbar;
axis square
colorbar;
caxis([-80 80])
title('Vorticity (/s)')
xlabel('')
ylabel('')
saveas(hFig, [dir_figures filesep 'vorticity_z__' sprintf('%5.5d',n)], 'png')
% %% SLICE velocity U mag
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), Umag(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), Umag(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('velocity magnitude')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([0 6000]);
%
% saveas(hFig, [dir_figures filesep 'slice_velocity_mag__' sprintf('%5.5d',n)], 'png')
%
% %% SLICE velocity U
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), fu(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), fu(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('crossflow velocity')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([-6000 6000]);
%
% saveas(hFig, [dir_figures filesep 'slice_velocity_u__' sprintf('%5.5d',n)], 'png')
%
%
% %% SLICE velocity V
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), fv(centerline_y,:), '-r');
% hold on;
% plot(1:size(y,2), fv(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('streamwise velocity')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([-6000 6000]);
%
% saveas(hFig, [dir_figures filesep 'slice_velocity_v__' sprintf('%5.5d',n)], 'png')
%
%
% %% SLICE vorticity
% hFig = init_figure([]);
%
% centerline_x = floor( size(fwz,1)/2 );
% centerline_y = floor( size(fwz,2)/2 );
%
% plot(1:size(fwz,1), fwz(centerline_y,:), '-r');
% hold on;
% plot(1:size(fwz,2), fwz(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('vorticity')
% xlabel('distance along slice')
% ylabel('vorticity (/s)')
% ylim([-200 200]);
%
% saveas(hFig, [dir_figures filesep 'slice_vorticity_z__ ' sprintf('%5.5d',n)], 'png')
%% cleanup (otherwise Matlab may give memory errors after creatting too many figure handles)
close all;
fclose all;
end % INSTANTANEOUS
%% plot statistical variables
% load in the statistics variables
STATS = load([dir_case filesep 'vectors' filesep 'stats' filesep 'stats.mat']);
x = STATS.x;
y = STATS.y;
mean_u = STATS.mean_u;
mean_v = -1 .* STATS.mean_v;
mean_Umag = STATS.mean_Umag;
std_u = STATS.std_u;
std_v = STATS.std_v;
std_mag = STATS.std_mag;
rms_u = STATS.rms_u;
rms_v = STATS.rms_v;
rms_mag = STATS.rms_mag;
mean_wz = STATS.mean_wz;
%% mean velocity magnitude normalized by inflow velocity
hFig = init_figure([]);
contourf(x, y, mean_Umag ./ OPTIONS.inflow);
colormap(cmap_LinLHot)
title(['mean velocity deficit magnitude, mean_U_mag / U_inflow'])
xlabel('mean_U_mag / U_inflow')
ylabel('')
axis square
colorbar;
caxis(clims_Umag)
saveas(hFig, [dir_figures filesep 'mean_velocity_mag_deficit'], 'png')
%% mean velocity magnitude
hFig = init_figure([]);
contourf(x, y, mean_Umag);
colormap(cmap_LinLHot)
colorbar;
title(['mean velocity magnitude ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_Umag)
saveas(hFig, [dir_figures filesep 'mean_velocity_mag'], 'png')
%% mean velocity U
hFig = init_figure([]);
contourf(x, y, mean_u);
colormap(cmap_bipolar)
colorbar;
title(['crossflow mean velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_u)
saveas(hFig, [dir_figures filesep 'mean_velocity_u'], 'png')
%% mean velocity V
hFig = init_figure([]);
contourf(x, y, mean_v);
colormap(cmap_LinLHot)
colorbar;
title(['streamwise mean velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_Umag)
saveas(hFig, [dir_figures filesep 'mean_velocity_v'], 'png')
%% Standard Deviation Magnitude
hFig = init_figure([]);
contourf(x, y, std_mag);
colormap(cmap_LinLHot)
colorbar;
title('standard deviation magnitude')
xlabel('')
ylabel('')
ylabel(cbar, ['standard deviation ' units_speed])
axis square
colorbar;
caxis([0 400])
saveas(hFig, [dir_figures filesep 'standard-deviation_mag'], 'png')
%% Mean Vorticity - NOT vorticity of the mean velocity
hFig = init_figure([]);
contourf(x, y, mean_wz);
colormap(cmap_bipolar)
colorbar;
axis square
colorbar;
caxis([-10 10])
title('mean vorticity (/s)')
xlabel('')
ylabel('')
saveas(hFig, [dir_figures filesep 'mean_vorticity_z'], 'png')
% %% SLICE mean velocity U mag
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), mean_Umag(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), mean_Umag(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('mean vorticity (/s)')
% xlabel('distance along slice')
% ylabel('mean speed (pixels / second)')
%
% saveas(hFig, [dir_figures filesep 'mean_slice_velocity_mag'], 'png')
%
% %% SLICE mean velocity U
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), mean_u(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), mean_u(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('mean crossflow velocity')
% xlabel('distance along slice')
% ylabel('mean speed (pixels / second)')
%
% saveas(hFig, [dir_figures filesep 'mean_slice_velocity_u'], 'png')
%
% %% SLICE mean velocity V
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
%
% plot(1:size(x,1), mean_v(centerline_y,:), '-r');
% hold on;
% plot(1:size(y,2), mean_v(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('mean streamwise velocity')
% xlabel('distance along slice')
% ylabel('mean speed (pixels / second)')
%
% saveas(hFig, [dir_figures filesep 'mean_slice_velocity_v'], 'png')
%
%
% %% SLICE mean vorticity
% hFig = init_figure([]);
%
% centerline_x = floor( size(mean_wz,1)/2 );
% centerline_y = floor( size(mean_wz,2)/2 );
%
% plot(1:size(mean_wz,1), mean_wz(centerline_y,:), '-r');
% hold on;
% plot(1:size(mean_wz,2), mean_wz(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('mean vorticity')
% xlabel('distance along slice')
% ylabel('mean vorticity (/s)')
%
% saveas(hFig, [dir_figures filesep 'mean_slice_vorticity'], 'png')
%% Turbulence Intensity
hFig = init_figure([]);
TI = 100 * std_mag ./ mean_Umag;
% TI = 100 * (Umag - mean_Umag)./mean_Umag);
% TI = 100 * (sqrt(uP^2 + vP^2)) ./ mean_Umag);
contourf(x, y, TI);
colormap(cmap_LinLHot)
colorbar;
title('Turbulence Intensity (%)')
xlabel('')
ylabel('')
axis square
colorbar;
caxis([1 40])
saveas(hFig, [dir_figures filesep 'turbulence-intensity'], 'png')
%% plot FLUCTUATING variables
parfor n = 1:numel(fnames_fluct)
% load the .mat file of fluctuating, filtered and transformed data
FLUCT = load([dir_case filesep 'vectors' filesep 'fluctuating' filesep fnames_fluct{n}]);
uP = FLUCT.uP;
vP = FLUCT.vP;
wzP = FLUCT.wzP;
%% fluctuating velocity magnitude
hFig = init_figure([]);
UmagP = sqrt(uP.^2 + vP.^2);
contourf(x, y, UmagP);
colormap(cmap_LinLHot)
colorbar;
title(['fluctuating velocity magnitude ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis([0 5000])
saveas(hFig, [dir_figures filesep 'fluctuating_velocity_mag__' sprintf('%5.5d',n)], 'png')
%% fluctuating velocity U
hFig = init_figure([]);
contourf(x, y, uP);
colormap(cmap_bipolar)
colorbar;
title(['fluctuating crossflow velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis(clims_u)
saveas(hFig, [dir_figures filesep 'fluctuating_velocity_u__' sprintf('%5.5d',n)], 'png')
%% fluctuating velocity V
hFig = init_figure([]);
contourf(x, y, vP);
colormap(cmap_LinLHot)
colorbar;
title(['fluctuating streamwise velocity ' units_speed])
xlabel('')
ylabel('')
axis square
colorbar;
caxis([0 200])
saveas(hFig, [dir_figures filesep 'fluctuating_velocity_v__' sprintf('%5.5d',n)], 'png')
%% fluctuating Vorticity
hFig = init_figure([]);
contourf(x, y, wzP);
colormap(cmap_bipolar)
colorbar;
axis square
colorbar;
caxis([-5 5])
title('fluctuating Vorticity (/s)')
xlabel('')
ylabel('')
saveas(hFig, [dir_figures filesep 'fluctuating_vorticity_z__' sprintf('%5.5d',n)], 'png')
% %% SLICE fluctuating velocity U mag
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), UmagP(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), UmagP(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('fluctuating velocity magnitude')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([0 5000]);
%
% saveas(hFig, [dir_figures filesep 'slice_fluctuating_velocity_mag__' sprintf('%5.5d',n)], 'png')
%
% %% SLICE fluctuating velocity U
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), uP(centerline_y,:), '-r');
% hold on
% plot(1:size(y,2), uP(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('fluctuating crossflow velocity')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([-3000 3000]);
%
% saveas(hFig, [dir_figures filesep 'slice_fluctuating_velocity_u__' sprintf('%5.5d',n)], 'png')
%
%
% %% SLICE fluctuating velocity V
% hFig = init_figure([]);
%
% centerline_x = floor( size(x,1)/2 );
% centerline_y = floor( size(x,2)/2 );
%
% plot(1:size(x,1), vP(centerline_y,:), '-r');
% hold on;
% plot(1:size(y,2), vP(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('fluctuating streamwise velocity')
% xlabel('distance along slice')
% ylabel('speed (pixels / second)')
% ylim([-3000 3000]);
%
% saveas(hFig, [dir_figures filesep 'slice_fluctuating_velocity_v__' sprintf('%5.5d',n)], 'png')
%
%
% %% SLICE fluctuating vorticity
% hFig = init_figure([]);
%
% centerline_x = floor( size(wzP,1)/2 );
% centerline_y = floor( size(wzP,2)/2 );
%
% plot(1:size(wzP,1), wzP(centerline_y,:), '-r');
% hold on;
% plot(1:size(wzP,2), wzP(:,centerline_x), '--b');
%
% hLeg = legend('slice crossflow','slice streamwise');
% set(hLeg, 'color','none');
%
% grid on
% title('fluctuating vorticity')
% xlabel('distance along slice')
% ylabel('vorticity (/s)')
% ylim([-200 200]);
%
% saveas(hFig, [dir_figures filesep 'slice_fluctuating_vorticity_z__ ' sprintf('%5.5d',n)], 'png')
%% fluctuating TKE
hFig = init_figure([]);
TKE = 0.5 * (uP.^2 + vP.^2);
contourf(x, y, TKE);
colormap(cmap_LinLHot)
colorbar;
title('')
xlabel('')
ylabel('')
ylabel(cbar, ['turbulent kinetic energy ' units_speed])
axis square
colorbar;
% caxis([0 500])
%
saveas(hFig, [dir_figures filesep 'TKE__' sprintf('%5.5d',n)], 'png')
%% cleanup (otherwise Matlab may give memory errors after creatting too many figure handles)
close all;
fclose all;
end
%% crop white space from all figure
crop(dir_figures);
end % function