
How to open netcdf4 file in MATLAB
8 views (last 30 days)
Show older comments
Hello there!
I am trying to open file - A20021822002212.L3b_MO_CHL.nc in MATLAB. After issuing the command -
ncdisp('/home/xyz/Desktop/abc/chlorophyl_Data/A20021822002212.L3b_MO_CHL.nc'),
I see the following details:
Source:
/home/xyz/Desktop/abc/chlorophyll_Data/A20021822002212.L3b_MO_CHL.nc
Format:
netcdf4
Global Attributes:
* product_name = 'A20021822002212.L3b_MO_CHL.nc'
* title = 'MODIS Level-3 Binned Data'
* instrument = 'MODIS'
* platform = 'Aqua'
* temporal_range = '26-day'
* start_orbit_number = 885
* end_orbit_number = 1.26e+03
* date_created = '2015177112310000'
* processing_version = '2014.0'
* history = 'l3bin
* par=A20021822002212.L3b_MO_CHL.param'
* time_coverage_start = '2002-07-03T22:55:06.000Z'
* time_coverage_end = '2002-07-29T18:40:05.000Z'
* northernmost_latitude = 83.7
* southernmost_latitude = -49
* easternmost_longitude = 180
* westernmost_longitude = -180
* geospatial_lat_max = 83.7
* geospatial_lat_min = -49
* geospatial_lon_max = 180
* geospatial_lon_min = -180
* geospatial_lat_units = 'degrees_north'
* geospatial_lon_units = 'degrees_east'
* geospatial_lon_resolution = 0.0417
* geospatial_lat_resolution = 0.0417
* spatialResolution = '4.6 km'
* data_bins = 1.11e+07
* percent_data_bins = 46.9
* units = 'chlor_a:mg m^-3,chl_ocx:mg m^-3'
* binning_scheme = 'Integerized Sinusoidal Grid'
* project = 'Ocean Biology Processing Group (NASA/GSFC/OBPG)'
* institution = 'NASA Goddard Space Flight Center, Ocean Ecology Laboratory, Ocean Biology Processing Group'
* standard_name_vocabulary = 'NetCDF Climate and Forecast (CF) Metadata Conventions'
* Metadata_Conventions = 'Unidata Dataset Discovery v1.0'
* Conventions = 'CF-1.6, Unidata Dataset Discovery v1.0'
* naming_authority = 'gov.nasa.gsfc.sci.oceandata'
* id = 'A20021822002212.L3b_MO_CHL.nc/L3/A20021822002212.L3b_MO_CHL.nc'
* license = 'http://science.nasa.gov/earth-science/earth-science-data/data-information-policy/'
* creator_name = 'NASA/GSFC/OBPG'
* publisher_name = 'NASA/GSFC/OBPG'
* creator_email = 'data@oceancolor.gsfc.nasa.gov'
* publisher_email = 'data@oceancolor.gsfc.nasa.gov'
* creator_url = 'http://oceandata.sci.gsfc.nasa.gov'
* publisher_url = 'http://oceandata.sci.gsfc.nasa.gov'
* processing_level = 'L3 Binned'
* cdm_data_type = 'point'
* identifier_product_doi_authority = 'http://dx.doi.org'
* identifier_product_doi = '10.5067/AQUA/MODIS_OC.2014.0'
* keywords = 'Oceans > Ocean Chemistry > Chlorophyll; Oceans > Ocean Optics > Ocean Color'
* keywords_vocabulary = 'NASA Global Change Master Directory (GCMD) Science Keywords'
*
Groups:
/level-3_binned_data/
Dimensions:
* binListDim = 11145203 (UNLIMITED)
* binDataDim = 11145203 (UNLIMITED)
* binIndexDim = 4320 (UNLIMITED)
Variables:
BinList
* Size: 11145203x1
* Dimensions: binListDim
* Datatype: UNSUPPORTED DATATYPE
chlor_a
* Size: 11145203x1
* Dimensions: binDataDim
* Datatype: UNSUPPORTED DATATYPE
chl_ocx
* Size: 11145203x1
* Dimensions: binDataDim
* Datatype: UNSUPPORTED DATATYPE
BinIndex
* Size: 4320x1
* Dimensions: binIndexDim
* Datatype: UNSUPPORTED DATATYPE
/processing_control/
Attributes:
* software_name = 'L3BIN'
* software_version = '4.03'
* source = 'A20021852002192.L3b_8D_CHL.nc,A20021932002200.L3b_8D_CHL.nc,A20022012002208.L3b_8D_CHL.nc,A2002184.L3b_DAY_CHL.nc,A2002209.L3b_DAY_CHL.nc,A2002210.L3b_DAY_CHL.nc'
l2_flag_names = 'ATMFAIL,LAND,HILT,HISATZEN,STRAYLIGHT,CLDICE,COCCOLITH,LOWLW,CHLWARN,CHLFAIL,NAVWARN,MAXAERITER,ATMWARN,HISOLZEN,NAVFAIL,FILTER,HIGLINT'
Groups:
/processing_control/input_parameters/
Attributes:
* infile = '/data2/sdpsoper/vdc/vpu1/workbuf/l3inlist.dat'
* ofile = 'A20021822002212.L3b_MO_CHL.nc'
* pfile = 'A20021822002212.L3b_MO_CHL.nc'
* oformat = 'netCDF4'
* syear = '2002'
* eyear = '2002'
* sday = '182'
* eday = '212'
* sorbit = '-1'
* eorbit = '-1'
* out_parm = 'DEFAULT'
* processing_version = '2014.0'
* reduce_fac = '1'
* merged = ''
* loneast = '180.000000'
* lonwest = '-180.000000'
* latnorth = '90.000000'
* latsouth = '-90.000000'
* verbose = '0'
* unit_wgt = '0'
* median = '0'
* deflate = '4'
But, When I issue the command :
cc=ncread('/home/xyz/Desktop/abc/chlorophyll_Data/A20021822002212.L3b_MO_CHL.nc','/level-3_binned_data/chlor_a');
I see the following error:
Error using netcdf.getVar (line 134)
33 is not a recognized netCDF datatype.
Error in internal.matlab.imagesci.nc/read (line 606)
data = netcdf.getVar(gid, varid);
Error in ncread (line 59)
vardata = ncObj.read(varName, varargin{:});
Please help me to rectify this error.
I have also tried h5read, but no use.
Thanks
0 Comments
Accepted Answer
Chad Greene
on 10 Sep 2017
If the NetCDF file you are using is one of the ones found here, I was able to access the data like this:
A = h5read('A20021822002212.L3b_MO_CHL.nc','/level-3_binned_data/chlor_a');
then there seems to be two arrays in a structure. They're called sum and sum_squared. Plotting them against each other looks like this:
plot(A.sum,A.sum_squared,'b.')

3 Comments
Chad Greene
on 12 Sep 2017
The 'b.' is just shorthand for "blue dots". It's the same as writing this:
plot(A.sum,A.sum_squared,,'color','blue','marker','.')
The georeferencing problem is less straightforward. It's an interesting problem, so I wrote a function for it and used your example in the documentation. The function is now on File Exchange here.
More Answers (1)
See Also
Categories
Find more on NetCDF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!