필터 지우기
필터 지우기

Error sending data to .xlsx (NetCDF)

조회 수: 1 (최근 30일)
Augusto Gabriel da Costa Pereira
Augusto Gabriel da Costa Pereira 2022년 12월 21일
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

채택된 답변

Mathieu NOE
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 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