Skip to content

python library that allows to easily convert data from SDF file format to VTK

Notifications You must be signed in to change notification settings

valenpe7/sdf2vtk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sdf2vtk

sdf2vtk is a python library that allows to easily convert variables from SDF file format to VTK.

Installing:

sdf2vtk requires sdf, vtk, and numpy.
If these dependencies are satisfied, one can install sdf2vtk using pip:

$> cd sdf2vtk
$> pip install .

Usage:

from sdf2vtk import *

convertor = sdf2vtk()

convertor.read_sdf("input_path/file_1.sdf") # sdf file with field data
convertor.list_variables()
convertor.create_vtk_field_grid(dimension=2, subset=None, reduced=False, norm=1.0e-6)
convertor.add_time_to_vtk(norm=1.0e-15)
convertor.add_electric_field_to_vtk(component="x", subset=None, reduced=False, norm=1.0e+15, single=True)
convertor.add_electric_field_to_vtk(component="z", subset=None, reduced=False, norm=1.0e+15, single=True)
convertor.add_magnetic_field_to_vtk(component="y", subset=None, reduced=False, norm=1.0e+7, single=True)
convertor.add_particle_number_density_to_vtk(species="electron", subset=None, reduced=False, norm=1.0e+27, single=False)
convertor.write_vtk_field_grid("output_path/file.vti") # field data are converted to uniform grids (.vti format)

convertor.read_sdf("input_path/file_2.sdf") # sdf file with particle data
convertor.list_variables()
convertor.create_vtk_particle_grid(dimension=3, species="electron", subset="gamma_gt_10", norm=1.0e-6)
convertor.add_time_to_vtk(norm=1.0e-15)
convertor.add_particle_momentum_to_vtk(species="electron", component="x", subset="gamma_gt_10", norm=1.0e-20, single=True)
convertor.add_particle_momentum_to_vtk(species="electron", component="z", subset="gamma_gt_10", norm=1.0e-20, single=True)
convertor.add_particle_weight_to_vtk(species="electron", subset="gamma_gt_10", single=False):
convertor.add_particle_id_to_vtk(species="electron", subset="gamma_gt_10", single=False):
convertor.write_vtk_particle_grid("output_path/file.vtu") # particle data are converted to unstructured grids (.vtu format)

About

python library that allows to easily convert data from SDF file format to VTK

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages