Modern I/O¶
Zarr v3 for field data, Parquet/Arrow for particle data, and Icechunk for
versioned storage. Every backend here is optional — each sits behind its own
extra and raises an install hint rather than an ImportError traceback when
the dependency is missing.
| Entry point | Extra | Purpose |
|---|---|---|
to_zarr / from_zarr |
zarr |
Single-step field store, Zarr v3 |
to_zarr_timeseries |
zarr |
Multi-step store with a leading time dimension |
open_virtual |
zarr |
VirtualiZarr view over existing HDF5, no conversion |
to_icechunk_virtual, open_icechunk_repo, icechunk_create_tag, icechunk_ancestry |
icechunk |
Git-like versioning and ACID commits over Zarr v3 |
particles_to_arrow / particles_from_arrow |
arrow |
In-memory ParticleData ↔ Arrow table |
particles_to_parquet / particles_from_parquet |
arrow |
Single-file particle round-trip |
particles_to_dataset / particles_from_dataset |
arrow |
Hive-partitioned dataset, by step and species |
query_sql |
duckdb |
SQL over particle Parquet, with spatial pushdown |
The on-disk layouts are specified in Schema § 4:
§ 4.2 for the Zarr store this module writes, § 4.3 for the Parquet particle
layout. Within each Parquet partition, rows are Morton-ordered over (x, y, z)
so row-group statistics support spatial predicate pushdown.
io
¶
Zarr v3, Parquet/Arrow, virtual HDF5, and Icechunk I/O for pypic.
Field data: to_zarr / from_zarr / to_zarr_timeseries (Zarr v3),
open_virtual (VirtualiZarr), Icechunk versioning.
Particle data: particles_to_arrow / particles_from_arrow (Arrow),
particles_to_parquet / particles_from_parquet (single-file Parquet),
particles_to_dataset / particles_from_dataset (partitioned Parquet),
query_sql (DuckDB over Parquet).
Optional dependencies per feature:
pip install "pypic-plasma[zarr]" — Zarr v3, VirtualiZarr
pip install "pypic-plasma[icechunk]" — Icechunk versioned storage
pip install "pypic-plasma[arrow]" — Arrow/Parquet particle I/O
pip install "pypic-plasma[duckdb]" — DuckDB SQL queries
particles_from_arrow(table)
¶
Reconstruct a ParticleData from a PyArrow Table.
Expects the column layout produced by particles_to_arrow.
Species metadata is read from table.schema.metadata[b"pypic"].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
|
required |
Returns:
| Type | Description |
|---|---|
ParticleData
|
|
Examples:
>>> import numpy as np
>>> from pypic.containers import ParticleData
>>> pcl = ParticleData(
... species_index=0, species_name="electrons",
... position=np.zeros((5, 3)), velocity=np.ones((5, 3)),
... n_particles=5, metadata={},
... weight=np.ones(5), species_charge=-1.0, species_mass=1.0,
... )
>>> back = particles_from_arrow(particles_to_arrow(pcl))
>>> (back.n_particles, back.species_charge, back.species_mass)
(5, -1.0, 1.0)
Source code in src/pypic/io/_arrow.py
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
particles_to_arrow(data, *, position_dtype=None, velocity_dtype=None)
¶
Convert a ParticleData to a PyArrow Table.
Column layout: x, y, z, vx, vy, vz,
weight, id. Columns for unloaded fields (e.g. velocity
when data.velocity is None) are omitted. Scalar
species_charge/species_mass travel in schema metadata.
Species metadata is stored in table.schema.metadata[b"pypic"]
as a JSON dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ParticleData
|
Source particle data. |
required |
position_dtype
|
str or None
|
Downcast position columns (e.g. |
None
|
velocity_dtype
|
str or None
|
Downcast velocity columns (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
Table
|
|
Examples:
>>> import numpy as np
>>> from pypic.containers import ParticleData
>>> pcl = ParticleData(
... species_index=0, species_name="electrons",
... position=np.zeros((5, 3)), velocity=np.ones((5, 3)),
... n_particles=5, metadata={},
... weight=np.ones(5), species_charge=-1.0, species_mass=1.0,
... )
>>> table = particles_to_arrow(pcl)
>>> table.num_rows
5
Source code in src/pypic/io/_arrow.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
query_sql(path, sql, *, return_type='particledata')
¶
Execute SQL over a partitioned particle Parquet dataset via DuckDB.
The dataset is available in the query as the particles view.
DuckDB automatically handles Hive partition discovery, predicate
pushdown, and parallel scanning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Root directory of the partitioned Parquet dataset. |
required |
sql
|
str
|
SQL query. The dataset is available as |
required |
return_type
|
str
|
|
'particledata'
|
Returns:
| Type | Description |
|---|---|
ParticleData or Table
|
|
See Also
pypic.io.particles_to_dataset : Writes the partitioned dataset this queries.
Source code in src/pypic/io/_duckdb.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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 | |
icechunk_ancestry(path, *, branch='main')
¶
Return the commit history of an Icechunk repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the Icechunk repository. |
required |
branch
|
str
|
Branch whose ancestry to inspect. |
'main'
|
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
List of |
Source code in src/pypic/io/_icechunk.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
icechunk_create_tag(path, tag, *, snapshot_id=None, branch='main')
¶
Create a named tag in an Icechunk repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the Icechunk repository. |
required |
tag
|
str
|
Tag name (e.g. |
required |
snapshot_id
|
str or None
|
Snapshot to tag. Defaults to the tip of branch. |
None
|
branch
|
str
|
Branch whose tip to tag (ignored when snapshot_id is given). |
'main'
|
Source code in src/pypic/io/_icechunk.py
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 | |
open_icechunk_repo(path, *, create=False, authorize_virtual_chunk_access=None)
¶
Open (or create) a local Icechunk repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Directory for the repository. |
required |
create
|
bool
|
When |
False
|
authorize_virtual_chunk_access
|
dict or None
|
Mapping of URL prefix → credentials ( |
None
|
Returns:
| Type | Description |
|---|---|
Repository
|
The repository handle. |
Source code in src/pypic/io/_icechunk.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
particles_from_dataset(path, *, step=None, species=None, spatial_box=None, ids=None, id_column='id', energy_min=None, columns=None)
¶
Read from a partitioned Parquet dataset with selective loading.
Uses pyarrow.dataset with Hive partitioning for partition
pruning (step, species) and Parquet row-group statistics for
predicate pushdown (spatial box, energy threshold, IDs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Root directory of the partitioned dataset. |
required |
step
|
int or None
|
Timestep to load (partition pruning). |
None
|
species
|
str or int or None
|
Species name or index (partition pruning). |
None
|
spatial_box
|
tuple or None
|
|
None
|
ids
|
array or Sequence or None
|
Values to filter on against |
None
|
id_column
|
str
|
Column name to filter |
'id'
|
energy_min
|
float or None
|
Minimum speed |
None
|
columns
|
Sequence[str] or None
|
Column names to load (e.g. |
None
|
Returns:
| Type | Description |
|---|---|
ParticleData
|
|
See Also
particles_to_dataset : The writer this reverses.
Source code in src/pypic/io/_parquet.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | |
particles_from_parquet(path)
¶
Read a single Parquet file into a ParticleData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the |
required |
Returns:
| Type | Description |
|---|---|
ParticleData
|
|
See Also
particles_to_parquet : The writer this reverses.
Source code in src/pypic/io/_parquet.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
particles_to_dataset(source, path, *, steps=None, species=None, position_dtype=None, velocity_dtype=None, compression_level=1, row_group_size=_DEFAULT_ROW_GROUP_SIZE, sort_by='position')
¶
Write a partitioned Parquet dataset from a Simulation or iterable.
Layout::
{path}/step=000000/species=electrons/part-00000.parquet
{path}/step=000000/species=ions/part-00000.parquet
{path}/step=000100/species=electrons/part-00000.parquet
...
When an iterable source yields multiple ParticleData chunks
for the same (step, species) (streaming pipelines), each chunk
is written to a fresh part-NNNNN.parquet within the partition
directory rather than overwriting the previous one. Existing
part-*.parquet files in the destination are preserved and the
counter resumes from the next free index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Simulation or Iterable[tuple[int, str, ParticleData]]
|
Either a |
required |
path
|
str or Path
|
Root directory for the partitioned dataset. |
required |
steps
|
Sequence[int] or None
|
Timestep indices to write (Simulation source only). Defaults to all particle steps. |
None
|
species
|
Sequence[int | str] or None
|
Species indices or names (Simulation source only). Defaults to all species. |
None
|
position_dtype
|
str or None
|
Downcast options. |
None
|
velocity_dtype
|
str or None
|
Downcast options. |
None
|
compression_level
|
int
|
zstd level (1 for processing, 3 for archival). |
1
|
row_group_size
|
int
|
Target rows per row group. |
_DEFAULT_ROW_GROUP_SIZE
|
sort_by
|
('position', 'weight')
|
Pre-write sort order; forwarded to |
"position"
|
Notes
Accepts either a Simulation or an iterable of
(step, species, ParticleData) triples, so custom pipelines can
feed it directly::
pairs = [(0, "electrons", pcl_e), (0, "ions", pcl_i)]
particles_to_dataset(pairs, out_dir)
See Also
particles_from_dataset : Reads back one partition.
Source code in src/pypic/io/_parquet.py
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 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
particles_to_parquet(data, path, *, position_dtype=None, velocity_dtype=None, compression_level=1, row_group_size=_DEFAULT_ROW_GROUP_SIZE, sort_by='position')
¶
Write a single ParticleData to a Parquet file.
Particles are sorted before writing so that Parquet row-group
min/max statistics enable predicate pushdown on read. The default
sort_by="position" uses a Morton Z-order curve, optimal for
spatial box queries. Use sort_by="weight" when weight serves
as the per-particle tracking ID (iPIC3D non-uniform plasma, where
each macroparticle's float64 weight is unique); spatial queries
become slower in return.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ParticleData
|
Source particle data (single species, single timestep). |
required |
path
|
str or Path
|
Destination |
required |
position_dtype
|
str or None
|
Downcast position columns (e.g. |
None
|
velocity_dtype
|
str or None
|
Downcast velocity columns (e.g. |
None
|
compression_level
|
int
|
zstd compression level (1 for processing, 3 for archival). |
1
|
row_group_size
|
int
|
Target rows per row group (500K--1M recommended). |
_DEFAULT_ROW_GROUP_SIZE
|
sort_by
|
('position', 'weight')
|
Pre-write sort order. |
"position"
|
Examples:
>>> import numpy as np
>>> from pypic.containers import ParticleData
>>> pcl = ParticleData(
... species_index=0, species_name="e",
... position=np.zeros((5, 3)), velocity=np.ones((5, 3)),
... n_particles=5, metadata={},
... weight=np.ones(5), species_charge=-1.0, species_mass=1.0,
... )
>>> import tempfile
>>> from pathlib import Path
>>> with tempfile.TemporaryDirectory() as tmp:
... out = Path(tmp) / "pcl.parquet"
... particles_to_parquet(pcl, out)
... particles_from_parquet(out).n_particles
5
Source code in src/pypic/io/_parquet.py
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
open_virtual(path, *, fields_group='fields', drop_variables=None, config=None)
¶
Create a virtual FieldDataset backed by HDF5 byte ranges.
Uses VirtualiZarr to extract byte-range metadata from an HDF5
file, producing a FieldDataset that lazily reads field data
from the original file without copying.
For files following the pypic canonical HDF5 layout (schema.md
Section 4), grid and normalization metadata are read automatically
from the grid/ and normalization/ groups. For other
layouts, pass a config with the required metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the HDF5 file. |
required |
fields_group
|
str or None
|
HDF5 group containing field datasets. |
'fields'
|
drop_variables
|
list[str] or None
|
HDF5 dataset names to exclude from the virtual view. |
None
|
config
|
SimulationConfig or None
|
Explicit metadata. When provided, overrides any metadata found in the HDF5 file. |
None
|
Returns:
| Type | Description |
|---|---|
FieldDataset
|
A lazy-loading dataset backed by virtual references to the original HDF5 file. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If grid metadata cannot be determined from the file or config. |
ImportError
|
If |
Notes
Virtual references are persisted via Icechunk's native Zarr v3
backend (in-memory store). Both virtualizarr and icechunk
are installed by the zarr extra (pip install "pypic-plasma[zarr]").
Source code in src/pypic/io/_virtual.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
to_icechunk_virtual(source, output, *, fields_group='fields', drop_variables=None, config=None, message=None, branch='main')
¶
Persist HDF5 byte-range references to an Icechunk repository.
Writes the virtual references for source's field datasets to a
persistent on-disk Icechunk repo at output and attaches pypic
metadata as group attrs. Subsequent reads via from_zarr(output)
resolve chunks by reading byte ranges from source — no field
data is copied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or Path
|
Path to the source HDF5 file. |
required |
output
|
str or Path
|
Destination directory for the Icechunk repository. |
required |
fields_group
|
str or None
|
HDF5 group containing field datasets ( |
'fields'
|
drop_variables
|
list[str] or None
|
HDF5 dataset names to exclude from the virtual view. |
None
|
config
|
SimulationConfig or None
|
Explicit metadata. When provided, overrides any metadata found in the HDF5 file. |
None
|
message
|
str or None
|
Icechunk commit message. Defaults to a generated string. |
None
|
branch
|
str
|
Branch to commit to. Defaults to |
'main'
|
Returns:
| Type | Description |
|---|---|
str
|
The Icechunk snapshot ID of the new commit. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
ValueError
|
If grid metadata cannot be determined from source or config. |
Notes
Both virtualizarr and icechunk are installed by the
zarr extra (pip install "pypic-plasma[zarr]"). Moving or deleting
source after the write breaks the virtual refs in output — the
on-disk repo is metadata only.
Source code in src/pypic/io/_virtual.py
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 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
from_zarr(path, *, branch=None, tag=None, snapshot_id=None)
¶
Read a FieldDataset from a Zarr v3 store.
Returns a lazy-loading dataset by default — field arrays are read from disk on first access. Icechunk repositories are auto-detected; pass branch, tag, or snapshot_id to read a specific version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to the Zarr store directory (or Icechunk repository). |
required |
branch
|
str or None
|
Icechunk branch to read from. |
None
|
tag
|
str or None
|
Icechunk tag to read from. |
None
|
snapshot_id
|
str or None
|
Icechunk snapshot ID to read from. |
None
|
Returns:
| Type | Description |
|---|---|
FieldDataset
|
Reconstructed dataset with full metadata. |
See Also
to_zarr : The writer this reverses.
Source code in src/pypic/io/zarr.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
to_zarr(fds, path, *, dtype=None, encoding=None, backend=None, message=None, branch='main', simulation_toml=None)
¶
Write a FieldDataset to a Zarr v3 store.
All pypic metadata (grid, normalization, species, physics, frame,
transforms) is serialized as flat keys on the root group's attrs
alongside a schema.version discriminator (see schema.md §4.2),
so that from_zarr — and any non-pypic consumer — can
reconstruct the full object straight from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fds
|
FieldDataset
|
The dataset to write. |
required |
path
|
str or Path
|
Destination directory (created if it does not exist). |
required |
dtype
|
str or None
|
When set (e.g. |
None
|
encoding
|
dict or None
|
Per-variable encoding overrides merged on top of the defaults
(Blosc zstd + bitshuffle). Keys are variable names, values
are dicts passed to |
None
|
backend
|
str or None
|
Storage backend. |
None
|
message
|
str or None
|
Commit message (Icechunk only). |
None
|
branch
|
str
|
Branch to commit to (Icechunk only). Default |
'main'
|
simulation_toml
|
str or Path or None
|
Source |
None
|
Returns:
| Type | Description |
|---|---|
str or None
|
Snapshot ID when |
Examples:
>>> import numpy as np
>>> from pypic.dataset import FieldDataset
>>> from pypic.grid import GridInfo
>>> from pypic.units import Normalization
>>> grid = GridInfo(dimensions=(4, 3, 2), spacing=(1.0, 1.0, 1.0))
>>> fds = FieldDataset.from_arrays(
... {"B_1": np.ones((4, 3, 2))}, grid, Normalization.identity(),
... )
>>> import tempfile
>>> from pathlib import Path
>>> with tempfile.TemporaryDirectory() as tmp:
... store = Path(tmp) / "test.zarr"
... to_zarr(fds, store)
... sorted(from_zarr(store).field_names())
['B_1']
Source code in src/pypic/io/zarr.py
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 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
to_zarr_timeseries(source, path, *, steps=None, fields=None, dtype=None, encoding=None, backend=None, message=None, branch='main', simulation_toml=None)
¶
Write multiple timesteps to a single Zarr v3 store.
Each field becomes (nt, n1, n2, n3) with time as the first
dimension, chunked so that reading one timestep is O(1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Simulation or Iterable[tuple[float | int, FieldDataset]]
|
Either a |
required |
path
|
str or Path
|
Destination Zarr store directory. |
required |
steps
|
Sequence[int] or None
|
Timestep indices to write (only used when source is a
|
None
|
fields
|
Sequence[str] or None
|
Field names to include (only used when source is a
|
None
|
dtype
|
str or None
|
Downcast dtype (e.g. |
None
|
encoding
|
dict or None
|
Per-variable encoding overrides. |
None
|
backend
|
str or None
|
Storage backend. |
None
|
message
|
str or None
|
Commit message (Icechunk only). |
None
|
branch
|
str
|
Branch to commit to (Icechunk only). Default |
'main'
|
simulation_toml
|
str or Path or None
|
Source |
None
|
Returns:
| Type | Description |
|---|---|
str or None
|
Snapshot ID when |
Examples:
>>> import numpy as np
>>> from pypic.dataset import FieldDataset
>>> from pypic.grid import GridInfo
>>> from pypic.units import Normalization
>>> grid = GridInfo(dimensions=(4, 3), spacing=(1.0, 1.0))
>>> pairs = [
... (0.0, FieldDataset.from_arrays(
... {"B_1": np.ones((4, 3))}, grid, Normalization.identity())),
... (1.0, FieldDataset.from_arrays(
... {"B_1": np.ones((4, 3)) * 2}, grid, Normalization.identity())),
... ]
>>> import tempfile
>>> from pathlib import Path
>>> with tempfile.TemporaryDirectory() as tmp:
... store = Path(tmp) / "ts.zarr"
... to_zarr_timeseries(pairs, store)
... from_zarr(store).xr.sizes["time"]
2
Source code in src/pypic/io/zarr.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |