Difference between revisions of "Analysing UM outputs"
Line 23: | Line 23: | ||
iris2netcdf is part of the [[Conda]] environments | iris2netcdf is part of the [[Conda]] environments | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
module use /g/data3/hh5/public/modules | module use /g/data3/hh5/public/modules | ||
module load conda/analysis3 | module load conda/analysis3 | ||
Line 34: | Line 34: | ||
To use the script you first need to load some Python libraries, run the script like | To use the script you first need to load some Python libraries, run the script like | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
module use ~access/modules | module use ~access/modules | ||
module load pythonlib/cdat-lite | module load pythonlib/cdat-lite | ||
Line 47: | Line 47: | ||
<code>um2cdf</code> uses the scripting interface of Xconv to do conversion - it is the same as using the NetCDF export from the Xconv GUI. | <code>um2cdf</code> uses the scripting interface of Xconv to do conversion - it is the same as using the NetCDF export from the Xconv GUI. | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
~access/bin/um2cdf uabcda.pah010 | ~access/bin/um2cdf uabcda.pah010 | ||
# Will create uabcda.pah010.nc in the current directory | # Will create uabcda.pah010.nc in the current directory | ||
Line 57: | Line 57: | ||
To make Iris available run | To make Iris available run | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
module use /g/data3/hh5/public/modules | module use /g/data3/hh5/public/modules | ||
module load conda/analysis3 | module load conda/analysis3 | ||
Line 65: | Line 65: | ||
To extract a field from a UM file using Iris | To extract a field from a UM file using Iris | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=python> |
#!/usr/bin/env python | #!/usr/bin/env python | ||
import iris | import iris | ||
Line 78: | Line 78: | ||
To make CDAT available run | To make CDAT available run | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
module use /g/data3/hh5/public/modules | module use /g/data3/hh5/public/modules | ||
module load conda/analysis27 | module load conda/analysis27 | ||
Line 85: | Line 85: | ||
To extract a field from a UM file using CDAT | To extract a field from a UM file using CDAT | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=python> |
#!/usr/bin/env python | #!/usr/bin/env python | ||
import cdms2 | import cdms2 | ||
Line 104: | Line 104: | ||
To make Mule available run | To make Mule available run | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang=bash> |
module use /g/data3/hh5/public/modules | module use /g/data3/hh5/public/modules | ||
module load conda/analysis3 | module load conda/analysis3 |
Revision as of 23:24, 11 December 2019
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.
Contents
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.
NetCDF converters
There are a number of tools for converting between UM files and NetCDF.
iris2netcdf
iris2netcdf
uses the Met Office's Iris library to do conversion from UM fields to NetCDF. It uses the Met Office's mappings between STASH codes and CF standard names, so may not have correct names for fields added specifically to ACCESS (e.g. CABLE fields)
iris2netcdf is part of the Conda environments
module use /g/data3/hh5/public/modules
module load conda/analysis3
iris2netcdf -o outfile.nc uabcda.pah010
um2netcdf.py
um2netcdf.py
is the program used by CAWCR to convert UM output to NetCDF for CMIP5 analysis. It includes CF fieldnames for most fields required by CMIP5, 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
um2netcdf.py may have problems with some fields, e.g. zonally averaged ozone.
um2cdf
um2cdf
uses the scripting interface of Xconv to do conversion - it is the same as using the NetCDF export from the Xconv GUI.
~access/bin/um2cdf uabcda.pah010
# Will create uabcda.pah010.nc in the current directory
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
For basic conversion the `iris2netcdf` command can convert UM format files to compressed NetCDF
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