pencil.export ============= .. py:module:: pencil.export .. autoapi-nested-parse:: Export data into different formats, like vtk or xml. Submodules ---------- .. toctree:: :maxdepth: 1 /code/sourcePython/pencil/export/arrays2d_to_vtk/index /code/sourcePython/pencil/export/arrays3d_to_vtk/index /code/sourcePython/pencil/export/create_h5/index /code/sourcePython/pencil/export/particles_to_vtk/index /code/sourcePython/pencil/export/pc2vtk/index Attributes ---------- .. autoapisummary:: pencil.export.fvars Classes ------- .. autoapisummary:: pencil.export.ParticlesVtk Functions --------- .. autoapisummary:: pencil.export.arrays2d_to_vtk pencil.export.arrays3d_to_vtk pencil.export.particles_to_vtk pencil.export.create_aver_sph pencil.export.var2vtk pencil.export.slices2vtk Package Contents ---------------- .. py:function:: 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) :param - folder: where to put the vtk :param - fil_ename: name of the vtk, '.vtk' will be added automatically :param - arrays: list of 2d array to export :param - names: list of names associated with arrays :param - gridx/y: grid as array .. py:function:: 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) :param - folder: where to put the vtk :param - fil_ename: name of the vtk, '.vtk' will be added automatically :param - arrays: list of 3d arrays to export :param - names: list of names associated with arrays :param - gridx/y: grid as array .. py:function:: 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. .. py:class:: ParticlesVtk Bases: :py:obj:`object` ParticlesVtk -- holds the vtk particle data and methods. Fill members with default values. .. py:attribute:: ipars :value: 0 .. py:attribute:: vtk_grid_data :value: [] .. py:attribute:: ti :value: -1 .. py:attribute:: tf :value: -1 .. py:attribute:: binary :value: True .. py:attribute:: destination :value: 'work.vtk' .. py:method:: 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. .. py:method:: write_to_vtk() Write the grid data into vtk files. call signature: write_to_vtk(self) .. py:function:: 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 \*filename*: Output filename. :keyword \*dataset*: HDF5 dataset. :keyword \*fields*: Names of the fields to be written. :keyword \*nzyxt*: Array containing [nz, ny, nx, nt]. :keyword \*zyxt*: Array containing the arrays z, y, x and t. :keyword \*hdf5dir*: Output data directory. :keyword \*dgroup*: Data group name. .. py:data:: fvars :value: [('utensor', (3,)), ('alpha', (3, 3)), ('beta', (3, 3)), ('gamma', (3,)), ('delta', (3,)),... .. py:function:: 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 \*var_file*: The original var_file. :keyword \*datadir*: Directory where the data is stored. :keyword \*proc*: Processor which should be read. Set to -1 for all processors. :keyword \*variables*: List of variables which should be written. If None all. :keyword \*b_ext*: Add the external magnetic field. :keyword \*destination*: Destination file. :keyword \*quiet*: Keep quiet when reading the var files. :keyword \*trimall*: Trim the data cube to exclude ghost zones. :keyword \*ti, tf*: Start and end index for animation. Leave negative for no animation. Overwrites variable var_file. .. py:function:: 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 \*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'"). :keyword \*extension*: List of slice positions. :keyword \*datadir*: Directory where the data is stored. :keyword \*destination*: Destination files. :keyword \*proc*: Processor which should be read. Set to -1 for all processors.