pygmt.clib.Session.put_vector

Session.put_vector(dataset, column, vector)[source]

Attach a numpy 1-D array as a column on a GMT dataset.

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

The dataset must be created by pygmt.clib.Session.create_data first. Use family='GMT_IS_DATASET|GMT_VIA_VECTOR'.

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

Warning

The numpy array must be C contiguous in memory. If it comes from a column slice of a 2-D array, for example, you will have to make a copy. 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.

  • column (int) – The column number of this vector in the dataset (starting from 0).

  • vector (numpy 1-D array) – The array that will be attached to the dataset. Must be a 1-D C contiguous array.

Raises

GMTCLibError – If given invalid input or GMT_Put_Vector exits with status != 0.