aus400

aus400.cat

Tools for filtering and loading from the Aus400 catalogue

aus400.cat.catalogue: pandas.DataFrame

The full Aus400 catalogue, as a pandas.DataFrame. This catalogue may be filtered using filter_catalogue(), or the matching files opened as xarray.Dataset with load() or load_all().

The catalogue has the following columns:

runid

Experiment run name (e.g. u-bq574)

resolution

Data resolution (e.g. d0036) - A ‘d’ then the grid spacing in ten-thousandths of a degree

ensemble

Ensemble member

stream

Output stream (fx, cldrad, mdl, slv or spec)

variable

BARRA variable name

time

First timestamp in the file

path

Path to the file

standard_name

CF standard name

description

Description of the variable

methods

Variable processing

aus400.cat.filter_catalogue(cat: Optional[pandas.core.frame.DataFrame] = None, **kwargs)

Returns a filtered view of the catalogue

By default the Aus400 catalogue is used as a starting point, if more complex filtering is required a different source may be provided.

Parameters
  • cat – Source catalogue (default catalogue)

  • resolution ('d0036' or 'd0198') – Resolution to select

  • ensemble (int) – Ensemble member to select

  • stream (str) – Output stream to select

  • variable (str) – Variable name to select

  • **kwargs – Any other column from catalogue

Returns

A filtered view of the catalogue

aus400.cat.load(cat: Optional[pandas.core.frame.DataFrame] = None, **kwargs) xarray.core.dataset.Dataset

Load a single variable

Arguments should be used to narrow down what gets loaded from the full catalogue

Parameters

**kwargs – See filter_catalogue()

Returns

xarray.Dataset

aus400.cat.load_all(cat: Optional[pandas.core.frame.DataFrame] = None, **kwargs)

Load multiple variables, e.g. from different streams or resolutions

Arguments should be used to narrow down what gets loaded from the full catalogue

Parameters

**kwargs – See filter_catalogue()

Returns

Dict[str, xarray.Dataset], with keys named like “{resolution}.{stream}.{variable}”

aus400.cat.load_var(variable, cat: Optional[pandas.core.frame.DataFrame] = None, **kwargs) xarray.core.dataarray.DataArray

Load a single variable as a DataArray

Arguments should be used to narrow down what gets loaded from the full catalogue

Parameters

**kwargs – See filter_catalogue()

Returns

xarray.Dataset

aus400.regrid

Regridding operations for Aus400 data

Aus400 data is on two main resolutions, ‘d0036’ - a 0.0036 degree grid spacing (equivalent to 400m at the equator) and ‘d0198’ - a 0.0198 degree grid spacing (equivalent to 2.2 km at the equator).

The Unified Model used to run the Aus400 experiment uses an Arakawa C grid. Scalar quantities are defined at grid centres, vector quantities on grid edges. Scalar quantites are on the ‘t’ grid, e.g. ‘d0036t’, and are offset half a grid spacing E-W from ‘d0036u’ and N-S from ‘d0036v’.

The default regridding uses bilinear interpolation. For custom regridding grid definitions may be found in the ‘grids/’ directory of the Aus400 published dataset, for use by e.g. ESMF_RegridWeightGen.

aus400.regrid.identify_grid(data: xarray.core.dataset.Dataset)

Identify the grid of an Aus400 variable

Parameters

data – Variable to identify

Returns

str with grid id of ‘data’

aus400.regrid.identify_resolution(data: xarray.core.dataset.Dataset)

Identify the resolution of an Aus400 variable

Parameters

data – Variable to identify

Returns

str with resolution id of ‘data’

aus400.regrid.identify_subgrid(data)

Identify the subgrid of an Aus400 variable

Parameters

data – Variable to identify

Returns

str with subgrid id of data (‘t’,’u’ or ‘v’)

aus400.regrid.regrid_vector(data)

Redrigs vector quantities like u/v defined on grid edges to the scalar grid on gridpoint centres (same resolution as original)

Currently cannot regrid cross-sections of vector quantities – these must be regridded first before taking the cross-section afterwards. (this is because the cross-sections can mess with lat/lon spacing)

will need to load a ‘dummy’ variable to get the coordinates of the gridpoint centres at the same resolution as input data - might be able to just use grids in /g/data instead? – > these are actually different from the variable grids (?)

Inputs:

data: input data

Outputs:

data_regrid: regridded data

aus400.regrid.to_barra(data: xarray.core.dataset.Dataset)

Regrid an Aus400 variable to the BARRA t (scalar) grid

Parameters

data – Variable to regrid

Returns

xarray.Dataset with ‘data’ on the ‘barrat’ grid

aus400.regrid.to_d0198(data: xarray.core.dataset.Dataset)

Regrid an Aus400 variable to the 2.2km t (scalar) grid

Parameters

data – Variable to regrid

Returns

xarray.Dataset with ‘data’ on the ‘d0198t’ grid

aus400.render

Functions for rendering Aus400 data using Pillow

aus400.render.field_to_image(field: xarray.core.dataarray.DataArray, vmin: Optional[float] = None, vmax: Optional[float] = None)

Render a Aus400 field as an image

If vmin, vmax are not provided they are set to the minimum, maximum of the field. Values outside of vmin, vmax are clipped.

Parameters
  • field – Input 2d field

  • vmin – Minimum value for normalisation

  • vmax – Maximum value for normalisation

Returns

PIL.Image.Image in mode ‘L’

aus400.render.set_image_mpl_cmap(image: PIL.Image.Image, cmap: str)

Set a PIL.Image to use a matplotlib colour map

See https://matplotlib.org/3.1.1/gallery/color/colormap_reference.html

Parameters
  • image – Image to modify

  • cmap – Matplotlib colour map name

aus400.render.to_bytes(array)

Convert an array of floats between 0 and 1 to bytes between 0 and 255

aus400.render.zoom_region(image: PIL.Image.Image, lat: float, lon: float, scale: float, size: Tuple[int, int])

Zooms to a specific region of an Aus400 rendered image

The output image is centred at (lat, lon), is ‘scale’ degrees wide, with the height determined by the aspect ratio of ‘size’

Parameters
  • image – Source image, must cover the full d0036t grid

  • lat – Central latitude

  • lon – Central longitude

  • scale – Output longitude width in degrees

  • size – Output image size in pixels

Returns

PIL.Image.Image with size ‘size’

aus400.vertical

aus400.cross_sec