The UM output files are in a binary format called 'fieldsfile'. This format consists of a set of headers describing the file as a whole, a lookup table describing the fields and a data table containing the field values. The format only supports 2D fields, 3D fields are stored as a 2D field for each vertical level.

Observation and ancillary files use mostly the same format, with some minor differences in the stored vairiables.

XConv


Xconv is a visualisation tool for working with UM & NetCDF files, found in ~access/bin. Select a variable from the list by double-clicking it, then use the Plot Data button in the upper left to visualise it. You can use the section on the right to specify a subregion to look at by e.g. swapping to the 'z' co-ordinate at the bottom, selecting a vertical level then pressing Apply to show only that level.

The selection controls in Xconv are a little unusual: left click lines to add them to the selection, middle click to select only that line and right-click to select the region between that line and where you last clicked.

You can convert fields to NetCDF format from within Xconv: select multiple fields, enter a name at the top of the screen then press the Convert button.

xconv.png

NetCDF converters


um2netcdf.py is the program used by CAWCR to convert UM output to NetCDF for CMIP analysis. It includes CF fieldnames for most fields required by CMIP, it's available in ~access/bin

To use the script you first need to load some Python libraries, run the script like
module use ~access/modules
module load pythonlib/cdat-lite
module load pythonlib/ScientificPython
~access/bin/um2netcdf.py -i uabcda.pah010 -o outfile.nc

Iris


Iris is a Python library developed by the Met Office for working with climate and weather data. It is able to load UM files into numpy arrays for further processing.

To make Iris available run
module use /g/data3/hh5/public/modules
module load conda/analysis3 # (or conda/analysis27 for python2.7)

For basic conversion the `iris2netcdf` command can convert UM format files to compressed NetCDF:
iris2netcdf --output an793.daily.nc an493a.p919500101 an493a.p919500201

To extract a field from a UM file using Iris
#!/usr/bin/env python
import iris
 
Tsurf = iris.load('uabcda.pah010', 'surface_temperature')
iris.io.save(Tsurf, 'Tsurf.nc')


CDAT


CDAT is another Python-based climate data package, it provides some support for UM output files.

To make CDAT available run
module use /g/data3/hh5/public/modules
module load conda/analysis27

To extract a field from a UM file using CDAT

#!/usr/bin/env python
import cdms2
 
data = cdms2.open('uabcda.pah010')
Tsurf = data['temp']
 
outfile = cdms2.open('Tsurf.nc','w')
outfile.write(Tsurf)
 
outfile.close()
data.close()

Mule


Mule is a python library for working with UM format files directly. It allows you to do things like modify header values for individual fields.

To make Mule available run
module use /g/data3/hh5/public/modules
module load conda/analysis3 # (or conda/analysis27 for python2.7)

Example Mule scripts

Resources


Fieldsfile Documentation
CMS Fieldsfile tools
Iris Homepage