forked from jfaghm/OceanEddies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan_multi.m
executable file
·35 lines (34 loc) · 1.53 KB
/
scan_multi.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
function scan_multi( ssh, lat, lon, dates, cyc, scan_type, areamap, destdir, varargin )
%SCAN_MULTI Scan all of the ssh data passed in (will function correctly if data
%passed in is a subset)
% ssh: ssh cube with nans for land
% lat: A 1D array of double's that gives the latitude for a given index in ssh data , should be equal to size(ssh, 1)
% lon: A 1D array of double's that gives the longitude for a given index in ssh data, should be equal to size(ssh, 2)
% dates: A 1D array of the dates of ssh data, length should be equal to size(ssh, 3)
% cyc: 'anticyc' or 'cyclonic'
% scan_type: 'v1', 'v2', 'hybrid'
% v1: Will run top-down scanning
% v2: Will run bottom-up scanning from the minima of the field
% hybrid: Will run v2 and v1 scanning and will take the union of the
% two sets where, for common features, v2 bodies will be used
% destdir: destination directory to save eddies
% Optional parameter
if ~strcmp(destdir(end), filesep())
destdir = [destdir filesep()];
end
if exist(destdir, 'dir') ~= 7
mkdir(destdir);
end
parfor i = 1:length(dates)
if exist([destdir cyc '_' num2str(dates(i)) '.mat'], 'file')
continue;
end
fprintf('starting iteration %d\n', i);
eddies = scan_single(ssh(:,:,i), lat, lon, dates(i), cyc, scan_type, areamap, varargin{:});
save_data([destdir cyc '_' num2str(dates(i))], eddies);
fprintf('finished iteration %d\n', i);
end
end
function save_data(path, eddies)
save(path, 'eddies', '-v7');
end