Tuesday, 28 April 2015

gdal - Converting GRIB to NetCDF with time dimension using netcdfAll?


I'm trying to convert grib files to NetCDF. The grib files contains subdata sets which are time related. Using the netcdfAll Java library with the NetCDF-4 C library works fine.


java -Xmx1g -classpath netcdfAll-4.5.jar ucar.nc2.dataset.NetcdfDataset -in ECM_DSD_2015021700_0000 -out ECM_DSD_2015021700_0000.nc -isLargeFile -netcdf4

The resulting NetCDF-4 file:


gdalinfo ECM_DSD_2015021700_0000.nc is listing all subdata sets like
Subdatasets:

SUBDATASET_1_NAME=HDF5:"ECM_DSD_2015021700_0000.nc"://GaussianLatLon_1280X2560-p07028S-179p9W/100_metre_U_wind_component_surface
SUBDATASET_1_DESC=[1x1280x2560] //GaussianLatLon_1280X2560-p07028S-179p9W/100_metre_U_wind_component_surface (32-bit floating-point)
SUBDATASET_2_NAME=HDF5:"ECM_DSD_2015021700_0000.nc"://GaussianLatLon_1280X2560-p07028S-179p9W/100_metre_V_wind_component_surface
SUBDATASET_2_DESC=[1x1280x2560] //GaussianLatLon_1280X2560-p07028S-179p9W/100_metre_V_wind_component_surface (32-bit floating-point)

The metatada of one subset shows an empty dimension list and a missing time dimension:


gdalinfo HDF5:"ECM_DSD_2015021700_0000.nc"://GaussianLatLon_1280X2560-p07028S-179p9/100_metre_U_wind_component_surface
Band 1 Block=2560x25 Type=Float32, ColorInterp=Undefined
Min=-25.970 Max=30.284
Minimum=-25.970, Maximum=30.284, Mean=0.493, StdDev=7.106

Metadata:
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface__Netcdf4Dimid=15
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_coordinates=time
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_DIMENSION_LIST=
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Center=98
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Level_Desc=Ground or water surface
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Level_Type=1
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Parameter=246
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Parameter_Name=100u
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_Subcenter=0

GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib1_TableVersion=228
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_Grib_Variable_Id=VAR_98-0-228-246_L1
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_long_name=100 metre U wind component @ Ground or water surface
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_missing_value=1.#QNAN
GaussianLatLon_1280X2560-p07028S-179p9W_100_metre_U_wind_component_surface_units=m s**-1
STATISTICS_MAXIMUM=30.284362792969
STATISTICS_MEAN=0.49316239946346
STATISTICS_MINIMUM=-25.969543457031
STATISTICS_STDDEV=7.1061257055032


So what is the trick to convert the data with the time dimension? I found some python scripts[1] and the ncks tool[2], need I switch to one of them?


After I want to convert each subdataset to a single GeoTiff but this should be more easy when the time dimension was rescued once :-)


I am working with GDAL 1.11 and netcdfAll 4.5


[1] http://pysclint.sourceforge.net/pycdf/pycdf.html and https://readchunks.wordpress.com/ [2] http://linux.die.net/man/1/ncks




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...