/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/aviso_addinMITprof.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/aviso_addinMITprof.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Wed Apr 20 20:37:22 2011 UTC (14 years, 2 months ago) by roquet
Branch: MAIN
Changes since 1.1: +44 -19 lines
- bug fix for longitudes (must be between 0 and 360 in opendap grid)
- create the variable prof_madt_aviso first, then fill it with extracted values.

1 roquet 1.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 roquet 1.2 global MITprof_verbose; if isempty(MITprof_verbose), MITprof_verbose=0; end
13    
14 roquet 1.1 % process file name
15     [pathstr, name, ext] = fileparts(ncfile);
16     if isempty(pathstr) | strcmp(pathstr,'.'), pathstr=pwd; end
17     if isempty(ext) | ~strcmp(ext,'.nc'), ext='.nc'; end
18     ncfile=[pathstr '/' name ext];
19    
20     if isempty(which('loaddap')),
21     error('loaddap toolbox must be installed');
22     end
23    
24     % load profiles
25 roquet 1.2 nc=ncopen(ncfile,'write');
26     vars=ncvars(nc);
27     ncclose(nc);
28     if ismember('prof_madt_aviso',vars)
29     M=MITprof_load(ncfile,{'prof_date','prof_lat','prof_lon','prof_madt_aviso'});
30     madt=M.prof_madt_aviso;
31     else
32     fillval=double(-9999);
33     nc=ncopen(ncfile,'write');
34     ncaddVar(nc,'prof_madt_aviso','double',{'iPROF'});
35     ncaddAtt(nc,'prof_madt_aviso','long_name',['MADT AVISO']);
36     ncaddAtt(nc,'prof_madt_aviso','units','m');
37     ncaddAtt(nc,'prof_madt_aviso','missing_value',fillval);
38     ncaddAtt(nc,'prof_madt_aviso','_FillValue',fillval);
39     ncclose(nc);
40     M=MITprof_load(ncfile,{'prof_date','prof_lat','prof_lon'});
41     madt=M.prof_lat*NaN;
42     end
43 roquet 1.1
44 roquet 1.2 % load and write data
45     I=find(isnan(madt));
46 roquet 1.1 loc=[];
47    
48 roquet 1.2 buffer=1000;
49     for kk=1:ceil(length(I)/buffer),
50    
51     if MITprof_verbose,
52     disp([num2str(kk) ' out of ' num2str(length(I)/buffer)]);
53     end
54    
55     % extract data
56     J=I((kk-1)*buffer+1:min([length(I),kk*buffer]));
57     loc.lat=M.prof_lat(J);
58     loc.lon=M.prof_lon(J);
59     loc.time=M.prof_date(J);
60     grid_aviso=aviso_get_grid;
61     madt_temp=aviso_get_madt(loc,grid_aviso);
62    
63     % write fields
64     madt(J)=madt_temp;
65     M.prof_madt_aviso=madt;
66     MITprof_write(ncfile,M,{'prof_madt_aviso'});
67    
68     end
69    

  ViewVC Help
Powered by ViewVC 1.1.22