visualdynamics.io.rattlesnake¶
rattlesnake
¶
Importer for Rattlesnake vibration controller output files (.nc4).
Rattlesnake streams results to netCDF4 with a channel table that includes engineering units (read in whatever case they were typed), so imports are fully unit-aware — no unit declaration needed. Layout (file_version 3.x):
- root attrs: sample_rate, hardware, file_version, ...
- time_data (response_channels, time_samples), in channel engineering units
- channels group: node_number, node_direction, unit, channel_type, and other per-channel metadata
- one group per environment (e.g. 'Random') that may carry a specification CPSD matrix (specification_frequency_lines, specification_cpsd_matrix_*) and the bands around it (specification_warning_matrix, specification_abort_matrix, each (2, lines, channels), lower first)
A run saves twice and the two files share nothing: streaming writes the time histories, and a separate save writes what the environment computed from them. Both are read here.
Returns a dict: 'channel_table' -> ChannelTable, and whichever of these the
file holds — 'time_data' -> TimeHistory, '
A modal environment counts every enabled channel as a response and never excludes its references, so the drives appear among them and the saved matrix carries each drive against the drives. Those rows are identity and cross-talk by construction — |H| exactly 1 against itself, numerically zero against the other, coherence exactly 1 — so they are dropped: they are arithmetic rather than measurement, and would put a force-per-force axis on the plot beside the real one.
A spectral file carries neither time data nor, once rattlesnake's own random save has been through it, the root attributes — so the sample rate may be missing and the frequency axis has to come from the specification's own lines. The noise cross spectra a random save also writes are deliberately left alone: they describe the measurement's noise floor and would double the object count for something rarely looked at.
Reading only, and deliberately: a .nc4 records a controller run — hardware
settings, environments, the lot — that visualdynamics does not hold, so a file written
from here would describe a test that never happened. See docs/export.md.
Functions:
| Name | Description |
|---|---|
machine_memory |
The machine's physical memory in bytes, or 0 when it cannot be asked. |
last_window |
Where a window of the last |
stream_summary |
What a run's streams would cost to import, read without reading one. |
stream_preview |
One channel's envelope over a whole stream, read in slabs. |
environment_kinds |
{environment name: kind} the file says it holds. |
run_kind |
What kind of test the file holds, by its own account. |
project_type |
The visualdynamics project this file is a run of, or None if visualdynamics has no |
streamed_sysid_candidate |
Whether a streamed save has the shape a system ID leaves: |
load |
Everything a Rattlesnake |
Classes¶
Functions:¶
machine_memory
¶
The machine's physical memory in bytes, or 0 when it cannot be asked.
The one system question this package asks: whether a stream about
to be imported would take a large share of it. POSIX answers
through sysconf; Windows through GlobalMemoryStatusEx.
Source code in src/visualdynamics/io/rattlesnake.py
last_window
¶
Where a window of the last last seconds of a run opens.
The one rule behind the import dialog's Last field and a
script's last= (Brandon, 2026-09-19): a run seconds long is
read from seconds - last to its end — and a run no longer than
that is taken whole, which is what None says. Asking for the last
100 s of a 28 s run is not a mistake to refuse; it is all of it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seconds
|
float
|
The instant of the run's last sample on its own clock. |
required |
last
|
float
|
How many seconds before the end the window opens; positive. |
required |
Returns:
| Type | Description |
|---|---|
float or None
|
The |
Source code in src/visualdynamics/io/rattlesnake.py
stream_summary
¶
What a run's streams would cost to import, read without reading one.
The import dialog's first question — is this stream a large share of the machine? — answered from the file's dimensions alone, so asking it costs nothing on a 22 GB run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
A Rattlesnake |
required |
Returns:
| Type | Description |
|---|---|
dict
|
'sample_rate'; 'channels', the table's coordinates in row
order; 'units', their units as the file spells them;
'streams', one dict per stream with 'key' (the name the
import gives it), 'variable', 'channels', 'samples',
'seconds' and 'bytes' (as float64, what the import holds);
'memory', |
Source code in src/visualdynamics/io/rattlesnake.py
stream_preview
¶
stream_preview(path: str | PathLike, channel: int | str = 0, stream: str = 'time_data', points: int = PREVIEW_POINTS) -> dict[str, Any]
One channel's envelope over a whole stream, read in slabs.
The picture an import window is chosen from: where the run
reaches level, where it stops, the false start at the front. Each
of points buckets keeps its least and greatest sample — the
stage's peak thinning, applied as the channel is read — so the
preview of a 22 GB run holds a slab at a time and comes back as a
few thousand points. The file's chunks run along one channel at a
time, so one channel is a sequential read of its own bytes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
A Rattlesnake |
required |
channel
|
int or str
|
The channel's row in the table, or its coordinate ('101Z+'). |
0
|
stream
|
str
|
Which stream variable ('time_data', 'time_data_1', …). |
'time_data'
|
points
|
int
|
How many buckets to thin to. |
PREVIEW_POINTS
|
Returns:
| Type | Description |
|---|---|
dict
|
'times', the bucket centers in seconds on the run's clock; 'low' and 'high', each bucket's least and greatest value as the file holds them, NaN where a bucket holds nothing else; 'dof', 'unit', 'dim' of the channel; and 'samples', 'sample_rate' of the stream. |
Source code in src/visualdynamics/io/rattlesnake.py
environment_kinds
¶
{environment name: kind} the file says it holds.
Empty for a file that does not say — an nc4 assembled by hand, or an older save from before the controller wrote its types down.
Source code in src/visualdynamics/io/rattlesnake.py
run_kind
¶
What kind of test the file holds, by its own account.
'modal', 'random', 'transient', 'sine' or 'time' for a run of one kind; 'mixed' when more than one environment drove the article at once, which is what a random-plus-sine-sweep run is; None when the file does not say.
Source code in src/visualdynamics/io/rattlesnake.py
project_type
¶
The visualdynamics project this file is a run of, or None if visualdynamics has no project of that kind — or the file never said what kind it was.
A mixed run answers with its leading half (MIXED_PRECEDENCE):
every environment's specification imports regardless, so the type
only chooses which workflow the tree leads with.
Source code in src/visualdynamics/io/rattlesnake.py
streamed_sysid_candidate
¶
Whether a streamed save has the shape a system ID leaves: exactly two streams, a quiet one then a loud one — the ambient measurement and the driven excitation.
The file itself cannot settle the question (a run of the environment that stopped and restarted its stream once looks the same on paper), so this is grounds to ask the person, never to decide. The quiet-then-loud check is what keeps the question from being asked about every two-stream file: a restarted run's halves play at one level, a system ID's differ by the whole test. Ten decibels is well under any real ambient-to-driven gap and well over a level change within one run.
Source code in src/visualdynamics/io/rattlesnake.py
load
¶
load(path: str | PathLike, full_cpsd: bool = False, start: float | None = None, stop: float | None = None, channels: Iterable[int | str] | None = None) -> dict[str, Any]
Everything a Rattlesnake .nc4 holds, keyed the way the tree names it.
The streamed time data, the channel table, and each environment's
specification, FRF, coherence and spectra; a saved system-ID
package on its own. start, stop and channels import a part
of the streams — the window a long run is read through when the
whole would not fit the machine (the import dialog asks; a script
says). The window is inclusive at both instants on the run's own
clock, which the records keep, and a stream the window misses
entirely is left out. A part is a recording, so a windowed stream
is not split into a spectral save's frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
The file. |
required |
full_cpsd
|
bool
|
Import every cross term of the environment's CPSDs, not only the autos. |
False
|
start
|
float
|
The window in seconds; either end open when omitted. |
None
|
stop
|
float
|
The window in seconds; either end open when omitted. |
None
|
channels
|
iterable of int or str
|
Which channels of the streams to import, by table row or by coordinate ('101Z+'). All of them when omitted. An environment's virtual responses come along only when every control channel they are computed from is among them. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Objects by key: 'time_data' (and 'time_data_2', …),
'channel_table', and ' |
Source code in src/visualdynamics/io/rattlesnake.py
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | |