pygmt.clib.Session.create_data
- Session.create_data(family, geometry, mode, dim=None, ranges=None, inc=None, registration='GMT_GRID_NODE_REG', pad=None)[source]
Create an empty GMT data container and allocate space to hold data.
Valid data families and geometries are in
FAMILIESandGEOMETRIES.There are two ways to define the dimensions needed to actually allocate memory:
Via
ranges,incandregistration.Via
dimandregistration.dimcontains up to 4 values and they have different meanings for different GMT data families:For
GMT_DATASET:0: number of tables
1: number of segments per table
2: number of rows per segment
3: number of columns per row
For
GMT_VECTOR:0: number of columns
1: number of rows [optional, can be 0 if unknown]
2: data type (e.g.,
GMT_DOUBLE) [Will be overwritten byput_vector]
For
GMT_GRID/GMT_IMAGE/GMT_CUBE/GMT_MATRIX:0: number of columns
1: number of rows
2: number of bands or layers [Ignored for
GMT_GRID]3: data type (e.g.,
GMT_DOUBLE) [ForGMT_MATRIXonly, but will be overwritten byput_matrix]
In other words,
incis assumed to be 1.0, andrangesis [0, dim[0], 0, dim[1]] for pixel registration or [0, dim[0]-1.0, 0, dim[1]-1.0] for grid registration.
When creating a grid/image/cube, you can do it in one or two steps:
Call this function with
mode="GMT_CONTAINER_AND_DATA". This creates a header and allocates a grid or an imageCall this function twice:
First with
mode="GMT_CONTAINER_ONLY", to create a header only and compute the dimensions based on other parametersSecond with
mode="GMT_DATA_ONLY", to allocate the grid/image/cube array based on the dimensions already set. This time, you pass NULL fordim/ranges/inc/registration/padand letdatabe the void pointer returned in the first step.
Note: This is not implemented yet, since this function doesn’t have the
dataparameter.
- Parameters:
family (
str) – A valid GMT data family name (e.g.,"GMT_IS_DATASET"). SeeFAMILIESfor valid names.geometry (
str) – A valid GMT data geometry name (e.g.,"GMT_IS_POINT"). SeeGEOMETRIESfor valid names.mode (
str) – A valid GMT data mode. SeeMODESfor valid names. ForGMT_IS_DATASET/GMT_IS_MATRIX/GMT_IS_VECTOR, addingGMT_WITH_STRINGSto themodewill allocate the corresponding arrays of string pointers.dim (
Sequence[int] |None, default:None) – The dimensions of the dataset, as explained above. IfNone, will pass in the NULL pointer.ranges (
Sequence[float] |None, default:None) – The data extent.inc (
Sequence[float] |None, default:None) – The increments between points of the dataset.registration (
Literal['GMT_GRID_NODE_REG','GMT_GRID_PIXEL_REG'], default:'GMT_GRID_NODE_REG') – The node registration. Can be"GMT_GRID_PIXEL_REG"or"GMT_GRID_NODE_REG".pad (
int|None, default:None) –The padding for
GMT_IS_GRID/GMT_IS_IMAGE/GMT_IS_CUBE. IfNone, defaults to"GMT_PAD_DEFAULT".For
GMT_IS_MATRIX, it can be:0: default row/col orientation [Default]
1: row-major format (C)
2: column-major format (FORTRAN)
- Return type:
- Returns:
data_ptr – A ctypes pointer (an integer) to the allocated GMT data container.