How to shift the dimensions of a variable in a NetCDF file
3 ビュー (過去 30 日間)
古いコメントを表示
I have a NetCDF(example file) file which have different variables inside it. Have to choose a particular variable from the file(Spectral_AOD_Scaling_Coeff) which has three dimensions say 4032 x 496 x 3. Iwant to rewrite the variable by shifting the third dimension to first and first in position of third, for my example 3 x 496 x 4032 to 4032 x 496 x 3 and save the variable to same file. I have a number of such NetCDF file to do this same work so looking for a code which takes each file from a folder, do the stuff. any help is appreciated.
Thanks in advance
0 件のコメント
採用された回答
Walter Roberson
2019 年 3 月 23 日
I am not positive, but I think you might have to delete the variable out of the file before you can write in with the new ordering. But that is a bit of a problem, because netcdf does not have an explicit deletion interface.
It might be easier to copy all the variables to a new file, changing the one that is of interest to you.
The reorganization of the variable is easy at the MATLAB level:
permute(TheArray, [3 2 1])
But be careful, because netcdf are normally written in row-major order, whereas MATLAB works in column-major order. That is, in netcdf files, A(1,1) and A(1,2) are adjacent in the file, whereis in MATLAB, A(1,1) and A(2,1) are adjacent in memory. You should work out what order of elements you want to create in the file.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で NetCDF についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!