Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData

Signature

class sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData(sample_rate: 'int', time_data: 'np.ndarray', channel_table: 'pd.DataFrame', file_version: 'str' = None, time_per_write: 'float' = None, time_per_read: 'float' = None, hardware: 'int' = None, hardware_file: 'str' = None, output_oversample: 'int' = None, task_trigger: 'int' = None, task_trigger_output_channel: 'str' = None, environment_names: 'list | np.ndarray' = [], environment_active_channels: 'list | np.ndarray' = [], environments: 'dict[str, RattlesnakeRandomEnvironmentData]' = {}, **kwargs)

Top-level container for all data read from a Rattlesnake nc4 file.

Provides the global channel table, per-environment data objects, and convenience methods for assembling sdynpy array objects directly from the file data.

Instances are normally created via :meth:read_rattlesnake_nc4 rather than by calling the constructor directly.

Parameters

Attributes

NameSummary
coordinateCoordinate array for all physical channels.
excitation_coordinateCoordinate array for excitation (drive) channels.
response_coordinateCoordinate array for response (non-excitation) channels.

coordinate

Coordinate array for all physical channels.

Builds a CoordinateArray from the node_number and node_direction columns of the channel table.

Returns

excitation_coordinate

Coordinate array for excitation (drive) channels.

Selects channels whose feedback_channel entry in the channel table is non-empty, which identifies them as drive/excitation channels.

Returns

response_coordinate

Coordinate array for response (non-excitation) channels.

Returns all channel coordinates that are not present in :attr:excitation_coordinate.

Returns

Methods

NameSummary
__init__Store all data parameters as instance attributes.
get_coordinateCoordinate array for all channels, optionally including virtual channels.
get_time_dataBuild TimeHistoryArray objects from the source nc4 file data.
read_rattlesnake_nc4Read a Rattlesnake nc4 file and return a populated data object.
unitsEngineering-unit label for each channel, optionally including virtual channels.

__init__

def sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData.__init__(self, sample_rate: 'int', time_data: 'np.ndarray', channel_table: 'pd.DataFrame', file_version: 'str' = None, time_per_write: 'float' = None, time_per_read: 'float' = None, hardware: 'int' = None, hardware_file: 'str' = None, output_oversample: 'int' = None, task_trigger: 'int' = None, task_trigger_output_channel: 'str' = None, environment_names: 'list | np.ndarray' = [], environment_active_channels: 'list | np.ndarray' = [], environments: 'dict[str, RattlesnakeRandomEnvironmentData]' = {}, **kwargs)

Store all data parameters as instance attributes.

Every named parameter is assigned directly to self. Any additional keyword arguments (extra global nc4 attributes or variables) are stored via __setattr__. See the class docstring for parameter descriptions.

get_coordinate

def sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData.get_coordinate(self, env_name: 'str' = None) -> 'CoordinateArray'

Coordinate array for all channels, optionally including virtual channels.

Parameters

Returns

get_time_data

def sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData.get_time_data(self, index: 'int | None' = None, env_name: 'str' = None) -> 'TimeHistoryArray | list[TimeHistoryArray]'

Build TimeHistoryArray objects from the source nc4 file data.

Iterates over all time_data variables found on this data object (populated by :meth:read_rattlesnake_nc4), converts each to a TimeHistoryArray, and optionally applies a response transformation matrix to produce virtual channel time histories which are appended to the array.

Parameters

Returns

read_rattlesnake_nc4

def sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData.read_rattlesnake_nc4(cls, filename: 'os.PathLike | nc4.Dataset')

Read a Rattlesnake nc4 file and return a populated data object.

Loads global nc4 attributes, global variables (including all time_data* streams), the channel table, and each environment group into a new RattlesnakeData instance. Each environment group is tried against every class in _ENV_CLASSES (currently only :class:RattlesnakeRandomEnvironmentData); the first class that loads without error wins.

Parameters

Returns

Raises

units

def sdynpy.fileio.sdynpy_rattlesnake.RattlesnakeData.units(self, env_name: 'str' = None) -> 'np.ndarray'

Engineering-unit label for each channel, optionally including virtual channels.

Reads the unit column of the channel table. When env_name is provided and the named environment contains a response_transformation_matrix, the array is zero-padded (empty string '') for each virtual transformed channel.

Parameters

Returns