Error sending data to .xlsx (NetCDF)
2 次查看(过去 30 天)
显示 更早的评论
Augusto Gabriel da Costa Pereira
2022-12-21
评论: Augusto Gabriel da Costa Pereira
2022-12-23
I have the CHIRPS data plus these scripts and at the time the data is sent to the .xlsx it has errors in the dates and the precipitation data is blank.
the biggest problem is the years, months and days
Does anyone have an idea to solve?
download link:
https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_daily/netcdf/p25/
the functions used are attached (get_and_save_ncf_data.m license.txt testfun.m natsortfiles_test.m natsort.m natsortfiles.m natsortfiles_doc.m)
%% Long and Lat
LG=[-48.375]; % longitude
LT=[-1.125]; % latitude
%% main code
fileDir = pwd; % current directory (or specify which one is the working directory)
S = dir(fullfile(fileDir,'*.nc')); % get list of nc files in directory
S = natsortfiles(S); % sort file names into natural order , see :
%(https://fr.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort)
for k = 1:length(S)
filename = S(k).name % to actually show filenames are sorted (see command window)
sheet = 1; % for excel file output, either on first sheet or increment sheet number if needed
filename_out = [filename(1:length(filename)-3) '.xlsx']; % replace nc extension with xlsx (or whatever you want)
get_and_save_ncf_data(fullfile(fileDir, filename),LG,LT,fullfile(fileDir, filename_out),sheet);
end
0 个评论
采纳的回答
Mathieu NOE
2022-12-21
hello Augusto
just correct this line in your function "get_and_save_ncf_data.m":
those nc files are daily data (time increment = day not hour) and there are referred to 1980 not 1900
% AA=time/24+datenum('1900-01-01 0:0:0'); % time in hours
AA=time+datenum('1980-01-01 0:0:0'); % time in days, reference is 1980 not 1900
更多回答(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!