sdynpy.core.sdynpy_coordinate.CoordinateArray
- class CoordinateArray(shape, buffer=None, offset=0, strides=None, order=None)[source]
Bases:
SdynpyArrayCoordinate information specifying Degrees of Freedom (e.g. 101X+).
Use the coordinate_array helper function to create the array.
- __init__()
Methods
abs()Returns a coordinate array with direction signs flipped positive
Returns a string array representation of the direction
find_indices(coordinate)Finds the indices and signs of the specified coordinates
from_matlab_cellstr(cellstr_data)Creates a CoordinateArray from a matlab cellstring object loaded from scipy.io.loadmat
from_nodelist(nodes[, directions, flatten])Returns a coordinate array with a set of nodes with a set of directions
Returns a local direction array
offset_node_ids(offset_value)Returns a copy of the CoordinateArray with the node IDs offset
sign()Returns the sign on the directions of the CoordinateArray
Returns a string array representation of the coordinate array
Attributes
Datatype for the underlying numpy structured array
- data_dtype = [('node', 'uint64'), ('direction', 'int8')]
Datatype for the underlying numpy structured array
- direction_string_array()[source]
Returns a string array representation of the direction
- Returns
ndarray of direction strings representing the CoordinateArray
- Return type
np.ndarray
- find_indices(coordinate)[source]
Finds the indices and signs of the specified coordinates
- Parameters
coordinate (CoordinateArray) – A CoordinateArray containing the coordinates to find.
- Returns
indices (tuple of ndarray) – An tuple of arrays of indices into this CoordinateArray for each entry in coordinate, which can be used directly to index this CoordinateArray.
signs (ndarray) – An array of sign flips between this CoordinateArray at the indices in indices for each entry in coordinate
- Raises
ValueError – If more than one coordinate matches, or no coordinate matches.
- classmethod from_matlab_cellstr(cellstr_data)[source]
Creates a CoordinateArray from a matlab cellstring object loaded from scipy.io.loadmat
- Parameters
cellstr_data (np.ndarray) – Dictionary entry corresponding to a cell string variable in a mat file loaded from scipy.io.loadmat
- Returns
CoordinateArray built from the provided cell string array
- Return type
- classmethod from_nodelist(nodes, directions=[1, 2, 3], flatten=True)[source]
Returns a coordinate array with a set of nodes with a set of directions
- Parameters
nodes (iterable) – A list of nodes to create degrees of freedom at
directions (iterable, optional) – A list of directions to create for each node. The default is [1,2,3], which provides the three positive translations (X+, Y+, Z+).
flatten (bool, optional) – Specifies that the array should be flattened prior to output. The default is True. If False, the output will have a dimension one larger than the input node list due to the added direction dimension.
- Returns
coordinate_array – Array of coordinates with each specified direction defined at each node. If flatten is false, this array will have shape nodes.shape + directions.shape. Otherwise, this array will have shape (nodes.size*directions.size,)
- Return type
- local_direction()[source]
Returns a local direction array
- Returns
local_direction_array – Returns a (…,3) array where … is the dimension of the CoordinateArray. The (…,0), (…,1), and (…,2) indices represent the x,y,z direction of the local coordinate direction. For example, a CoordinateArray with direction X- would return [-1,0,0].
- Return type
np.ndarray