Hi guys:
I use the 64bit IDL 8.0.1 java-bridge to read grib data with Netcdf-JAVA. The Netcdf-java package is
ftp://ftp.unidata.ucar.edu/pub/netcdf-java/v4.2/toolsUI-4.2.jar, and the grib data is "Historical Unidata Internet Data Distribution (IDD) Gridded Model Data" (
http://dss.ucar.edu/datasets/ds335.0/). I use the following commands in IDL workbench to read these grib data and get errors. But running these commands in "IDL Command Line" window. It's ok. So why?
IDL> filepathname = file_search("E:\GFS_Global_0p5deg_20100426_0000_anl.grib2")
IDL> varNames = nmc_grib_get_variable_names(filePathName)
% Jun 11, 2011 12:09:44 PM ucar.grib.grib2.ParameterTable
SEVERE: grib2 table reading failed
java.lang.IllegalArgumentException: InputStream cannot be null
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:120)
at ucar.grib.grib2.ParameterTable.(ParameterTable.java:88)
at ucar.grib.GribGridRecord.getParameter(GribGridRecord.java:256)
at ucar.grib.GribGridRecord.getParameterDescription(GribGridRecord.java:246)
at ucar.grib.GribGridRecord.cdmVariableName(GribGridRecord.java:372)
at ucar.nc2.iosp.grid.GridIndexToNC.open(GridIndexToNC.java:135)
at ucar.nc2.iosp.grib.GribGridServiceProvider.open(GribGridServiceProvider.java:126)
at ucar.nc2.NetcdfFile.(NetcdfFile.java:1318)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:754)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:394)
at ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:687)
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)
at com.rsi.idldt.core.ips.IPS_Access.IPS_Start(Native Method)
at com.rsi.idldt.core.ips.IPS_Manager$2.run(IPS_Manager.java:383)
at java.lang.Thread.run(Thread.java:619)
ps:
function nmc_grib_get_variable_names, inFile
compile_opt idl2, hidden
IF SIZE(inFile, /type) EQ 7 THEN BEGIN
; create netcdf dataset
oNetcdfDataset = OBJ_NEW("IDLJavaObject$NetcdfDataset", "ucar.nc2.dataset.NetcdfDataset")
; open netcdf file
NetcdfFileObj = oNetcdfDataset->openDataset(inFile)
ENDIF ELSE BEGIN
NetcdfFileObj = inFile
ENDELSE
; check object
if ~obj_isa(NetcdfFileObj,'IDLJAVAOBJECT$UCAR_NC2_NETCDFFILE') and $
~obj_isa(NetcdfFileObj,'IDLJAVAOBJECT$UCAR_NC2_DATASET_NETCDFDATASET') then $
message, 'NetcdfFileObj is not valid UCAR_NC2_NETCDFFILE or UCAR_NC2_DATASET_NETCDFDATASET object'
; get variables
var = NetcdfFileObj->getVariables()
; get variable array
varArr = var->toArray()
; get variable number
varNum = var->size()
; create variable name array
varNames = strarr(varNum)
; get variable names
for i=0L, varNum-1L do begin
varNames[i] = varArr[i]->getShortName()
endfor
; destroy objects
obj_destroy, var
obj_destroy, varArr
; destroy file objects
IF SIZE(inFile, /type) EQ 7 THEN BEGIN
OBJ_DESTROY, oNetcdfDataset
OBJ_DESTROY, NetcdfFileObj
ENDIF
return, varNames
end