Error combining netcdf files

5 次查看(过去 30 天)
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.

请先登录,再进行评论。

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by