Difference between revisions of "Analysing UM outputs"

(Updated xconv access instructions)
 
Line 4: Line 4:
 
Observation and ancillary files use mostly the same format, with some minor differences in the stored vairiables.
 
Observation and ancillary files use mostly the same format, with some minor differences in the stored vairiables.
  
=XConv=  
+
= 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.
+
Xconv is a visualisation tool for working with UM & NetCDF files.
 +
 
 +
Xconv is available as a module:
 +
 
 +
<syntaxhighlight lang="bash">
 +
module use ~access/modules
 +
module load xconv
 +
xconv
 +
</syntaxhighlight>
 +
&nbsp;
 +
Note: to use xconv you must be a member of the access group on gadi.
 +
 
 +
&nbsp;
 +
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.
 
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.
Line 12: Line 25:
 
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.
 
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.
  
[[File:xconv.png|800x689px]]
+
[[File:Xconv.png|800x689px|Xconv.png]]
  
=NetCDF converters=  
+
= NetCDF converters =
  
There are a number of tools for converting between UM files and NetCDF.  
+
There are a number of tools for converting between UM files and NetCDF.
  
 
== iris2netcdf ==
 
== iris2netcdf ==
Line 22: Line 35:
 
<code>iris2netcdf</code> uses the Met Office's Iris library to do conversion from UM fields to NetCDF. It uses the Met Office's [https://github.com/SciTools/iris/blob/master/lib/iris/fileformats/um_cf_map.py mappings between STASH codes and CF standard names], so may not have correct names for fields added specifically to ACCESS (e.g. CABLE fields)
 
<code>iris2netcdf</code> uses the Met Office's Iris library to do conversion from UM fields to NetCDF. It uses the Met Office's [https://github.com/SciTools/iris/blob/master/lib/iris/fileformats/um_cf_map.py 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
+
iris2netcdf is part of the [[Conda|Conda]] environments
<syntaxhighlight lang=bash>
+
<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 47:
  
 
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 lang=bash>
+
<syntaxhighlight lang="bash">
 
module use ~access/modules
 
module use ~access/modules
 
module load pythonlib/cdat-lite
 
module load pythonlib/cdat-lite
Line 47: Line 60:
 
<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 lang=bash>
+
&nbsp;
 +
<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
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Iris=  
+
= Iris =
  
 
[http://scitools.org.uk/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.
 
[http://scitools.org.uk/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
 
To make Iris available run
<syntaxhighlight lang=bash>
+
<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 79:
  
 
To extract a field from a UM file using Iris
 
To extract a field from a UM file using Iris
<syntaxhighlight lang=python>
+
<syntaxhighlight lang="python">
 
#!/usr/bin/env python
 
#!/usr/bin/env python
 
import iris
 
import iris
Line 73: Line 87:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=CDAT=  
+
= CDAT =
  
 
[http://www2-pcmdi.llnl.gov/cdat CDAT] is another Python-based climate data package, it provides some support for UM output files.
 
[http://www2-pcmdi.llnl.gov/cdat CDAT] is another Python-based climate data package, it provides some support for UM output files.
  
 
To make CDAT available run
 
To make CDAT available run
<syntaxhighlight lang=bash>
+
<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 99:
 
To extract a field from a UM file using CDAT
 
To extract a field from a UM file using CDAT
  
<syntaxhighlight lang=python>
+
&nbsp;
 +
<syntaxhighlight lang="python">
 
#!/usr/bin/env python
 
#!/usr/bin/env python
 
import cdms2
 
import cdms2
Line 99: Line 114:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Mule=
+
= 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.
 
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
 
To make Mule available run
<syntaxhighlight lang=bash>
+
<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 111: Line 126:
 
[https://code.metoffice.gov.uk/doc/um/mule/2017.08.1/examples.html Example Mule scripts]
 
[https://code.metoffice.gov.uk/doc/um/mule/2017.08.1/examples.html Example Mule scripts]
  
=Resources=  
+
= Resources =
  
* [https://nf.nci.org.au/facilities/software/UM/8.2/umdoc_system/UM_docs/papers/html/F3/index.html Fieldsfile Documentation]
+
*[https://nf.nci.org.au/facilities/software/UM/8.2/umdoc_system/UM_docs/papers/html/F3/index.html Fieldsfile Documentation]  
* [https://github.com/coecms/fieldsfile CMS Fieldsfile tools]
+
*[https://github.com/coecms/fieldsfile CMS Fieldsfile tools]  
* [http://scitools.org.uk/iris/ Iris Homepage]
+
*[http://scitools.org.uk/iris/ Iris Homepage]  
  
 
[[Category:Unified Model]]
 
[[Category:Unified Model]]

Latest revision as of 20:08, 24 February 2020

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.

Xconv is available as a module:  

module use ~access/modules
module load xconv
xconv

  Note: to use xconv you must be a member of the access group on gadi.

  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

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

Example Mule scripts

Resources