1 |
function model_addinMITprof(ncfile,model,varargin) |
2 |
% function model_addinMITprof(ncfile,model) |
3 |
% add hydrographic profiles from a model interpolated on profile |
4 |
% positions available in a MITprof netcdf file. |
5 |
% |
6 |
% fileIn: path (absolute or relative) to MITprof netcdf file |
7 |
% model is a string used to select the model to be loaded |
8 |
% 'OCCA' : ECCOv4 grid + OCCA atlas |
9 |
% 'SOSE59' : SOSE59 grid + atlas |
10 |
|
11 |
% process file name |
12 |
[pathstr, name, ext] = fileparts(ncfile); |
13 |
if isempty(pathstr) | strcmp(pathstr,'.'), pathstr=pwd; end |
14 |
if isempty(ext) | ~strcmp(ext,'.nc'), ext='.nc'; end |
15 |
ncfile=[pathstr '/' name ext]; |
16 |
|
17 |
% load profiles |
18 |
M=MITprof_load(ncfile); |
19 |
|
20 |
% interpolate model |
21 |
M=model_interp(M,model); |
22 |
|
23 |
% add fields |
24 |
fillval=double(-9999); |
25 |
T=getfield(M,['prof_T_' model])'; T(isnan(T))=fillval; |
26 |
MITprof_addVar(ncfile,['prof_T_' model],'double',{'iDEPTH','iPROF'},T); |
27 |
S=getfield(M,['prof_S_' model])'; S(isnan(S))=fillval; |
28 |
MITprof_addVar(ncfile,['prof_S_' model],'double',{'iDEPTH','iPROF'},S); |
29 |
|
30 |
% add attributes |
31 |
nc=ncopen(ncfile,'write'); |
32 |
ncaddAtt(nc,['prof_T_' model],'long_name',['pot. temp. model ' model]); |
33 |
ncaddAtt(nc,['prof_T_' model],'units','degree C'); |
34 |
ncaddAtt(nc,['prof_T_' model],'missing_value',fillval); |
35 |
ncaddAtt(nc,['prof_T_' model],'_FillValue',fillval); |
36 |
ncaddAtt(nc,['prof_S_' model],'long_name',['salinity model ' model]); |
37 |
ncaddAtt(nc,['prof_S_' model],'units','psu'); |
38 |
ncaddAtt(nc,['prof_S_' model],'missing_value',fillval); |
39 |
ncaddAtt(nc,['prof_S_' model],'_FillValue',fillval); |
40 |
ncclose(nc); |