Azzera filtri
Azzera filtri

error in opening netcdf nc4 files

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Vincent Moron
Vincent Moron il 26 Gen 2021
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 Commento
Caroline Mallary
Caroline Mallary il 27 Mag 2021
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.

Accedi per commentare.

Più risposte (0)

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by