Unable to read grib2 data with nctoolbox

조회 수: 31 (최근 30일)
John Cruce
John Cruce 2021년 9월 14일
댓글: Muyin Wang 2022년 10월 14일
I'm attempting to read MRMS radar data from here:
I grabbed a sample grib2 file. I've used nctoolbox for several years and this is the first time I've run into an issue reading data. The variable I'm having issues with is the reflectivity data (VAR209-3-57_FROM_161-0-0_altitude_above_msl).
Here is the simple read code:
nc=ncgeodataset('MRMS_ReflectivityAtLowestAltitude_00.50_20210913-194039.grib2');
time=nc.geovariable('time');
time=time.data(:);
altitude=nc.geovariable('altitude_above_msl');
altitude=altitude.data(:);
lat=nc.geovariable('lat');
lat=lat.data(:);
lon=nc.geovariable('lon');
lon=lon.data(:);
lowestalt=nc.geovariable('VAR209-3-57_FROM_161-0-0_altitude_above_msl');
lowestalt=squeeze(lowestalt.data(:,:,:,:));
I encouter the following error upon running:
Error using ncdataset/readdata (line 494)
Java exception occurred:
java.lang.UnsupportedOperationException: Unsupported DRS type = 41
at ucar.nc2.grib.grib2.Grib2Drs.factory(Grib2Drs.java:59)
at
ucar.nc2.grib.grib2.Grib2SectionDataRepresentation.getDrs(Grib2SectionDataRepresentation.java:73)
at ucar.nc2.grib.grib2.Grib2Record.readData(Grib2Record.java:271)
at ucar.nc2.grib.grib2.Grib2Iosp$DataReader.read(Grib2Iosp.java:983)
at ucar.nc2.grib.grib2.Grib2Iosp.readDataFromCollection(Grib2Iosp.java:912)
at ucar.nc2.grib.grib2.Grib2Iosp.readData(Grib2Iosp.java:722)
at ucar.nc2.NetcdfFile.readData(NetcdfFile.java:1941)
at ucar.nc2.Variable.reallyRead(Variable.java:859)
at ucar.nc2.Variable._read(Variable.java:831)
at ucar.nc2.Variable.read(Variable.java:709)
at ucar.nc2.dataset.VariableDS.reallyRead(VariableDS.java:518)
at ucar.nc2.dataset.VariableDS._read(VariableDS.java:502)
at ucar.nc2.dataset.VariableDS._read(VariableDS.java:526)
at ucar.nc2.Variable.read(Variable.java:695)
at ucar.nc2.Variable.read(Variable.java:669)
Error in ncdataset/data (line 171)
d = obj.readdata(variable, first, last, stride);
Error in ncgeodataset/subsref (line 630)
B = builtin('subsref',obj,g);
Error in ncvariable/somedata (line 406)
data = obj.dataset.data(name, first, last, stride);
Error in ncvariable/data (line 189)
d = somedata(obj, 1, first, last, stride);
Error in ncgeovariable/subsref (line 1116)
sref = obj.data(first, last, stride);
Error in ncgeodataset/subsref (line 660)
B = v.data(s(2).subs{:});
Any thoughts on what might be the issue here?
  댓글 수: 1
Muyin Wang
Muyin Wang 2022년 10월 14일
I ran into similar problems. My code worked last year on Matlab2020a. But then I got a new MacBook Pro (with M1 chips), then the same code stopped working. I also tried MatlabR2018a, still, I got the following error messages:
Error using ncdataset (line 97)
Failed to open CFS-mon/ocnh06.gdas.202001.grib2
Error in cfdataset (line 59)
obj = obj@ncdataset(url);
Error in ncgeodataset (line 74)
obj = obj@cfdataset(url);
Error in comp_theta_steveupdate1 (line 29)
grb2=ncgeodataset(file);
Caused by:
Error using ncdataset (line 81)
Java exception occurred:
java.lang.RuntimeException: java.lang.NoClassDefFoundError:
ucar/nc2/util/CloseableIterator
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1535)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:887)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:496)
at ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:693)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:424)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:407)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:392)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:379)
Caused by: java.lang.NoClassDefFoundError: ucar/nc2/util/CloseableIterator
at
ucar.nc2.grib.grib2.Grib2CollectionBuilder.<init>(Grib2CollectionBuilder.java:115)
at
ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndexFromSingleFile(Grib2CollectionBuilder.java:76)
at
ucar.nc2.grib.GribIndex.makeGribCollectionFromSingleFile(GribIndex.java:123)
at ucar.nc2.grib.grib2.Grib2Iosp.open(Grib2Iosp.java:310)
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1499)
... 7 more
Caused by: java.lang.ClassNotFoundException: ucar.nc2.util.CloseableIterator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more

댓글을 달려면 로그인하십시오.

답변 (1개)

Feixiong Huang
Feixiong Huang 2021년 10월 18일
You have to use MATLAB2017 or lower version
  댓글 수: 1
Muyeqingfeng
Muyeqingfeng 2022년 6월 9일
I don't think that. I'm using the version of 2020b, but there also always appear wrong.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Web Services에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by