Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Error while reading netCDF file

1 vue (au cours des 30 derniers jours)
Arun Nair
Arun Nair le 3 Oct 2019
Clôturé : Arun Nair le 5 Oct 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 commentaires
meghannmarie
meghannmarie le 3 Oct 2019
Modifié(e) : meghannmarie le 3 Oct 2019
Did you try using nc operators? Do this and post results:
ncdisp(FILE_NAME)
Arun Nair
Arun Nair le 3 Oct 2019
Error using ncdisp
Too many output arguments.
Error in reading (line 29)
file_id = ncdisp(FILE_NAME);
This is what I'm getting!

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by