pencil.export

Export data into different formats, like vtk or xml.

Submodules

Attributes

fvars

Classes

ParticlesVtk

ParticlesVtk -- holds the vtk particle data and methods.

Functions

arrays2d_to_vtk(folder, filename, arrays, names, ...)

Convert 2-D array in a VTK file.

arrays3d_to_vtk(folder, filename, arrays, names, ...)

Convert 3-D array in a VTK file.

particles_to_vtk([var_file, datadir, proc, ...])

Read the pVAR files from Pencil Code and write them as vtk files.

create_aver_sph(filename, dataset, fields, nzyxt, zyxt)

call signature:

var2vtk([var_file, datadir, proc, variables, b_ext, ...])

Convert data from PencilCode format to vtk.

slices2vtk([field, extension, datadir, destination, proc])

Convert slices from PencilCode format to vtk.

Package Contents

pencil.export.arrays2d_to_vtk(folder, filename, arrays, names, gridx, gridy)

Convert 2-D array in a VTK file.

call signature:

arrays2d_to_vtk(folder, filename, arrays, names, gridx, gridy)

Parameters:
  • folder (-) – where to put the vtk

  • fil_ename (-) – name of the vtk, ‘.vtk’ will be added automatically

  • arrays (-) – list of 2d array to export

  • names (-) – list of names associated with arrays

  • gridx/y (-) – grid as array

pencil.export.arrays3d_to_vtk(folder, filename, arrays, names, gridx, gridy, gridz)

Convert 3-D array in a VTK file.

call signature:

arrays3d_to_vtk(folder, filename, arrays, names, gridx, gridy)

Parameters:
  • folder (-) – where to put the vtk

  • fil_ename (-) – name of the vtk, ‘.vtk’ will be added automatically

  • arrays (-) – list of 3d arrays to export

  • names (-) – list of names associated with arrays

  • gridx/y (-) – grid as array

pencil.export.particles_to_vtk(var_file='pvar.dat', datadir='data', proc=-1, destination='particles.vtk', ti=-1, tf=-1, binary=True)

Read the pVAR files from Pencil Code and write them as vtk files.

call signature:

particles_to_vtk(var_file=’pvar.dat’, datadir=’data’, proc=-1,

destination=’particles.vtk’, ti=-1, tf=-1, binary=True)

Keyword arguments:

var_file:

Name of the PVAR file.

datadir:

Directory where the data is stored.

proc:

Processor to be read. If -1 read all and assemble to one array.

destination:

Destination file (only if ti, tf > 0).

ti:

Initial time index for animation.

tf:

Final time index for animation.

binary:

Determines if binary or clear text data for the vtk files.

class pencil.export.ParticlesVtk

Bases: object

ParticlesVtk – holds the vtk particle data and methods.

Fill members with default values.

ipars = 0
vtk_grid_data = []
ti = -1
tf = -1
binary = True
destination = 'work.vtk'
convert_to_vtk(pvar_list)

Convert particle data into vtk format and return the vtk objects.

call signature:

convert_to_vtk(self, pvar_list)

Keyword arguments:

pvar_list:

List of particle objects.

write_to_vtk()

Write the grid data into vtk files.

call signature:

write_to_vtk(self)

pencil.export.create_aver_sph(filename, dataset, fields, nzyxt, zyxt, hdf5dir='data', dgroup='emftensor')

call signature:

create_aver_sph(filename, dataset, fields, nzyxt, zyxt,

hdf5dir=’data’, dgroup=’emftensor’)

Keyword Arguments:
  • *filename* – Output filename.

  • *dataset* – HDF5 dataset.

  • *fields* – Names of the fields to be written.

  • *nzyxt* – Array containing [nz, ny, nx, nt].

  • *zyxt* – Array containing the arrays z, y, x and t.

  • *hdf5dir* – Output data directory.

  • *dgroup* – Data group name.

pencil.export.fvars = [('utensor', (3,)), ('alpha', (3, 3)), ('beta', (3, 3)), ('gamma', (3,)), ('delta', (3,)),...
pencil.export.var2vtk(var_file='var.dat', datadir='data', proc=-1, variables=None, b_ext=False, magic=[], destination='work', quiet=True, trimall=True, ti=-1, tf=-1)

Convert data from PencilCode format to vtk.

call signature:

var2vtk(var_file='', datadir='data', proc=-1,
       variables='', b_ext=False,
       destination='work', quiet=True, trimall=True, ti=-1, tf=-1)

Read var_file and convert its content into vtk format. Write the result in destination.

Keyword Arguments:
  • *var_file* – The original var_file.

  • *datadir* – Directory where the data is stored.

  • *proc* – Processor which should be read. Set to -1 for all processors.

  • *variables* – List of variables which should be written. If None all.

  • *b_ext* – Add the external magnetic field.

  • *destination* – Destination file.

  • *quiet* – Keep quiet when reading the var files.

  • *trimall* – Trim the data cube to exclude ghost zones.

  • tf* (*ti,) – Start and end index for animation. Leave negative for no animation. Overwrites variable var_file.

pencil.export.slices2vtk(field='', extension='', datadir='data', destination='slices', proc=-1)

Convert slices from PencilCode format to vtk.

call signature:

slices2vtk(field='', extension='', datadir='data', destination='slices', proc=-1)

Read slice files specified by variables and convert them into vtk format for the specified extensions. Write the result in destination. NB: You need to have called src/read_videofiles.x before using this script.

Keyword Arguments:
  • *field* – All allowed fields which can be written as slice files, e.g. b2, uu1, lnrho, … See the pencil code manual for more (chapter: “List of parameters for `video.in’”).

  • *extension* – List of slice positions.

  • *datadir* – Directory where the data is stored.

  • *destination* – Destination files.

  • *proc* – Processor which should be read. Set to -1 for all processors.