-
Notifications
You must be signed in to change notification settings - Fork 4
/
MxHLmodel.m
75 lines (67 loc) · 3.31 KB
/
MxHLmodel.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
%% MxHL Model
% Builds the MxHL Model, Age-Depth, and Accumulation Models to match the
% size of the Radar Image.
% Interpolate Density Model to Resolution of Radar Depth Section
AgeModel = cell(nFiles,1);
Ages = cell(nFiles,1);
DensityModel = cell(nFiles,1);
InstantVelocityModel = cell(nFiles,1);
DensityAnomalyModel = cell(nFiles,1);
AvgDensityModel = cell(nFiles,1);
StackingVelocityModel = cell(nFiles,1);
MeanDensityDeviation = cell(nFiles,1);
SurfaceDensityDeviation = cell(nFiles,1);
DepthAge = cell(nFiles,1);
AvgAccumulation = cell(nFiles,1);
MxAccumulationRate = cell(nFiles,1);
MxHLAccumulationRate = cell(nFiles,1);
ix550 = zeros(1,size(DensityModel{ii},2));
depth550 = zeros(1,size(DensityModel{ii},2));
for ii = 1:nFiles
% Resize Depth-Density Model
DensityModel{ii} = griddata(TraverseX{ii},StackDepth{ii},...
HerronLangwayDensity{ii},xStack{ii},DepthMatrix{ii},'linear');
% Fill in NaN with Nearest Extrapolation
DensityModel{ii}(1,:) = DensityModel{ii}(2,:);
% Compute Instantaneous Velocity Model
InstantVelocityModel{ii} = DryCrimVRMS(DensityModel{ii});
% Resize Depth-AvgDensity Model
AvgDensityModel{ii} = griddata(TraverseX{ii},StackDepth{ii},...
StackingDensity{ii},xStack{ii},DepthMatrix{ii},'linear');
% Fill in NaN with Nearest Extrapolation
AvgDensityModel{ii}(1,:) = AvgDensityModel{ii}(2,:);
% Compute Resized Stacking Velocities
StackingVelocityModel{ii} = DryCrimVRMS(AvgDensityModel{ii});
% Resize Depth-Age Model
AgeModel{ii} = griddata(TraverseX{ii},StackDepth{ii},...
HerronLangwayAge{ii},xStack{ii},DepthMatrix{ii},'linear');
% Fill in NaN with Zero Age
AgeModel{ii}(1,:) = 0;
% Determine Critical Depth
for kk = 1:size(DensityModel{ii},2)
ix550(kk) = find(DensityModel{ii}(:,kk)>.550,1);
depth550(kk) = DepthMatrix{ii}(ix550(kk),kk);
end
% Density Anomaly from the Mean
DensityAnomalyModel{ii} = DensityModel{ii} - mean(DensityModel{ii},2);
MeanDensityDeviation{ii} = mean(DensityAnomalyModel{ii},1);
SurfaceDensityDeviation{ii} = DensityAnomalyModel{ii}(1,:);
% Calculate Accumulation Rate from Maximum Isochrone to Surface
MaxAge = floor(min(AgeModel{ii}(end,:)));
% Ages{ii} = [1:5:MaxAge];
Ages{ii} = [5:5:20];
Isochrones = abs(str2num(Year{ii}) - Ages{ii});
for kk = 1:length(Isochrones)
[~, AgeIx] = min(abs(AgeModel{ii}-Ages{ii}(kk)));
AgeIx = sub2ind(size(DepthMatrix{ii}),AgeIx,1:length(AgeIx));
DepthAge{ii}(:,kk) = DepthMatrix{ii}(AgeIx');
AvgAccumulation{ii}(:,kk) = AvgDensityModel{ii}(AgeIx').*DepthAge{ii}(:,kk);
end
% This Calculation is Redundant Due Circularity of Methodology
MxHLAccumulationRate{ii} = AvgAccumulation{ii}(:,find(Ages{ii} == MaxAge))./MaxAge;
% MxRadar Evaluated Contemporary Accumulation Rate
% This result is Bias Corrected (Depth and Density) is Final
MxAccumulationRate{ii} = SnowWaterEqv{1,ii};% - (normSWE.*SnowWaterEqv{1,ii});
% Uncertainties Are Developed During HVA Bootstrapping
Isochrones = DepthAge;
end