-
Notifications
You must be signed in to change notification settings - Fork 1
/
SandyErrorCorrection.m
28 lines (21 loc) · 1.24 KB
/
SandyErrorCorrection.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
%Run this script after running "WarpSandy" to build the
%sandyWarpedModelCompleteData matrix, which contains latitude and longitude
%in the first two columns, and the corrected max water heights for
%simulations alt01-alt09 (alt06 being historical) in the remaining columns
warpIdx = 6;
errorFunc = reshape(sandyWarp(6,:,:),resY,resX);
numSims = 9;
numModelPoints = size(sandyModelCompleteData,1);
sandyWarpedModelCompleteData = sandyModelCompleteData;
rad = 0.02 * warpIdx;
warpInterpolant = scatteredInterpolant(x(~isnan(errorFunc)), y(~isnan(errorFunc)), errorFunc(~isnan(errorFunc)));
distInterpolant = griddedInterpolant(x', y', distances');
modelPointsDist = distInterpolant(sandyModelCompleteData(:,1), sandyModelCompleteData(:,2));
modelWarp = warpInterpolant(sandyModelCompleteData(:,1), sandyModelCompleteData(:,2));
modelPointsToWarp = find(modelPointsDist < rad);
modelBelowWater = sandyModelCompleteData;
warpedModelBelowWater = sandyModelCompleteData;
for sim = 1:numSims
completeDataCol = sim+3;
sandyWarpedModelCompleteData(modelPointsToWarp,completeDataCol) = sandyModelCompleteData(modelPointsToWarp,completeDataCol) - modelWarp(modelPointsToWarp);
end