Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thopri
BoBEAS
Commits
ed6b5111
Commit
ed6b5111
authored
6 years ago
by
ashbre
Browse files
Options
Download
Email Patches
Plain Diff
Adding matlab function for IC generation
parent
2ac80057
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
0 deletions
+184
-0
SCRIPTS/nemo_IC_salinity.m
SCRIPTS/nemo_IC_salinity.m
+66
-0
SCRIPTS/nemo_IC_temperature.m
SCRIPTS/nemo_IC_temperature.m
+64
-0
SCRIPTS/smooth2.m
SCRIPTS/smooth2.m
+54
-0
No files found.
SCRIPTS/nemo_IC_salinity.m
0 → 100644
View file @
ed6b5111
clear
all
clc
addpath
(
'/projectsa/ETI/Tracer_work/Matlab_progs'
)
fname
=
'initcd_vosaline.nc'
;
fname_data
=
'Sal_16_0000.nc'
;
z_data
=
'domain_cfg.nc'
;
Sin
=
ncread
(
fname_data
,
'so'
);
xin
=
double
(
ncread
(
fname_data
,
'longitude'
));
yin
=
double
(
ncread
(
fname_data
,
'latitude'
));
zin
=
double
(
ncread
(
fname_data
,
'depth'
));
Sin
=
permute
(
Sin
,[
2
1
3
]);
Sout
=
double
(
ncread
(
fname
,
'vosaline'
));
xout
=
double
(
ncread
(
fname
,
'x'
));
yout
=
double
(
ncread
(
fname
,
'y'
));
dzout
=
ncread
(
z_data
,
'e3t_0'
);
xout
=
repmat
(
xout
,
1
,
1
,
size
(
Sout
,
3
));
yout
=
repmat
(
yout
,
1
,
1
,
size
(
Sout
,
3
));
z
=
zeros
(
size
(
Sout
,
1
),
size
(
Sout
,
2
),
size
(
Sout
,
3
));
for
i
=
1
:
size
(
Sout
,
3
)
if
i
==
1
z
(:,:,
i
)
=
dzout
(:,:,
i
);
else
z
(:,:,
i
)
=
z
(:,:,
i
-
1
)
+
dzout
(:,:,
i
);
end
end
zin
(
1
)
=
0
;
zin
(
end
)
=
max
(
z
(:))
+
1
;
%
% parfor i=1:size(Sin,3)
% i
% Sin(:,:,i)=smooth2(Sin(:,:,i),100,100);
%
% end
Sinterp
=
interp3
(
xin
,
yin
,
zin
,
Sin
,
xout
,
yout
,
z
);
ncid
=
netcdf
.
open
(
fname
,
'WRITE'
);
varid
=
netcdf
.
inqVarID
(
ncid
,
'vosaline'
);
netcdf
.
putVar
(
ncid
,
varid
,
Sinterp
)
This diff is collapsed.
Click to expand it.
SCRIPTS/nemo_IC_temperature.m
0 → 100644
View file @
ed6b5111
clear
all
clc
fname
=
'initcd_votemper.nc'
;
fname_data
=
'Temp_16_0000.nc'
;
z_data
=
'domain_cfg.nc'
;
Tin
=
ncread
(
fname_data
,
'thetao'
);
xin
=
double
(
ncread
(
fname_data
,
'longitude'
));
yin
=
double
(
ncread
(
fname_data
,
'latitude'
));
zin
=
double
(
ncread
(
fname_data
,
'depth'
));
Tin
=
permute
(
Tin
,[
2
1
3
]);
Tout
=
double
(
ncread
(
fname
,
'votemper'
));
xout
=
double
(
ncread
(
fname
,
'x'
));
yout
=
double
(
ncread
(
fname
,
'y'
));
dzout
=
ncread
(
z_data
,
'e3t_0'
);
xout
=
repmat
(
xout
,
1
,
1
,
size
(
Tout
,
3
));
yout
=
repmat
(
yout
,
1
,
1
,
size
(
Tout
,
3
));
z
=
zeros
(
size
(
Tout
,
1
),
size
(
Tout
,
2
),
size
(
Tout
,
3
));
for
i
=
1
:
size
(
Tout
,
3
)
if
i
==
1
z
(:,:,
i
)
=
dzout
(:,:,
i
);
else
z
(:,:,
i
)
=
z
(:,:,
i
-
1
)
+
dzout
(:,:,
i
);
end
end
zin
(
1
)
=
0
;
zin
(
end
)
=
max
(
z
(:))
+
1
;
% parfor i=1:size(Tin,3)
% i
% Tin(:,:,i)=smooth2(Tin(:,:,i),100,100);
%
% end
Tinterp
=
interp3
(
xin
,
yin
,
zin
,
Tin
,
xout
,
yout
,
z
);
ncid
=
netcdf
.
open
(
fname
,
'WRITE'
);
varid
=
netcdf
.
inqVarID
(
ncid
,
'votemper'
);
netcdf
.
putVar
(
ncid
,
varid
,
Tinterp
)
This diff is collapsed.
Click to expand it.
SCRIPTS/smooth2.m
0 → 100644
View file @
ed6b5111
function
[
mat_new
]
=
smooth2
(
mat_old
,
stencilx
,
stencily
)
%stencil = 2;
% check matrix in each direction
% mat(x,y)
%mat_new=nan(size(mat_old,1),size(mat_old,2));
mat_new
=
mat_old
;
for
i
=
1
:
size
(
mat_old
,
1
)
for
j
=
1
:
size
(
mat_old
,
2
)
if
isnan
(
mat_old
(
i
,
j
))
type1
=
(
i
-
1
);
type2
=
abs
(
i
-
size
(
mat_old
,
1
));
type3
=
(
j
-
1
);
type4
=
abs
(
j
-
size
(
mat_old
,
2
));
%adj_stencil=min([stencil type1 type2 type3 type4]);
x_min
=
(
i
-
min
([
stencilx
type1
]));
x_max
=
(
i
+
min
([
stencilx
type2
]));
y_min
=
(
j
-
min
([
stencily
type3
]));
y_max
=
(
j
+
min
([
stencily
type4
]));
sub_mat
=
mat_old
(
x_min
:
x_max
,
y_min
:
y_max
);
mat_new
(
i
,
j
)
=
nanmean
(
sub_mat
(:));
%end
% if isnan(mat_old(i,j))
% mat_new(i,j)=NaN;
% end
end
end
end
end
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment