-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsaveWISdata.m
128 lines (103 loc) · 3.47 KB
/
saveWISdata.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
function saveWISdata(inputFolder_WIS,outputFolder_WIS)
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isdir(inputFolder_WIS)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', inputFolder_WIS);
uiwait(warndlg(errorMessage));
return;
end
if ~isdir(outputFolder_WIS)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', outputFolder_WIS);
uiwait(warndlg(errorMessage));
return;
end
% Get a list of all files in the folder with the desired file name pattern.
infilePattern = fullfile(inputFolder_WIS, '*.mat'); % Change to whatever pattern you need.
input_files = dir(infilePattern);
for k = 1 : length(input_files)
baseFileName = input_files(k).name;
fullFileName = fullfile(inputFolder_WIS, baseFileName);
%fprintf(1, 'Now reading %s\n', fullFileName);
load(fullFileName);
[pathstr,filename,ext] = fileparts(fullFileName)
savename = [outputFolder_WIS filename '_rose.mat'];
%loadname = ['C:/Andrew/WIS/WISDATA/WISn' num2str(stations(k)) '_80_99']
%load(loadname);
%load NDBC_44018_02_12(mod)
%savename = ['climdata/rose' num2str(stations(k)) '_80_99_' 'th' num2str(Shores(k)) '_pk']
shornt = 0; % degrees (clockwise = positive) difference between location and array
g= 9.81; % That's gravity, holmes
pi = 3.1415; % ref. Archimedes (-232)
degtorad = pi/180; % convert radians to degrees
binsize = 15; % um, size of the bins
binnumber = 360/binsize
binarray = binsize/2:binsize:360-binsize/2;
EnergyFluxIn = zeros(1,360/binsize);
ldata = length(data);
AngleInV = zeros(ldata,1);
HInV = zeros(ldata,1);
TIn = zeros(ldata,1); % ref coastal list
% where loop will start
% zero some stuff
ASTSum = 0;
RateSum = 0;
ASTSumNB = 0;
RateSumNB = 0;
ASTNB = zeros(1,360/binsize);
RateContNB = zeros(1,360/binsize);
EnergyFluxNB = zeros(1,360/binsize);
AST = zeros(1,360/binsize);
RateCont = zeros(1,360/binsize);
EnergyFlux = zeros(1,360/binsize);
HighAST = 0;
HighASTSum = 0;
HighRateAsym = 0;
HighRateSum = 0;
LowAST = 0;
LowASTSum = 0;
LowRateAsym = 0;
LowRateSum = 0;
Bad = []; % bad data points
NotRef = [];
for j = 1:ldata
HIn = data(j,1);
T = data(j,3);
WaveAngleIn = data(j,2);
% Save in data for comparison the backrefracted stuff - keep oriented
% in general reference frame
AngleInV(j) = WaveAngleIn;
HInV(j) = HIn;
TIn(j) = T;
for i = 1:binnumber
if ((((i-1)*binsize) < WaveAngleIn) & (WaveAngleIn <= i * binsize))
% add up contribution to energy flux
HTscale = (HIn^(12/5)) * (T^(1/5));
EnergyFluxIn(i) = EnergyFluxIn(i) + HTscale;
end
end
if mod(j,1000) == 0
j
end
end
Bad;
NotRef;
BadData = length(Bad)
NotRefData = length(NotRef)
figure()
plot(binarray,EnergyFluxIn,'r','linewidth',1.5)
legend('Averaged','Peak')
title(filename)
xlim([0 360])
hold off
figure()
innormal = EnergyFluxIn/sum(EnergyFluxIn);
polargeo([binarray binarray(1)]*degtorad, [innormal innormal(1)],'b')
title(filename)
h= findobj('Color','r');
set(h,'MarkerFaceColor','r')
h= findobj('Color','g');
set(h,'LineWidth',2)
hold off
save(join(savename,''))
%savename
end
end