-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangemask.m
58 lines (50 loc) · 1.08 KB
/
changemask.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
function[]=changemask(fname)
% change mask
% fname = 'Combined2016_10mv4_grd.nc';
d = ncread(fname,'h');
mask_r = ncread(fname,'mask_rho');
mask_u = ncread(fname,'mask_u');
mask_v = ncread(fname,'mask_v');
mask_p = ncread(fname,'mask_psi');
[ii, jj] = size(d); % 734 834
for i = 1:ii;
for j = 1:jj;
if d(i,j)>4; % 4 is my minh - CHECK THIS VALUE IN YOUR GRID!
mask_r(i,j)=1;
elseif d(i,j)==4;
mask_r(i,j)=0;
end
end
end
for i = 1:ii-1;
for j = 1:jj;
if d(i,j)>4;
mask_u(i,j)=1;
elseif d(i,j)==4;
mask_u(i,j)=0;
end
end
end
for i = 1:ii;
for j = 1:jj-1;
if d(i,j)>4;
mask_v(i,j)=1;
elseif d(i,j)==4;
mask_v(i,j)=0;
end
end
end
for i = 1:ii-1;
for j = 1:jj-1;
if d(i,j)>4;
mask_p(i,j)=1;
elseif d(i,j)==4;
mask_p(i,j)=0;
end
end
end
ncwrite(fname,'mask_rho',mask_r);
ncwrite(fname,'mask_u',mask_u);
ncwrite(fname,'mask_v',mask_v);
ncwrite(fname,'mask_psi',mask_p);
end