Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

  • Get full lat,lon vectors: 1D vectors are small, so we can get all data
    Code Block
    nc_dump(ncfile)
       G.lon    = nc_varget(ncfile,'lon' ); % 1D
       G.lat    = nc_varget(ncfile,'lat' ); % 1D
    
  • Find the subset-indices within the bounding box
    Code Block
    ilon     = find(G.lon > boundingbox.lon(1) & G.lon < boundingbox.lon(2));
       ilat     = find(G.lat > boundingbox.lat(1) & G.lat < boundingbox.lat(2));
    
    Wiki Markup
  • ranslate subset-indices to netCDF argument: \ [start,count,stride\]
    Code Block
    stride   = [1 1]; % additionally specify a stride when the subset is still too big
       start    = [min(ilat)-1 min(ilon)-1]; % subtract one as netCDF is 0-based, whereas matlab is 1-bases
       count    = ceil([length(ilat) length(ilon)]./stride); % use ceil to cover at least bounding box area
    
  • Request data subset
    Code Block
    G.lat    = nc_varget(ncfile,'lat' ,start(1),count(1),stride(1)); % 1D
       G.lon    = nc_varget(ncfile,'lon' ,start(2),count(2),stride(2)); % 1D
       G.topo   = nc_varget(ncfile,'topo',start(:),count(:),stride(:)); % 2D
       G.title  = nc_attget(ncfile,nc_global,'title')
    
  • Plot data subset
    Code Block
    figure(i)
       pcolorcorcen(G.lon,G.lat,G.topo)
       hold on
       plot(L.lon,L.lat,'k')
       axis([boundingbox.lon boundingbox.lat])
       tickmap('ll','texttype','text','dellast',1)
       axislat % sets aspect ratio
       grid on
       clim ([-50 150])
       title(mktex(G.title))
       colorbarwithvtext('z [m]')
       print2screensize(mkvar(G.title))
    

...