pygmt.clib.Session.put_matrix

Session.put_matrix(dataset, matrix, pad=0)[source]

Attach a 2-D numpy array to a GMT dataset.

Use this function to attach numpy array data to a GMT dataset and pass it to GMT modules. Wraps GMT_Put_Matrix.

The dataset must be created by pygmt.clib.Session.create_data first with family="GMT_IS_DATASET|GMT_VIA_MATRIX".

Not all numpy dtypes are supported, only: int8, int16, int32, int64, longlong, uint8, uint16, uint32, uint64, ulonglong, float32, and float64.

Warning

The numpy array must be C contiguous in memory. Use numpy.ascontiguousarray to make sure your matrix is contiguous (it won’t copy if it already is).

Parameters:
  • dataset (c_void_p) – The ctypes void pointer to a GMT_MATRIX data container. Create it with pygmt.clib.Session.create_data.

  • matrix (ndarray) – The array that will be attached to the dataset. Must be a 2-D C contiguous array.

  • pad (int, default: 0) – The amount of padding that should be added to the matrix. Use when creating grids for modules that require padding.

Raises:

GMTCLibError – If given invalid input or GMT_Put_Matrix exits with a non-zero status.