specifying a stride length in ncread
Ältere Kommentare anzeigen
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 Kommentare
KSSV
am 4 Okt. 2016
Why don't you load whole 'z' and then pick what you want?
Chad Greene
am 4 Okt. 2016
Bearbeitet: Chad Greene
am 4 Okt. 2016
KSSV
am 5 Okt. 2016
Have you tried the same with netcdf.getVar?
Chad Greene
am 5 Okt. 2016
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu NetCDF Files finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!