pygmt.clib.Session.put_matrix

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

Attach a numpy 2D 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. Use |GMT_VIA_MATRIX' in the family.

Not at all numpy dtypes are supported, only: float64, float32, int64, int32, uint64, and uint32.

Warning

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

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

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

  • pad (int) – 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 status != 0.