A boilerplate NcML writer via jython. You don't have to stop at
NetCDF. This library reads much more. Thanks again for pointing this
tool out. Additional documentation will be generated in the IOOS
Technical google group (
http://groups.google.com/group/ioos_tech).
#!/usr/bin/env jython
import ucar
wrf = ucar.nc2.dataset.NetcdfDataset.openDataset('wrfout-
d01-20090404_00z.nc')
# Open a file to write the NcML
f = open('wrfout-d01-20090404_00z.xml', 'w')
wrf.writeNcML(f,None)
---
$ cat wrfout-d01-20090404_00z.xml
<?xml version="1.0" encoding="UTF-8"?>
<netcdf xmlns="
http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2"
location="file:
wrfout-d01-20090404_00z.nc">
<dimension name="time" length="49" />
<dimension name="nob" length="19" />
<dimension name="ydim" length="78" />
<dimension name="xdim" length="141" />
<attribute name="title" value="4 km Prince William Sound Regional
WRF Model Output from AEFF" />
....
<variable name="TMP_2_HTGL" shape="time ydim xdim" type="float">
<attribute name="long_name"
value="air_temperature_at_2m_above_ground" />
<attribute name="standard_name"
value="air_temperature_at_2m_above_ground" />
<attribute name="units" value="degC" />
</variable>
....
<variable name="time" shape="time" type="double">
<attribute name="long_name" value="forecast_reference_time" />
<attribute name="standard_name" value="forecast_reference_time" />
<attribute name="units" value="days since 0001-01-01 00:00:0.0" />
<attribute name="timezone" value="GMT" />
<attribute name="_CoordinateAxisType" value="Time" />
</variable>
<variable name="lat" shape="ydim xdim" type="float">
<attribute name="long_name" value="latitude" />
<attribute name="standard_name" value="latitude" />
<attribute name="units" value="degrees_north" />
<attribute name="_CoordinateAxisType" value="Lat" />
</variable>
<variable name="lon" shape="ydim xdim" type="float">
<attribute name="long_name" value="longitude" />
<attribute name="standard_name" value="longitude" />
<attribute name="units" value="degrees_east" />
<attribute name="_CoordinateAxisType" value="Lon" />
</variable>
<variable name="PRES_SFC" shape="time ydim xdim" type="float">
<attribute name="long_name" value="surface_air_pressure" />
<attribute name="standard_name" value="surface_air_pressure" />
<attribute name="units" value="mbar" />
<attribute name="_CoordinateAxisType" value="Pressure" />
</variable>
</netcdf>