WDF File I/O / WDFファイル入出力¶
The generated save and load docstrings are the public WDF API contract.
They describe typed Frame data, metadata, and lazy-load behavior. WDF stores a
concrete Frame result, not a replayable Recipe; use the
Recipe How-to when the artifact should replay
operations on another input. Saving and loading WDF need the io extra
(pip install "wandas[io]").
生成されたsave/load docstringが、公開WDF API契約の正本です。具体的なFrame結果を保存する
WDFと、別入力へ処理を再実行するRecipeの使い分けはRecipe How-to
を参照してください。WDFの保存と読み込みにはio extra(pip install "wandas[io]")が必要です。
wandas/io/の実装不変条件はI/O Contractsで管理します。
wandas.io.wdf_io.save(frame, path, *, compress='gzip', overwrite=False)
¶
Save an exact built-in Frame as WDF 0.4, 0.5 or sparse 0.6.
A time-frequency Frame with a known physical frame origin uses WDF 0.5. Sparse time-frequency results use WDF 0.6 with explicit sparse state. All other Frames retain WDF 0.4. Older readers reject new versions explicitly; this preserves placement instead of silently discarding its additional state.
The artifact retains the Frame label, user metadata, channel labels and
metadata (units, references, calibration, and channel extras), source-time
offsets, analysis coordinates, and the derived operation_history view.
Metadata fields use strict JSON encoding and therefore follow JSON value
semantics (for example, a tuple is loaded as a list).
It stores the concrete Frame result; previous references and replayable
Recipe intent are not persisted.
Dask data is handed directly to xarray and is written synchronously; Wandas does
not first materialize the complete tensor with frame._data.compute().
The frame is written to a temporary file first, so a failure while computing
or writing it leaves an existing file unchanged and creates no partial file.
A new file is then moved into place. An existing file is overwritten in place
by copying the finished temporary file into it, so it keeps its hard links,
owner, group, permission bits and ACLs, and a symlinked path updates the file
it points to. Overwriting a file that is not writable, or an HDF5 file that is
open or locked, raises OSError before anything is computed. An
interruption of that final copy (for example a full disk or a power loss), or
another process opening the file between that check and the copy, can still
leave the existing file incomplete.
Saving needs the io extra (pip install "wandas[io]"); without it,
ImportError names that install command.
Source code in wandas/io/wdf_io.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
wandas.io.wdf_io.load(path)
¶
Load a local WDF 0.4, 0.5 or 0.6 artifact as its exact built-in Frame type.
WDF 0.4 time-frequency Frames have unknown physical center times; their existing zero-based time axes remain available. WDF 0.5 restores the explicit physical origin without inferring it from history. WDF 0.6 also restores the sparse-window permission, retaining gaps in the time axis.
The returned Frame restores the saved label, user metadata, channel labels
and metadata (units, references, calibration, and channel extras),
source-time offsets, analysis coordinates, and derived
operation_history view. Metadata follows strict JSON value semantics;
for example, a tuple saved in metadata is loaded as a list. WDF does not
restore a previous reference or replayable Recipe intent.
The returned Frame owns access to its source internally. Keep the source path
unchanged while that Frame or Frames derived from it are in use. Obtain NumPy
values through frame.data without managing the storage backend directly.
Loading needs the io extra (pip install "wandas[io]"); without it,
ImportError names that install command.
Source code in wandas/io/wdf_io.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | |