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!