Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Error while reading netCDF file

1 Ansicht (letzte 30 Tage)
Arun Nair
Arun Nair am 3 Okt. 2019
Geschlossen: Arun Nair am 5 Okt. 2019
I am trying to open a netCDF file that has multiple subfolders. This is the code that I got from https://hdfeos.org/examples/index.php
clear
import matlab.io.hdf5.*
% Open file.
FILE_NAME='MISR_AM1_AS_AEROSOL_P139_O095382_F13_0023.nc';
file_id = H5F.open(FILE_NAME, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');
% Read data.
data_NAME='4.4_KM_PRODUCTS/Aerosol_Optical_Depth';
data_id=H5D.open(file_id, data_NAME);
data=H5D.read(data_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', ...
'H5P_DEFAULT');
% Read the fill value attribute.
ATTRIBUTE = '_FillValue';
attr_id = H5A.open_name(data_id, ATTRIBUTE);
fillvalue=H5A.read(attr_id, 'H5T_NATIVE_DOUBLE');
% Read units attribute.
ATTRIBUTE = 'units';
attr_id = H5A.open_name (data_id, ATTRIBUTE);
units = H5A.read(attr_id, 'H5ML_DEFAULT');
% Read long_name attribute.
ATTRIBUTE = 'long_name';
attr_id = H5A.open_name (data_id, ATTRIBUTE);
long_name = H5A.read(attr_id, 'H5ML_DEFAULT');
% Read latitude.
Lat_NAME='4.4_KM_PRODUCTS/Latitude';
lat_id=H5D.open(file_id, Lat_NAME);
lat=H5D.read(lat_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', ...
'H5P_DEFAULT');
% Read longitude.
Lon_NAME='4.4_KM_PRODUCTS/Longitude';
lon_id=H5D.open(file_id, Lon_NAME);
lon=H5D.read(lon_id,'H5T_NATIVE_DOUBLE', 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT');
% Close ids.
H5A.close (attr_id)
H5D.close(data_id);
H5D.close(lat_id);
H5D.close(lon_id);
H5F.close(file_id);
But it showing the error :-
Error using hdf5lib2
Unable to open file. Filename may be corrupt or have unsupported characters.
Error in H5F.open (line 48)
file_id = H5ML.hdf5lib2('H5Fopen', filename, flags, fapl);
Error in reading (line 29)
file_id = H5F.open(FILE_NAME, 'H5F_ACC_RDONLY', 'H5P_DEFAULT');
How should I solve this?
I use MATLAB R2016a.
  2 Kommentare
meghannmarie
meghannmarie am 3 Okt. 2019
Bearbeitet: meghannmarie am 3 Okt. 2019
Did you try using nc operators? Do this and post results:
ncdisp(FILE_NAME)
Arun Nair
Arun Nair am 3 Okt. 2019
Error using ncdisp
Too many output arguments.
Error in reading (line 29)
file_id = ncdisp(FILE_NAME);
This is what I'm getting!

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by