-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadvelocitydata.m
48 lines (32 loc) · 1.6 KB
/
readvelocitydata.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
function v = readvelocitydata(datasource, path1, filetype)
if datasource == 1
location1 = [path1, filetype];
files = dir(location1); %will load all the nc4 files in the folder
files = struct2cell(files);
files = files(1, 1:end);
files = files';
files2 = [path1, files{1}];
%This information is specific to promice data
v.x = ncread(files2, 'x');
v.y = ncread(files2, 'y');
[v.x, v.y] = meshgrid(v.x, v.y); %these lines make
v.x = v.x'; v.y=v.y';
for ii = 1:length(files)
clear files2
files2 = [path1, files{ii}];
v.time(:,:,ii) = ncread(files2, 'time') + datenum(1990,1,1); %This may need to be changed for python
v.tbands(:,:,ii) = ncread(files2, 'time_bnds') + datenum(1990,1,1); %This may need to be changed for python
v.e_vel(:,:,ii) = ncread(files2, 'land_ice_surface_easting_velocity');
v.n_vel(:,:,ii) = ncread(files2, 'land_ice_surface_northing_velocity');
v.tot_vel(:,:,ii) = ncread(files2, 'land_ice_surface_vertical_velocity');
v.vert_vel(:,:,ii) = ncread(files2, 'land_ice_surface_vertical_velocity');
v.e_vel_std(:,:,ii) = ncread(files2, ' land_ice_surface_easting_velocity_std ');
v.n_vel_std(:,:,ii) = ncread(files2, ' land_ice_surface_northing_velocity_std ');
end
v.pixelsize = abs(v.x(1) - v.x(2)); %This makes the implicit assumption that the velocity data have 'square' pixels!
elseif datasource == 2
%
elseif datasource == 3
else
disp('The code does not understand your choice of velocity data: Abort!')
end