Clear Filters
Clear Filters

Merge netCDF files to have sequence of daily precipitation of several weather stations

1 view (last 30 days)
Please, I posted this question long time ago and I didn't get any help. Please, I appreciate any help and suggestions! The question posted here: https://www.mathworks.com/matlabcentral/answers/343582-merge-netcdf-files-to-have-sequence-of-daily-precipitation-of-several-weather-stations
Thanks, Majid
  6 Comments
KSSV
KSSV on 12 Jul 2017
Dear friend....you need to have a look into nc files....that code is trying to read date, time, precipitation from the nc file. Your nc files doesn't have that information....
Majid Mohamod
Majid Mohamod on 12 Jul 2017
Edited: Majid Mohamod on 12 Jul 2017
I tried to enlarge the study area and now I am getting results " the script works".
You had helped me someday to export the array as excel worksheets as shown below:
files = dir('*.nc') ;
nfiles = length(files) ;
P = cell(nfiles,1) ; % precipitation of all files
date = cell(nfiles,2) ;
time = cell(nfiles,2) ;
for i = 1:nfiles
%%Read dat
date{i,1} = ncreadatt(files(i).name,'/','HDF5_GLOBAL.BeginDate') ;
date{i,2} = ncreadatt(files(i).name,'/','HDF5_GLOBAL.EndDate') ;
%%Read time
time{i,1} = ncreadatt(files(i).name,'/','HDF5_GLOBAL.BeginTime') ;
time{i,2} = ncreadatt(files(i).name,'/','HDF5_GLOBAL.EndTime') ;
%%REad precipitation
P{i} = ncread(files(i).name,'precipitation') ;
end
myfile = 'myfile.xlsx' ;
for i = 1:nfiles
xlswrite(myfile,P{i},i)
end
Could you change the part of exporting from worksheet to excel file individually. Which mean each nc file will be excel file instead excel sheet?
I appreciate it man!
Majid

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!