pencil.read.pstalk2

Classes

Struct

Simple dict-like container with attribute (dot) access.

Functions

pstalk2([datadir, it0, it1, swap_endian, quiet, ...])

Read Pencil Code particle stalker data (PSTALK) and return a Struct with

Module Contents

class pencil.read.pstalk2.Struct

Bases: dict

Simple dict-like container with attribute (dot) access.

Initialize self. See help(type(self)) for accurate signature.

pencil.read.pstalk2.pstalk2(datadir='data', it0=0, it1=-1, swap_endian=False, quiet=False, noutmax=None, single=False, nstalk=None, ipar=None, read_last=False)

Read Pencil Code particle stalker data (PSTALK) and return a Struct with dot-access fields:

fs.t : (nout,) fs.ipar : (nstalk,) fs.<field>: (nstalk, nout) for each field in particles_stalker_header.dat

Parameters:
  • datadir (str) – Base data directory (e.g. “data”). ~ expansion is supported.

  • it0 (int) – First time index to read (inclusive).

  • it1 (int) – If >0, print a log line whenever it % it1 == 0.

  • swap_endian (bool) – If True, swap endianness when reading the binary PSTALK files.

  • quiet (bool) – If True, suppress most logging.

  • noutmax (int or None) – Maximum number of output times to read. None => use all available. Semantics match IDL: min(noutmax, noutmaxfile), with -1 meaning “all”.

  • single (bool) – If True, store output data in float32; otherwise float64. (Binary precision is auto-detected and then cast.)

  • nstalk (int or None) – Max number of stalked particles to keep. Defaults to pdim.npar_stalk. In non-sink mode, particles with index >= nstalk are ignored. In sink-particle mode, nstalk may be increased internally if needed.

  • ipar (int or list of int or None) – If given, read only these particle indices (memory-efficient).

  • read_last (bool) – If True, read only the last timestep (overrides it0)

Returns:

fs – Container with fields t, ipar, and one field per stalk quantity.

Return type:

Struct