pencil.tool_kit

Specialized tools that are of use to a limited number of users only.

Submodules

Classes

NullPoint

Contains the position of the null points and the finding routine.

Separatrix

Contains the separatrix layers and methods to find them.

Spine

Contains the spines of the null points and their finding routines.

Functions

write_forcing_cont(a[, outfile])

Writes the file forcing_cont.dat that can be used to specify the form of the continuous forcing in forcing.f90

Package Contents

class pencil.tool_kit.NullPoint

Bases: object

Contains the position of the null points and the finding routine.

Fill members with default values.

nulls = None
eigen_values = None
eigen_vectors = None
sign_trace = None
fan_vectors = None
normals = None
find_nullpoints(var, field)

find_nullpoints(var, field)

Find the null points to the field ‘field’ with information from ‘var’.

Parameters:
  • var (obj) – The var object from the read.var routine.

  • field (string) – The vector field name.

write_vtk(datadir='data', file_name='nulls.vtk', binary=False)

write_vtk(datadir=’data’, file_name=’nulls.vtk’, binary=False)

Write the null point into a vtk file.

Parameters:
  • datadir (string) – Target data directory.

  • file_name (string) – Target file name.

  • binary (bool) – Write file in binary or ASCII format.

read_vtk(datadir='data', file_name='nulls.vtk')

read_vtk(datadir=’data’, file_name=’nulls.vtk’)

Read the null point from a vtk file.

Parameters:
  • datadir (string) – Origin data directory.

  • file_name (string) – Origin file name.

class pencil.tool_kit.Separatrix

Bases: object

Contains the separatrix layers and methods to find them.

Fill members with default values.

lines = []
eigen_values = []
eigen_vectors = []
sign_trace = []
fan_vectors = []
normals = []
separatrices = []
connectivity = []
find_separatrices(var, field, null_point, delta=0.1, iter_max=100, ring_density=8)
find_separatrices(var, field, null_point, delta=0.1,

iter_max=100, ring_density=8)

Find the separatrices to the field ‘field’ with information from ‘var’.

Parameters:
  • var (obj) – The var object from the read_var routine.

  • field (string) – The vector field.

  • null_point (obj) – NullPoint object containing the magnetic null points.

  • delta (float) – Step length for the field line tracing.

  • iter_max (int) – Maximum iteration steps for the fiel line tracing.

  • ring_density (float) – Density of the tracer rings.

write_vtk(datadir='data', file_name='separatrices.vtk', binary=False)

write_vtk(datadir=’data’, file_name=’separatrices.vtk’, binary=False)

Write the separatrices into a vtk file.

Parameters:
  • datadir (string) – Target data directory.

  • file_name (string) – Target file name.

  • binary (bool) – Write file in binary or ASCII format.

read_vtk(datadir='data', file_name='separatrices.vtk')

read_vtk(datadir=’data’, file_name=’separatrices.vtk’)

Read the separatrices from a vtk file.

Parameters:
  • datadir (string) – Origin data directory.

  • file_name (string) – Origin file name.

class pencil.tool_kit.Spine

Bases: object

Contains the spines of the null points and their finding routines.

Fill members with default values.

spines = []
find_spines(var, field, null_point, delta=0.1, iter_max=100)

find_spines(var, field, null_point, delta=0.1, iter_max=100)

Find the spines to the field ‘field’ with information from ‘var’.

Parameters:
  • var (obj) – The var object from the read_var routine.

  • field (string) – The vector field.

  • null_point (obj) – NullPoint object containing the magnetic null points.

  • delta (float) – Step length for the field line tracing.

  • iter_max (int) – Maximum iteration steps for the fiel line tracing.

write_vtk(datadir='data', file_name='spines.vtk', binary=False)

write_vtk(datadir=’data’, file_name=’spines.vtk’, binary=False)

Write the spines into a vtk file.

Parameters:
  • datadir (string) – Target data directory.

  • file_name (string) – Target file name.

  • binary (bool) – Write file in binary or ASCII format.

read_vtk(datadir='data', file_name='spines.vtk')

read_vtk(datadir=’data’, file_name=’spines.vtk’)

Read the spines from a vtk file.

Parameters:
  • datadir (string) – Target data directory.

  • file_name (string) – Target file name.

pencil.tool_kit.write_forcing_cont(a, outfile='forcing_cont.dat')

Writes the file forcing_cont.dat that can be used to specify the form of the continuous forcing in forcing.f90

Parameters:
  • a (numpy array specifying the continuous forcing. Shape is expected to be (3,nz,ny,nx). Note that the order of the spatial indices is the same as in the rest of the Pencil Python module.)

  • outfile (file into which the array should be written)

  • usage (Example)

  • -------------

  • pc (>>> import pencil as)

  • np (>>> import numpy as)

  • pc.read.dim() (>>> dim =)

  • np.ones((3 (>>> a =)

  • dim.nx

  • dim.ny

  • dim.nz))

  • pc.tool_kit.write_forcing_cont(a) (>>>)