How to open GRIB2 file using ncgeodatset?

11 ビュー (過去 30 日間)
Zhou Ci
Zhou Ci 2022 年 5 月 26 日
回答済み: Jacob Halbrooks 2024 年 9 月 25 日
Hi everyone,
I am trying to open a 'GRIB2' file using ncgeodataset. But I am not able to do it.
fname = 'E:\NCEP\fnl_20170603_06_00.grib2'
ds = ncgeodataset(fname);
After I run above two lines, these are the results. Can somebody tell me what is the issue here. Thank you
fname =
'E:\NCEP\fnl_20170603_06_00.grib2'
2022-05-26 19:40:45,657 [main] WARN ucar.nc2.grib.grib2.Grib2CollectionBuilder - GribCollection fnl_20170603_06_00.grib2: invalid index
2022-05-26 19:40:45,657 [main] WARN ucar.nc2.grib.GribCollection - Failed to delete E:\NCEP\fnl_20170603_06_00.grib2.ncx
Warning: Escaped character '\N' is not valid. See 'doc sprintf' for supported special characters.
> In ncdataset (line 95)
In cfdataset (line 59)
In ncgeodataset (line 74)
Error using ncdataset (line 97)
Failed to open E:
Error in cfdataset (line 59)
obj = obj@ncdataset(url);
Error in ncgeodataset (line 74)
obj = obj@cfdataset(url);
Caused by:
Error using ncdataset (line 81)
Java exception occurred:
java.lang.UnsupportedOperationException: This is supposed to be overridden by subclasses.
at com.google.protobuf.GeneratedMessage.getUnknownFields(GeneratedMessage.java:262)
at ucar.nc2.grib.GribCollectionProto$Record.getSerializedSize(GribCollectionProto.java:162)
at com.google.protobuf.CodedOutputStream.computeMessageSizeNoTag(CodedOutputStream.java:916)
at com.google.protobuf.CodedOutputStream.computeMessageSize(CodedOutputStream.java:668)
at ucar.nc2.grib.GribCollectionProto$VariableRecords.getSerializedSize(GribCollectionProto.java:657)
at com.google.protobuf.AbstractMessageLite.toByteArray(AbstractMessageLite.java:70)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:558)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.createIndex(Grib2CollectionBuilder.java:415)
at ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndex(Grib2CollectionBuilder.java:157)
at
ucar.nc2.grib.grib2.Grib2CollectionBuilder.readOrCreateIndexFromSingleFile(Grib2CollectionBuilder.java:77)
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)
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)
  1 件のコメント
jessupj
jessupj 2022 年 5 月 26 日
編集済み: jessupj 2022 年 5 月 26 日
I think this is an external tool (https://github.com/nctoolbox). You're better off asking around the developer instead of this community, as it's probbaly not a matlab-itself problem.
(My guess is opendap problems or an incompatible JVM version. if your gribfile is local, have you tried converting it to netcdf in ncl and loading it with the matlab function ncread? That way, it's at least in 'matlab' rather than a 3rd party tool and you're likely to get more help here.)

サインインしてコメントする。

採用された回答

Jacob Halbrooks
Jacob Halbrooks 2024 年 9 月 25 日
As of R2023b, you can read data from a GRIB file (.grb, .grib, .grib2) using the Mapping Toolbox readgeoraster function. You can also get information about a GRIB file by using the georasterinfo function. These functions were enhanced in R2024b to support GRIB files that use CCSDS compression.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Web Services from MATLAB Using HTTP についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by