1 |
function aviso_addinMITprof(ncfile) |
2 |
% function aviso_addinMITprof(ncfile) |
3 |
% add MADT (Maps of Absolute Dynamic Topography) interpolated on profile |
4 |
% positions available in a MITprof netcdf file. |
5 |
% Use OpenDap, through the loaddap function. |
6 |
% |
7 |
% fileIn: path (absolute or relative) to MITprof netcdf file |
8 |
% model is a string used to select the model to be loaded |
9 |
% 'OCCA' : ECCOv4 grid + OCCA atlas |
10 |
% 'SOSE59' : SOSE59 grid + atlas |
11 |
|
12 |
% process file name |
13 |
[pathstr, name, ext] = fileparts(ncfile); |
14 |
if isempty(pathstr) | strcmp(pathstr,'.'), pathstr=pwd; end |
15 |
if isempty(ext) | ~strcmp(ext,'.nc'), ext='.nc'; end |
16 |
ncfile=[pathstr '/' name ext]; |
17 |
|
18 |
if isempty(which('loaddap')), |
19 |
error('loaddap toolbox must be installed'); |
20 |
end |
21 |
|
22 |
% load profiles |
23 |
M=MITprof_load(ncfile,{'prof_date','prof_lat','prof_lon'}); |
24 |
|
25 |
% load data |
26 |
loc=[]; |
27 |
loc.lat=M.prof_lat; |
28 |
loc.lon=M.prof_lon; |
29 |
loc.time=M.prof_date; |
30 |
grid_aviso=aviso_get_grid; |
31 |
madt=aviso_get_madt(loc,grid_aviso); |
32 |
|
33 |
% add fields |
34 |
fillval=double(-9999); |
35 |
madt(isnan(madt))=fillval; |
36 |
MITprof_addVar(ncfile,['prof_madt_aviso'],'double',{'iPROF'},madt); |
37 |
|
38 |
% add attributes |
39 |
nc=ncopen(ncfile,'write'); |
40 |
ncaddAtt(nc,'prof_madt_aviso','long_name',['MADT AVISO']); |
41 |
ncaddAtt(nc,'prof_madt_aviso','units','m'); |
42 |
ncaddAtt(nc,'prof_madt_aviso','missing_value',fillval); |
43 |
ncaddAtt(nc,'prof_madt_aviso','_FillValue',fillval); |
44 |
ncclose(nc); |