用matlab处理grib2,关于Matlab2017b读取GRIB2文件的问题
由于經(jīng)常需要處理grib2格式的大氣海洋數(shù)據(jù),因此,經(jīng)常用到用于讀取nc、hdf、grib等數(shù)據(jù)的Matlab工具箱:nctoolbox和snctools。Matlab版本升級(jí)為Matlab2017b之后,出現(xiàn)了問(wèn)題,以前的2015b、2016a、2016b、2017a均可以正常使用。問(wèn)題具體表現(xiàn)如下。
由于nctoolbox和snctools是通過(guò)調(diào)用NetCDF的java庫(kù)文件,所以需要在toolbox\local\classpath.txt指定java的路徑,nctoolbox和snctools都是2014年之前開(kāi)發(fā)的工具箱,默認(rèn)使用的netcdf-java是4.2版本,但不能正確識(shí)別最近GRIB2格式中一些變量,特別是本人常用的CFSR、GFS、GDAS數(shù)據(jù)集中部分變量不能識(shí)別。為了能夠正常讀取所有的GRIB2變量,我在Matlab2015b、Matlab2016b的時(shí)候都是使用netcdf-java-4.6.9、netcdf-java-4.6.10,但是,但是,但是,切換到Matlab2017b,一起變了,只能使用netcdf-java-4.2才能讀取GRIB2文件,4.3、4.4、4.5、4.6的所有版本都試了一遍,都不行??啾频氖?#xff0c;4.2版本,雖然能讀取,可有很多變量不能識(shí)別,也就是說(shuō)讀取文件并不正常,用起來(lái)也就沒(méi)什么意義。
請(qǐng)教解決方案。
使用netcdf-java-4.2版本打開(kāi)GRIB2文件時(shí)候,自動(dòng)生成*.gbx8文件;使用4.6版本的,則自動(dòng)生成*.gbx9和*.ncx3兩個(gè)文件。
Matlab2017b打開(kāi)GRIB2文件錯(cuò)誤信息如下:
>> fn
fn =
'f:\gdas2.0p25.2016120100.f00.grb2'
>> q=nc_info(fn)
錯(cuò)誤使用 nc_info_java (line 26)
Java exception occurred:
java.io.IOException: java.lang.RuntimeException: java.lang.NoSuchFieldError: userTimeUnit
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:427)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:394)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:381)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:369)
Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldError: userTimeUnit
at ucar.nc2.NetcdfFile.(NetcdfFile.java:1596)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:835)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:424)
... 3 more
Caused by: java.lang.NoSuchFieldError: userTimeUnit
at
ucar.nc2.grib.collection.Grib2CollectionBuilder$Grib2Rectilyser.make(Grib2CollectionBuilder.java:259)
at ucar.nc2.grib.collection.Grib2CollectionBuilder.makeGroups(Grib2CollectionBuilder.java:163)
at
ucar.nc2.grib.collection.GribCollectionBuilder.createMultipleRuntimeCollections(GribCollectionBuilder.java:150)
at ucar.nc2.grib.collection.GribCollectionBuilder.createIndex(GribCollectionBuilder.java:138)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:780)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:764)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromRaf(GribCdmIndex.java:734)
at ucar.nc2.grib.collection.GribIosp.open(GribIosp.java:213)
at ucar.nc2.NetcdfFile.(NetcdfFile.java:1560)
... 5 more
出錯(cuò) nc_info (line 55)
fileinfo = nc_info_java(ncfile);
總結(jié)
以上是生活随笔為你收集整理的用matlab处理grib2,关于Matlab2017b读取GRIB2文件的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 大数的相加 乘 余 幂
- 下一篇: zcmu-1661