필터 지우기
필터 지우기

Error combining netcdf files

조회 수: 5 (최근 30일)
Augusto Gabriel da Costa Pereira
편집: Walter Roberson 2023년 1월 27일
I'm having a problem when processing this netcdf data
When I run the commands, at the end the following message appears:,
Unrecognized field name "all".
Error in FUN_nc_merge (line 223)
MV.all = [ MV.all ; tem(:) ];
The function I used is attached here with the name FUN_nc_merge.m and can be obtained through this link https://github.com/HappySpring/Easy_NetCDF
The script I used is just below and the link with google drive is the NetCDF files I used https://drive.google.com/drive/folders/1yts62Bbd5P1N_O3we3R2iQi0PgYbkJNT?usp=share_link
% input_dir: path for the folder containing the files
input_dir = '/home/augusto/Documentos/Dados_Mensais_CHIRPS';
% filelist
filelist = dir(fullfile(input_dir,'Merge_Demo*.nc'));
% output filename
output_fn = 'Merged_Output.nc';
% name of the demension to be merged.
merge_dim_name = 'time';
% compatibility_mode:
% compatibility_mode = 1: write netCDF in 'CLOBBER'; Compression would be disabled.
% compatibility_mode = 0: write netCDF in 'NETCDF4'.
compatibility_mode = 0;
strvcat( filelist(:).name )
cd /home/augusto/Downloads/Easy_NetCDF-main
FUN_nc_merge( input_dir, filelist, output_fn, merge_dim_name, compatibility_mode )

채택된 답변

Augusto Gabriel da Costa Pereira
% input_dir: path for the folder containing the files
input_dir = './Data/';
% filelist
filelist = dir(fullfile(input_dir,'data_chirps*.nc'));
% output filename
output_fn = 'Merged_Output.nc';
% name of the demension to be merged.
merge_dim_name = 'time';
% compatibility_mode:
% compatibility_mode = 1: write netCDF in 'CLOBBER'; Compression would be disabled.
% compatibility_mode = 0: write netCDF in 'NETCDF4'.
compatibility_mode = 0;
strvcat( filelist(:).name )
FUN_nc_merge( input_dir, filelist, output_fn, merge_dim_name, compatibility_mode )

추가 답변 (2개)

L Chi
L Chi 2023년 1월 27일
I guess I figured out what happened. I happened to introduce a bug in a recent commit on Dec 14, 2022, which does not define the variable MV.all correclty if is_overlap_allowed is false. I found it a few days later and fix it in a following commit (480d64d) on Dec 28, 2022. If you happened to download the latest toolbox between Dec 14 and Dec 28, this is probably the case. Please download the latest toolbox from github and try it again. It should work, you're welcomed to email me/open an issue on github/replay this post if you still have problems in using the toolbox.
  댓글 수: 1
L Chi
L Chi 2023년 1월 27일
편집: Walter Roberson 2023년 1월 27일
By the way, I always try to make sure the releases ( https://github.com/HappySpring/Easy_NetCDF/releases ) are free of bugs. The latest release currently is version 1.12 released on July 27, 2022. I add experimental features in commits after the latest release, however, this may also include bugs. My suggestion would be that the latest release would always be a better choice unless you need new features introduced after it.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2023년 1월 14일
You have the code structure
if is_overlap_allowed
%stuff here
MV.all = cell2mat( MV.val(:) );
else
for ii = 1:length( filepath_list )
fprintf('Checking: %s\n', filepath_list{ii} );
tem = FUN_nc_varget( filepath_list{ii}, merge_dim_var_name );
MV.all = [ MV.all ; tem(:) ];
%more stuff
Notice that MV.all is not assigned to before the if and inside the if it is assigned to only if is_overlap_allowed; in the case that is_overlap_allowed is false, it is not assigned to before it is used inside the for ii loop.
  댓글 수: 11
Walter Roberson
Walter Roberson 2023년 1월 17일
Can we assume that the latitude and longitude will be exactly the same for all three files?
Augusto Gabriel da Costa Pereira
yes, exactly that, latitude and longitude will be the same.
I think now you understand my question.
I've been trying to make this script for a while but I haven't been successful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by