error in opening netcdf nc4 files

2 次查看(过去 30 天)
Dear all
I have an error when I try to read data in netcdf files. Basically, I used a file list and a loop to fill a matrix with data in a 3-D output (called "DATA") ; I have the same error when I simply open this file with netcdf.open or if I try to look at its info with ncinfo or ncdisp;
>> DATA(i,:,:)=ncread(NAME_file(M(i),:),'precipitationCal');
Error using internal.matlab.imagesci.nc/openToRead (line 1272)
Could not open 3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5.nc4 for reading.
Error in internal.matlab.imagesci.nc (line 121)
this.openToRead();
Error in ncread (line 61)
ncObj = internal.matlab.imagesci.nc(ncFile);
But when I look into this file with "ncdump" for example, there are data in it that can be read
>> !ncdump 3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5.nc4 | head
netcdf \3B-HHR.MS.MRG.3IMERG.20130101-S000000-E002959.0000.V06B.HDF5 {
dimensions:
time = 1 ;
lon = 3600 ;
lat = 801 ;
variables:
float precipitationCal(time, lon, lat) ;
precipitationCal:DimensionNames = "time,lon,lat" ;
precipitationCal:Units = "mm/hr" ;
precipitationCal:units = "mm/hr" ;
Any idea to solve this issue ?
Thank you in advance
Vincent

采纳的回答

Vincent Moron
Vincent Moron 2021-1-26
The error is related to extra blank space at the end of the file names ...
>> DATA(i,:,:)=ncread(NAME_file(M(i),1:64),'precipitationCal');
makes the job
V
  1 个评论
Caroline Mallary
Caroline Mallary 2021-5-27
Thank you for this. This extra space also occurs with MERRA2's .nc4 files, e.g. MERRA2_400.tavgM_2d_aer_Nx.201901.nc4 had an extra space at the end when I initially tried to load it into Matlab.
This is a good thing to be aware of for users who are downloading satellite weather data. My file came from earthdata.nasa.gov; if yours did too, perhaps their system is adding the extra space.

请先登录,再进行评论。

更多回答(0 个)

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by