pencil.read.varfile
Contains the read class for the VAR file reading, some simulation attributes and the data cube.
Classes
DataCube -- holds Pencil Code VAR file data. |
Functions
|
Wrapper for |
Module Contents
- class pencil.read.varfile.DataCube
Bases:
objectDataCube – holds Pencil Code VAR file data.
Fill members with default values.
- t = 0.0
- dx = 1.0
- dy = 1.0
- dz = 1.0
- x = None
- y = None
- z = None
- f = None
- l1 = None
- l2 = None
- m1 = None
- m2 = None
- n1 = None
- n2 = None
- magic = None
- keys()
- read(var_file='', datadir='data', proc=-1, ivar=-1, quiet=True, trimall=False, magic=None, sim=None, precision='d', lpersist=False, dtype=np.float64, flist=None, timing=True, fbloc=True, lvec=True, lonlyvec=False, range_x=None, range_y=None, range_z=None, irange_x=None, irange_y=None, irange_z=None, var_list=None, unshear=False)
- read(var_file=’’, datadir=’data’, proc=-1, ivar=-1, quiet=True,
trimall=False, magic=None, sim=None, precision=’d’, lpersist=False, dtype=np.float64, flist=None, timing=True, fbloc=True, lvec=True, lonlyvec=False, range_x=None, range_y=None, range_z=None, irange_x=None, irange_y=None, irange_z=None, unshear=False)
Read VAR files from Pencil Code. If proc < 0, then load all data and assemble, otherwise load VAR file from specified processor.
The file format written by output() (and used, e.g. in var.dat) consists of the followinig Fortran records: 1. data(mx, my, mz, nvar) 2. t(1), x(mx), y(my), z(mz), dx(1), dy(1), dz(1), deltay(1) Here nvar denotes the number of slots, i.e. 1 for one scalar field, 3 for one vector field, 8 for var.dat in the case of MHD with entropy. but, deltay(1) is only there if lshear is on! need to know parameters.
- Parameters:
var_file (string) – Name of the VAR file. If not specified, use var.dat (which is the latest snapshot of the fields)
datadir (string) – Directory where the data is stored.
proc (int) – Processor to be read. If -1 read all and assemble to one array.
ivar (int) – Index of the VAR file, if var_file is not specified.
quiet (bool) – Flag for switching off output.
trimall (bool) – Trim the data cube to exclude ghost zones.
magic (list of strings) – If present list of derived values to be computed from the data, e.g. B = curl(A).
sim (pencil code simulation object) – Contains information about the local simulation.
precision (string) – Float ‘f’, double ‘d’ or half ‘half’.
flist (list) – If present list of exclusive basic farrays to include
timing (bool) – Report the time taken to create the obbject
fbloc (bool) – If memory is restricted omit duplicate farray copy
lvec (bool) – Combine components to form a vector
lonlyvec (bool) – If memory is restricted omit components and provide only the vector
lpersist (bool) – Read the persistent variables if they exist
range_[xyz] (2-tuple of real) – coordinate range selection for subdomain (closed interval). If trimall=F, ghost zones will be included on either side of the interval.
irange_[xyz] (either 2-tuple of integer or slice) – index range selection for subdomain (closed interval). Note that this index is in the full array (including ghost zones). If trimall=F, ghost zones will be included on either side of the interval.
var_list (list of string) – List of variables to read (must be a subset of the names in data/index.pro). If not provided, all available variables will be read. Note that if only a subset of variables is read, the indices in the f-array of the DataCube object will not match the indices in data/index.pro.
- Returns:
Instance of the pencil.read.var.DataCube class. All of the computed fields are imported as class members.
- Return type:
Examples
Read the latest var.dat file and print the shape of the uu array: >>> var = pc.read.var() >>> print(var.uu.shape)
Read the VAR2 file, compute the magnetic field B = curl(A), the vorticity omega = curl(u) and remove the ghost zones: >>> var = pc.read.var(var_file=’VAR2’, magic=[‘bb’, ‘vort’], trimall=True) >>> print(var.bb.shape)
- magic_attributes(param, dtype=np.float64)
Compute some additional ‘magic’ quantities.
- pencil.read.varfile.var(*args, **kwargs)
Wrapper for
DataCube.read()