Difference between revisions of "VTKpytools"
(Add link to Anaconda page) |
(Add subpages topic) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
== Using vtkpytools == | == Using vtkpytools == | ||
− | + | === Installation === | |
+ | |||
+ | ==== Normal Use ==== | ||
+ | vtkpytools is already installed on the global (<code>main</code>) [[Anaconda|conda environment]] installed on the viz nodes. This also makes all vtkpytool scripts (ie. <code>bar2vtk.py</code> and <code>barsplit.py</code>, etc.) available in your <code>$PATH</code> when the conda environment is active, allowing them to be used in command line without specifying a path to them. | ||
+ | |||
+ | This installation is with be updated periodically as updates are made. It is installed from a cloned repository at <code>/projects/tools/vtkpytools</code> and running <code>pip install .</code> with the conda environment active (see [[Anaconda#Activating_conda_Environment]]). ''Please do not make any changes to this repository''; clone/fork your own copy and make any changes you want there. See next section for how to use your own copy of the package repository | ||
+ | |||
+ | ==== Development Use ==== | ||
+ | If you're making changes to the code and want to test it out, there are two ways to "override" the normal installation. | ||
+ | |||
+ | ====== Adding to Path ====== | ||
+ | First is adding the development repository to the path that Python searches for packages. This maybe done by modifying the <code>$PYTHONPATH</code> environment variable: | ||
+ | |||
+ | PYTHONPATH=path/to/vtkpytools/repository/directory:$PYTHONPATH | ||
+ | |||
+ | or by using the following commands in a script: | ||
import sys | import sys | ||
sys.path.insert(0, 'path/to/vtkpytools/repository/directory') | sys.path.insert(0, 'path/to/vtkpytools/repository/directory') | ||
− | + | ====== Using vtkpytools executables ====== | |
+ | When wanting to use an executable from a specific version of vtkpytools, in addition to modifying your <code>$PYTHONPATH</code>, you must also modify your <code>$PATH</code> such that it includes the path to the <code>bin</code> directory of the desired vtkpytools installation | ||
+ | |||
+ | export PATH=path/to/vtkpytools/repository/directory/bin:$PATH | ||
+ | |||
+ | Note that often only the <code>$PYTHONPATH</code> needs to be adjusted. For example, the [https://github.com/PHASTA/vtkpytools/blob/master/bin/bar2vtk.py code for bar2vtk] simply imports vtkpytools and runs the <code>bar2vtk_main()</code> function. Thus, only the <code>$PYTHONPATH</code> needs to be modified such that the script imports the correct version of vtkpytools. | ||
+ | |||
+ | Note also that the above means that you ''must'' modify <code>$PYTHONPATH</code> to get the executable working ''as expected''; the script will import whichever version of vtkpytools it finds and use it. | ||
+ | |||
+ | ====== Creating a New (personal) Conda Environment ====== | ||
+ | The second way is [https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands creating a new (personal) conda environment] and installing your copy of the repository there. If going this route, it is recommended to install the package via <code>python setup.py develop</code> as this will allow updates to be tested without reinstalling the package every time. | ||
=== Abbreviation === | === Abbreviation === | ||
Line 21: | Line 46: | ||
Currently, the vtkpytools repository is structured so that it can be expanded to host useful functions/utilities/scripts for many different kinds of problems/uses. If you would like to make changes/additions to the package, see the (to be added) <code>CONTRIBUTING.md</code> file in the repository for instructions. | Currently, the vtkpytools repository is structured so that it can be expanded to host useful functions/utilities/scripts for many different kinds of problems/uses. If you would like to make changes/additions to the package, see the (to be added) <code>CONTRIBUTING.md</code> file in the repository for instructions. | ||
+ | |||
+ | == Tutorials/Related pages == | ||
+ | |||
+ | Here's a list of tutorial pages related to vtkpytools. This is manually updated, so [[:Category:VTKpytools]] may have more up-to-date references to vtkpytools related wiki pages (''Hint: if it does, add them onto this page!'') | ||
+ | |||
+ | * [https://docs.pyvista.org/ pyvista Documentation] | ||
+ | ** vtkpytools is built on top of pyvista, so some knowledge of how it works is helpful to understand and debug stuff | ||
+ | ** Two recommended pages on their documentation: | ||
+ | *** [https://docs.pyvista.org/user-guide/what-is-a-mesh.html What is a Mesh?]: For general terminology and basic usage | ||
+ | *** [https://docs.pyvista.org/user-guide/simple.html# Basic API Usage]: For understand how to interact with pyvista-wrapped vtk objects | ||
+ | |||
+ | * [[Bar2vtk]] | ||
+ | ** Documentation for the <code>bar2vtk</code> command | ||
+ | ** Takes spanwise average "bar" files and loads that data onto a [[Barfiletools#VTM_File_Format|"blank" vtm file]]. | ||
+ | |||
+ | * [[Barfiletools]] | ||
+ | ** Comprehensive tutorial of using vtkpytools for post-processing spanwise averaged data: | ||
+ | *** [[Barfiletools#Creating_Blank_VTM_File|creating a 2D "blank" vtm file]], | ||
+ | *** Loading the data onto the resulting vtm file | ||
+ | *** Using vtkpytools for post-processing (calculating values, obtaining profiles, etc.) | ||
+ | |||
+ | * [https://fluid.colorado.edu/tutorials/vtkpytoolsVideos/ Video Tutorials] | ||
+ | ** [[Barfiletools]] tutorials videos reviewing over the three primary steps | ||
+ | |||
+ | === Subpages === | ||
+ | {{Special:PrefixIndex/VTKpytools/}} | ||
[[Category:Post-processing]] | [[Category:Post-processing]] | ||
[[Category:VTKpytools]] | [[Category:VTKpytools]] | ||
+ | [[Category:Python]] |
Latest revision as of 10:57, 18 September 2022
vtkpytools is a python package developed in house that has useful tools for generating Visualization ToolKit (VTK) files, and for extracting and manipulating data from VTK files. The code is hosted on a repository in PHASTA's GitHub organization.
vtkpytools heavily utilizes the pyvista Python package, which provides a Pythonic interface to VTK objects, and the Python bindings for the VTK library itself (which are simply one-to-one copies of the C++ API).
Contents
Using vtkpytools
Installation
Normal Use
vtkpytools is already installed on the global (main
) conda environment installed on the viz nodes. This also makes all vtkpytool scripts (ie. bar2vtk.py
and barsplit.py
, etc.) available in your $PATH
when the conda environment is active, allowing them to be used in command line without specifying a path to them.
This installation is with be updated periodically as updates are made. It is installed from a cloned repository at /projects/tools/vtkpytools
and running pip install .
with the conda environment active (see Anaconda#Activating_conda_Environment). Please do not make any changes to this repository; clone/fork your own copy and make any changes you want there. See next section for how to use your own copy of the package repository
Development Use
If you're making changes to the code and want to test it out, there are two ways to "override" the normal installation.
Adding to Path
First is adding the development repository to the path that Python searches for packages. This maybe done by modifying the $PYTHONPATH
environment variable:
PYTHONPATH=path/to/vtkpytools/repository/directory:$PYTHONPATH
or by using the following commands in a script:
import sys sys.path.insert(0, 'path/to/vtkpytools/repository/directory')
Using vtkpytools executables
When wanting to use an executable from a specific version of vtkpytools, in addition to modifying your $PYTHONPATH
, you must also modify your $PATH
such that it includes the path to the bin
directory of the desired vtkpytools installation
export PATH=path/to/vtkpytools/repository/directory/bin:$PATH
Note that often only the $PYTHONPATH
needs to be adjusted. For example, the code for bar2vtk simply imports vtkpytools and runs the bar2vtk_main()
function. Thus, only the $PYTHONPATH
needs to be modified such that the script imports the correct version of vtkpytools.
Note also that the above means that you must modify $PYTHONPATH
to get the executable working as expected; the script will import whichever version of vtkpytools it finds and use it.
Creating a New (personal) Conda Environment
The second way is creating a new (personal) conda environment and installing your copy of the repository there. If going this route, it is recommended to install the package via python setup.py develop
as this will allow updates to be tested without reinstalling the package every time.
Abbreviation
In Python, it is somewhat customary to use an abbreviation for packages when importing them (numpy -> np
or pandas -> pd
). In that same vein, vtkpytools
maybe abbreviated to vpt
. For those unfamiliar, this maybe done by
import vtkpytools as vpt
Expanding vtkpytools
Currently, the vtkpytools repository is structured so that it can be expanded to host useful functions/utilities/scripts for many different kinds of problems/uses. If you would like to make changes/additions to the package, see the (to be added) CONTRIBUTING.md
file in the repository for instructions.
Tutorials/Related pages
Here's a list of tutorial pages related to vtkpytools. This is manually updated, so Category:VTKpytools may have more up-to-date references to vtkpytools related wiki pages (Hint: if it does, add them onto this page!)
- pyvista Documentation
- vtkpytools is built on top of pyvista, so some knowledge of how it works is helpful to understand and debug stuff
- Two recommended pages on their documentation:
- What is a Mesh?: For general terminology and basic usage
- Basic API Usage: For understand how to interact with pyvista-wrapped vtk objects
- Bar2vtk
- Documentation for the
bar2vtk
command - Takes spanwise average "bar" files and loads that data onto a "blank" vtm file.
- Documentation for the
- Barfiletools
- Comprehensive tutorial of using vtkpytools for post-processing spanwise averaged data:
- creating a 2D "blank" vtm file,
- Loading the data onto the resulting vtm file
- Using vtkpytools for post-processing (calculating values, obtaining profiles, etc.)
- Comprehensive tutorial of using vtkpytools for post-processing spanwise averaged data:
- Video Tutorials
- Barfiletools tutorials videos reviewing over the three primary steps