specifying a stride length in ncread
古いコメントを表示
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 件のコメント
KSSV
2016 年 10 月 4 日
Why don't you load whole 'z' and then pick what you want?
Chad Greene
2016 年 10 月 4 日
編集済み: Chad Greene
2016 年 10 月 4 日
KSSV
2016 年 10 月 5 日
Have you tried the same with netcdf.getVar?
Chad Greene
2016 年 10 月 5 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で NetCDF Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!