Difference between revisions of "VTKpytools/Bar2vtk"
(Jrwrigh moved page Bar2vtk to Barfiletools: Reserve bar2vtk for the utility) |
m (Jrwrigh moved page Bar2vtk to VTKpytools/Bar2vtk: Move to a subpage organization) |
||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | # | + | '''bar2vtk''' is a utility from the [[VTKpytools|vtkpytools]] project for taking data in *bar files (<code>velbar</code> and <code>stsbar</code>) and loading it into a "blank" VTK Multiblock (VTM) file. In particular, it makes use of the [[Barfiletools|barfiletools]] module in the <code>vtkpytools</code> project. |
+ | |||
+ | Documentation for <code>bar2vtk</code> can be found by running the <code>--help</code> flag, but this will also serve as a more detailed/verbose documentation page as well. | ||
+ | |||
+ | [[File:Vtkpytools flowchart-Using bar2vtk.png|right]] | ||
+ | |||
+ | == Functionality == | ||
+ | |||
+ | === Modes === | ||
+ | <code>bar2vtk</code> has two primary modes; cli (short for ''command line interface'') and toml. They have equal capabilities and can be called by <code>bar2vtk cli</code> and <code>bar2vtk toml</code>, respectively. The cli operates solely on the command line via standard flag and argument system. The toml system uses configuration files (in a [https://toml.io/en/ toml] format) to control the program instead. | ||
+ | |||
+ | Below is a equivalency table for cli flags/arguments vs toml config declarations. A more detailed description for each option is given in [[Bar2vtk#Options|Options]]. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! cli | ||
+ | ! toml | ||
+ | ! Description | ||
+ | |- | ||
+ | | <code>[1st argument]</code> | ||
+ | | <code>blankvtmfile = ' '</code> | ||
+ | | Path to the blank vtm file | ||
+ | |- | ||
+ | | <code>[2nd argument]</code> | ||
+ | | <code>barfiledir = ' '</code> | ||
+ | | Path to *bar files | ||
+ | |- | ||
+ | | <code>[3rd argument]</code> | ||
+ | | <code>timestep = ' '</code> | ||
+ | | Timesteps of data to be used | ||
+ | |- | ||
+ | | <code>--velbar</code> | ||
+ | | <code>velbar = [ ]</code> | ||
+ | | Explicitly specify velbar file to use | ||
+ | |- | ||
+ | | <code>--stsbar</code> | ||
+ | | <code>stsbar = [ ]</code> | ||
+ | | Explicitly specify stsbar file to use | ||
+ | |- | ||
+ | | <code>--ascii</code> | ||
+ | | <code>asciidata = [true/false]</code> | ||
+ | | Whether the *bar files are written in ASCII | ||
+ | |- | ||
+ | | <code>--debug</code> | ||
+ | | <code>debug = [true/false] </code> | ||
+ | | Add raw <code>stsbar</code> data to the file for debugging purposes | ||
+ | |- | ||
+ | | <code>--velonly</code> | ||
+ | | <code>velonly = [true/false]</code> | ||
+ | | Whether to only include data from <code>velbar</code> files | ||
+ | |- | ||
+ | | <code>--outpath</code> | ||
+ | | <code>outpath = ' '</code> | ||
+ | | Path that the resulting file should be output to | ||
+ | |- | ||
+ | | <code>-f/--new-file-prefix</code> | ||
+ | | <code>new-file-prefix = ' '</code> | ||
+ | | Prefix defined for the new file | ||
+ | |} | ||
+ | === Basic Usage === | ||
+ | |||
+ | <code>bar2vtk</code> takes three primary arguments: <code>blankvtmfile</code>, <code>barfiledir</code>, and <code>timestep</code>. The utility will search the <code>barfiledir</code> for the appropriate *bar file(s) based on the <code>timestep</code> argument, and then load them onto the <code>blankvtmfile</code>. | ||
+ | |||
+ | ; <code>blankvtmfile</code> | ||
+ | : Path to the VTM file that the data is loaded onto. Must match the "blank" [[Barfiletools#VTM_File_Format|VTM file format]]. | ||
+ | ; <code>barfiledir</code> | ||
+ | : Path to directory where the *bar file(s) are located. | ||
+ | ; <code>timestep</code> | ||
+ | : The timestep(s) of the *bar file(s) to be loaded. For [[Bar2vtk#Time_Windows|time windows]], a <code>-</code> is used to delimit between the beginning and ending timestep. | ||
+ | |||
+ | By default, the loaded VTM file will be output to the current directory and it's name will be <code>[blankvtmfile]_[timestep].vtm</code>. This can be changed using the utility [[Bar2vtk#Options|options]]. | ||
+ | |||
+ | '''Example:''' | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! cli | ||
+ | ! toml | ||
+ | |- | ||
+ | | <pre>bar2vtk cli vtkFiles/example_blank.vtm data/ 10000 </pre> | ||
+ | | <pre>~> cat input.toml | ||
+ | [arguments] | ||
+ | asciidata = false | ||
+ | barfiledir = './data' | ||
+ | blankvtmfile = 'vtkFiles/example_blank.vtm' | ||
+ | debug = false | ||
+ | new_file_prefix = '' | ||
+ | outpath = '' | ||
+ | stsbar = [] | ||
+ | timestep = '10000' | ||
+ | ts0 = -1 | ||
+ | velbar = [] | ||
+ | velonly = false | ||
+ | |||
+ | ~> bar2vtk toml input.toml | ||
+ | </pre> | ||
+ | |} | ||
+ | |||
+ | * Searches for <code>{vel,sts}bar.10000</code> in <code>./data</code> | ||
+ | * Outputs <code>example_blank_10000.vtm</code> to the <code>vtkFiles/</code> directory | ||
+ | |||
+ | === *bar File Searching === | ||
+ | When searching for the *bar file(s) in <code>barfiledir</code>, <code>bar2vtk</code> uses a regex of <code>^{vel,sts}bar.*{timestep}(?![\d|-]).*</code> to find them. For example, given <code>timestep=200</code>, this regex string will return the files <code>velbar.200</code> or <code>velbar.200.1</code>, but not <code>velbar.2000</code> or <code>velbar.200-300.1</code>. If the regex matches more than one file, it will return an error. | ||
+ | |||
+ | If setting the *bar file paths explicitly using [[Bar2vtk#--velbar_and_--stsbar|<code>--velbar</code> and <code>--stsbar</code>]], <code>barfiledir</code> will be ignored and no globing will occur. | ||
+ | |||
+ | === Time Windows === | ||
+ | Splitting time windows of the *bar files is done my specifying a <code>timestep</code> with a <code>-</code> to delimit the two timesteps. This will also require the <code>--ts0</code> flag to define at what timestep the *bar files were reset at. | ||
+ | |||
+ | '''Example:''' | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | ! cli | ||
+ | ! toml | ||
+ | |- | ||
+ | | <pre>bar2vtk cli vtkFiles/example_blank.vtm data/ 10000-20000 --ts0 5000</pre> | ||
+ | | <pre>~> cat input.toml | ||
+ | [arguments] | ||
+ | asciidata = false | ||
+ | barfiledir = './data' | ||
+ | blankvtmfile = 'vtkFiles/example_blank.vtm' | ||
+ | debug = false | ||
+ | new_file_prefix = '' | ||
+ | outpath = '' | ||
+ | stsbar = [] | ||
+ | timestep = '10000-20000' | ||
+ | ts0 = 5000 | ||
+ | velbar = [] | ||
+ | velonly = false | ||
+ | |||
+ | ~> bar2vtk toml input.toml | ||
+ | </pre> | ||
+ | |} | ||
+ | |||
+ | * Searches for <code>{vel,sts}bar.10000</code> and <code>{vel,sts}bar.20000</code> in <code>./data</code> | ||
+ | * Outputs <code>example_blank_10000-20000.vtm</code> to the <code>vtkFiles/</code> directory | ||
+ | |||
+ | == Options == | ||
+ | |||
+ | ==== <code>--velbar</code> and <code>--stsbar</code> ==== | ||
+ | These flags allow for explicit setting the path(s) to the <code>velbar</code> and <code>stsbar</code> files. They can take a maximum of two arguments. | ||
+ | |||
+ | When given two paths, it will assume that a [[Bar2vtk#Time__Windows|time window]] is to be created, with the first file corresponding to the first timestep in the timestep range. | ||
+ | |||
+ | '''Examples:''' | ||
+ | * <code>bar2vtk [vtmfile] [dataPath] 10000 --velbar /data/path/velbar.file --stsbar /data/path/stsbar.file</code> | ||
+ | ** Will use the files given to do a "single timestep" VTM creation | ||
+ | * <code>bar2vtk [vtmfile] [dataPath] 10000-20000 --ts0=0 --velbar /data/path/velbar_first.file /data/path/velbar_second.file --stsbar /data/path/stsbar_first.file /data/path/stsbar_second.file</code> | ||
+ | ** Will create a time step window using the <code>/data/path/*bar_first.file</code> files as timestep 10000 and <code>/data/path/*bar_second.file</code> as timestep 20000 | ||
+ | |||
+ | ==== <code>--ascii</code> ==== | ||
+ | Ordinarily, the <code>*bar</code> files are assumed to be Fortran binary array files. Using this flag, the file(s) will instead be assumed to be space-delimited plain-text files (ie. ASCII files). | ||
+ | |||
+ | ==== <code>--debug</code> ==== | ||
+ | This flag will add in the raw values from the <code>stsbar</code> file, allowing for better debugging of the files if any strange data comes out from them. | ||
+ | |||
+ | ==== <code>--velonly</code> ==== | ||
+ | Will only load the <code>velbar</code> file(s) into the VTM file. | ||
+ | |||
+ | ==== <code>--vptpath</code> ==== | ||
+ | Path to <code>vtkpytools</code> in case of a desire to do custom testing with a separate module. Not generally recommended to use, mostly for testing/development purposes. | ||
+ | |||
+ | ==== <code>--outpath</code> ==== | ||
+ | Specify the path that the "loaded" VTM file is output to (instead of being saved to the current working directory by default). | ||
+ | |||
+ | ==== <code>-f/--new-file-prefix</code> ==== | ||
+ | Choosing a new file prefix for the "loaded" VTM file. By default, the name of the blank VTM file will be used with <code>_[timestep]</code> being appended to it. If this flag is given, then it's argument will be used as the file prefix. | ||
+ | |||
+ | '''Examples:''' | ||
+ | bar2vtk example_blank.vtm data/ 10000 -f otherprefix | ||
+ | # output file name is "otherprefix_10000.vtm" | ||
+ | |||
+ | == toml Mode == | ||
+ | |||
+ | There are only two options in toml mode; output a blank toml file: | ||
+ | |||
+ | bar2vtk toml -b blank_toml_filename.toml | ||
+ | |||
+ | or giving <code>bar2vtk</code> a filled out toml file to process: | ||
+ | |||
+ | bar2vtk toml filled_toml_filename.toml | ||
+ | |||
+ | Here's an example of a filled toml file: | ||
+ | <nowiki> | ||
+ | [arguments] | ||
+ | asciidata = false | ||
+ | barfiledir = './BinaryBars' | ||
+ | blankvtmfile = '../meshFiles/CRS_4delta_12-30.vtm' | ||
+ | debug = false | ||
+ | new_file_prefix = 'CRS_4delta_12-30_basestab' | ||
+ | outpath = 'vtkFiles' | ||
+ | stsbar = [] | ||
+ | timestep = '1500-4500' | ||
+ | ts0 = 0 | ||
+ | velbar = [] | ||
+ | velonly = false </nowiki> | ||
+ | |||
+ | See [https://toml.io/en/ toml's website] for documentation on what is possible with. For example, the <code>#</code> is used for comments, allowing you to make notes or skip over certain entries. | ||
+ | |||
+ | [[Category:VTKpytools]] | ||
+ | [[Category:Post-processing]] | ||
+ | [[Category:Python]] |
Latest revision as of 10:57, 18 September 2022
bar2vtk is a utility from the vtkpytools project for taking data in *bar files (velbar
and stsbar
) and loading it into a "blank" VTK Multiblock (VTM) file. In particular, it makes use of the barfiletools module in the vtkpytools
project.
Documentation for bar2vtk
can be found by running the --help
flag, but this will also serve as a more detailed/verbose documentation page as well.
Contents
Functionality
Modes
bar2vtk
has two primary modes; cli (short for command line interface) and toml. They have equal capabilities and can be called by bar2vtk cli
and bar2vtk toml
, respectively. The cli operates solely on the command line via standard flag and argument system. The toml system uses configuration files (in a toml format) to control the program instead.
Below is a equivalency table for cli flags/arguments vs toml config declarations. A more detailed description for each option is given in Options.
cli | toml | Description |
---|---|---|
[1st argument]
|
blankvtmfile = ' '
|
Path to the blank vtm file |
[2nd argument]
|
barfiledir = ' '
|
Path to *bar files |
[3rd argument]
|
timestep = ' '
|
Timesteps of data to be used |
--velbar
|
velbar = [ ]
|
Explicitly specify velbar file to use |
--stsbar
|
stsbar = [ ]
|
Explicitly specify stsbar file to use |
--ascii
|
asciidata = [true/false]
|
Whether the *bar files are written in ASCII |
--debug
|
debug = [true/false]
|
Add raw stsbar data to the file for debugging purposes
|
--velonly
|
velonly = [true/false]
|
Whether to only include data from velbar files
|
--outpath
|
outpath = ' '
|
Path that the resulting file should be output to |
-f/--new-file-prefix
|
new-file-prefix = ' '
|
Prefix defined for the new file |
Basic Usage
bar2vtk
takes three primary arguments: blankvtmfile
, barfiledir
, and timestep
. The utility will search the barfiledir
for the appropriate *bar file(s) based on the timestep
argument, and then load them onto the blankvtmfile
.
-
blankvtmfile
- Path to the VTM file that the data is loaded onto. Must match the "blank" VTM file format.
-
barfiledir
- Path to directory where the *bar file(s) are located.
-
timestep
- The timestep(s) of the *bar file(s) to be loaded. For time windows, a
-
is used to delimit between the beginning and ending timestep.
By default, the loaded VTM file will be output to the current directory and it's name will be [blankvtmfile]_[timestep].vtm
. This can be changed using the utility options.
Example:
cli | toml |
---|---|
bar2vtk cli vtkFiles/example_blank.vtm data/ 10000 |
~> cat input.toml [arguments] asciidata = false barfiledir = './data' blankvtmfile = 'vtkFiles/example_blank.vtm' debug = false new_file_prefix = '' outpath = '' stsbar = [] timestep = '10000' ts0 = -1 velbar = [] velonly = false ~> bar2vtk toml input.toml |
- Searches for
{vel,sts}bar.10000
in./data
- Outputs
example_blank_10000.vtm
to thevtkFiles/
directory
*bar File Searching
When searching for the *bar file(s) in barfiledir
, bar2vtk
uses a regex of ^{vel,sts}bar.*{timestep}(?![\d|-]).*
to find them. For example, given timestep=200
, this regex string will return the files velbar.200
or velbar.200.1
, but not velbar.2000
or velbar.200-300.1
. If the regex matches more than one file, it will return an error.
If setting the *bar file paths explicitly using --velbar
and --stsbar
, barfiledir
will be ignored and no globing will occur.
Time Windows
Splitting time windows of the *bar files is done my specifying a timestep
with a -
to delimit the two timesteps. This will also require the --ts0
flag to define at what timestep the *bar files were reset at.
Example:
cli | toml |
---|---|
bar2vtk cli vtkFiles/example_blank.vtm data/ 10000-20000 --ts0 5000 |
~> cat input.toml [arguments] asciidata = false barfiledir = './data' blankvtmfile = 'vtkFiles/example_blank.vtm' debug = false new_file_prefix = '' outpath = '' stsbar = [] timestep = '10000-20000' ts0 = 5000 velbar = [] velonly = false ~> bar2vtk toml input.toml |
- Searches for
{vel,sts}bar.10000
and{vel,sts}bar.20000
in./data
- Outputs
example_blank_10000-20000.vtm
to thevtkFiles/
directory
Options
--velbar
and --stsbar
These flags allow for explicit setting the path(s) to the velbar
and stsbar
files. They can take a maximum of two arguments.
When given two paths, it will assume that a time window is to be created, with the first file corresponding to the first timestep in the timestep range.
Examples:
-
bar2vtk [vtmfile] [dataPath] 10000 --velbar /data/path/velbar.file --stsbar /data/path/stsbar.file
- Will use the files given to do a "single timestep" VTM creation
-
bar2vtk [vtmfile] [dataPath] 10000-20000 --ts0=0 --velbar /data/path/velbar_first.file /data/path/velbar_second.file --stsbar /data/path/stsbar_first.file /data/path/stsbar_second.file
- Will create a time step window using the
/data/path/*bar_first.file
files as timestep 10000 and/data/path/*bar_second.file
as timestep 20000
- Will create a time step window using the
--ascii
Ordinarily, the *bar
files are assumed to be Fortran binary array files. Using this flag, the file(s) will instead be assumed to be space-delimited plain-text files (ie. ASCII files).
--debug
This flag will add in the raw values from the stsbar
file, allowing for better debugging of the files if any strange data comes out from them.
--velonly
Will only load the velbar
file(s) into the VTM file.
--vptpath
Path to vtkpytools
in case of a desire to do custom testing with a separate module. Not generally recommended to use, mostly for testing/development purposes.
--outpath
Specify the path that the "loaded" VTM file is output to (instead of being saved to the current working directory by default).
-f/--new-file-prefix
Choosing a new file prefix for the "loaded" VTM file. By default, the name of the blank VTM file will be used with _[timestep]
being appended to it. If this flag is given, then it's argument will be used as the file prefix.
Examples:
bar2vtk example_blank.vtm data/ 10000 -f otherprefix # output file name is "otherprefix_10000.vtm"
toml Mode
There are only two options in toml mode; output a blank toml file:
bar2vtk toml -b blank_toml_filename.toml
or giving bar2vtk
a filled out toml file to process:
bar2vtk toml filled_toml_filename.toml
Here's an example of a filled toml file:
[arguments] asciidata = false barfiledir = './BinaryBars' blankvtmfile = '../meshFiles/CRS_4delta_12-30.vtm' debug = false new_file_prefix = 'CRS_4delta_12-30_basestab' outpath = 'vtkFiles' stsbar = [] timestep = '1500-4500' ts0 = 0 velbar = [] velonly = false
See toml's website for documentation on what is possible with. For example, the #
is used for comments, allowing you to make notes or skip over certain entries.