How can I read many netcdf files with complex names by using loop in MATLAB?
조회 수: 2 (최근 30일)
이전 댓글 표시
- 3B-HHR.MS.MRG.3IMERG.20140401-S000000-E002959.0000.V03D.HDF5.nc_precipitationCal[960_969][986_992],lat[986_992],lon[960_969]
- 3B-HHR.MS.MRG.3IMERG.20140401-S003000-E005959.0030.V03D.HDF5.nc_precipitationCal[960_969][986_992],lat[986_992],lon[960_969]
- 3B-HHR.MS.MRG.3IMERG.20140401-S010000-E012959.0060.V03D.HDF5.nc_precipitationCal[960_969][986_992],lat[986_992],lon[960_969]
Hello Guys,
I would like to read many Netcdf files with this type of names:
3B-HHR.MS.MRG.3IMERG.20140401-S000000-E002959.0000.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]
3B-HHR.MS.MRG.3IMERG.20140401-S003000-E005959.0030.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]
3B-HHR.MS.MRG.3IMERG.20140401-S010000-E012959.0060.V03D.HDF5.nc?precipitationCal[960:969][986:992],lat[986:992],lon[960:969]
As you see the first number shows the date 20140401 and then time in order to hour, minute and second.
I need to use a loop to read them in order to sorting time!!
these three files as a sample are attached.
Thank you in advance for considering this question.
Regards,
댓글 수: 0
채택된 답변
Kelly Kearney
2016년 7월 29일
Are you reading these files locally? Or is it via OPeNDAP? If the files are local, it may be easiest to query all the filenames using dir, and then sort by the date portion of the files.
If you can't do that, then do you know how many files to expect? Start date, end date, and time interval between files? Do you know the pattern to the -E portion of the file name?
-Kelly
댓글 수: 5
Kelly Kearney
2016년 8월 1일
You can replace the datetime call with
date = datenum(regexprep(tstr, '-S', ''), 'yyyymmddHHMMSS');
(datenum is a little less flexible than datetime in parsing formats with extra characters, hence the regexprep to get rid of the non-date characters).
추가 답변 (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!