Documentation page for cdat_utils.py¶
Interfacing netcdf data via CDAT
Author: guangzhi XU (xugzhi1987@gmail.com) Update time: 2020-12-05 10:28:38.
- cdat_utils.checkGeomap(var, xarray, yarray)¶
Check input args suitable for geo plot or not and do some preprocessing
- Parameters
var (TransientVariable) – input N-d TransientVariable.
xarray (ndarray) – 1d array, x-coordinates.
yarray (ndarray) – 1d array, y-coordinates.
- Returns
isgeo (bool) –
- True if inputs are suitable for geographical plot, False
otherwise.
- var (TransientVariable): input <var> with latitude order reversed if
needed.
- xx (ndarray): 1d array, use longitude axis of <var> if possible,
<xarray> otherwise
- yy (ndarray): 1d array, use latitude axis of <var> if possible,
<yarray> otherwise
- cdat_utils.increasingLatitude(slab, verbose=False)¶
Changes a slab so that is always has latitude running from south to north.
- Parameters
slab (TransientVariable) – input TransientVariable, need to have a proper latitude axis.
- Returns
slab2 (TransientVariable) –
- if latitude axis is reversed, or <slab>
otherwise.
If <slab> has a latitude axis, and the latitudes run from north to south, a copy <slab2> is made with the latitudes reversed, i.e., running from south to north.
- cdat_utils.interpretAxis(axis, ref_var, verbose=True)¶
Interpret and convert an axis id to index
- Parameters
axis (int or str) – axis option, integer (e.g. 0 for 1st dimension) or string (e.g. ‘x’ for x-dimension).
ref_var (TransientVariable) – reference variable.
- Returns
axis_index (int) – the index of required axis in <ref_var>.
- E.g. index=interpretAxis(‘time’,ref_var)
index=0
index=interpretAxis(1,ref_var) index=1
- cdat_utils.isInteger(x)¶
Check an input is integer
- Parameters
x (unknow type) – input
- Returns
True if <x> is integer type, False otherwise.
- cdat_utils.readData(varid)¶
Read sample netcdf data
- Parameters
varid (str) – id of variable to read.
- Returns
var (TransientVariable) – sample netcdf data.