specifying a stride length in ncread
Afficher commentaires plus anciens
I have a big 1.5 GB .nc file. Data loading is the slowest part of my processing, but I'm lucky that it will be sufficient to load only every Nth data point. Loading the whole file takes about 0.14 seconds:
tic
z = ncread('myfile.nc','z');
toc
Elapsed time is 0.142669 seconds.
which is about the same amount of time it takes when I specify that which indices to load:
tic
z = ncread('myfile.nc','z',[1 1],[Inf Inf],[1 1]);
toc
Elapsed time is 0.156108 seconds.
And so it should be faster if I specify a "stride" of more than 1. But it actually takes much more time to load every 2nd datapoint:
tic
z = ncread('myfile.nc','z',[1 1],[Inf Inf],[2 2]);
toc
Elapsed time is 4.992349 seconds.
Increasing the stride length beyond 2 seems to bring data loading time back down, but I have to use a stride length of 8 or more to get any benefit at all. What gives? Any ideas for fixes?

4 commentaires
KSSV
le 4 Oct 2016
Why don't you load whole 'z' and then pick what you want?
Chad Greene
le 4 Oct 2016
Modifié(e) : Chad Greene
le 4 Oct 2016
KSSV
le 5 Oct 2016
Have you tried the same with netcdf.getVar?
Chad Greene
le 5 Oct 2016
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur NetCDF Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!