Array Transforms¶
transform
: This module provides several conveinance methods for
transforming NumPy arrays in a Cartesian coordinate system.
empty_array¶
logscale¶
meshgrid¶
-
wtools.transform.
meshgrid
(x, y, z=None)[source]¶ Use this convienance method for your meshgrid needs. This ensures that we always use <ij> indexing to stay consistant with Cartesian grids.
This simply provides a wrapper for
np.meshgrid
ensuring we always useindexing='ij'
which makes sense for typical Cartesian coordinate systems (<x,y,z>).Note
This method handles 2D or 3D grids.
Example
>>> import wtools >>> import numpy as np >>> x = np.arange(20, 200, 10) >>> y = np.arange(20, 500, 20) >>> z = np.arange(0, 1000, 50) >>> xx, yy, zz = wtools.meshgrid(x, y, z) >>> # Now check that axii are ordered correctly >>> assert(xx.shape[0] == len(x)) >>> assert(xx.shape[1] == len(y)) >>> assert(xx.shape[2] == len(z))
transpose¶
-
wtools.transform.
transpose
(arr)[source]¶ Transpose matrix from Cartesian to Earth Science coordinate system. This is useful for UBC Meshgrids where +Z is down.
Note
Works forward and backward.
Parameters: arr (ndarray) – 3D NumPy array to transpose with ordering: <i,j,k> Returns: same array transposed from <i,j,k> to <j,i,-k> Return type: ndarray Example
>>> import wtools >>> import numpy as np >>> model = np.random.random(1000).reshape((10, 20, 5)) >>> wtools.transpose(model).shape (20, 10, 5)