Python Class for managing IMPACT-Z/T input files
Project description
IMPACT_IN
Python Class for managing IMPACT-Z/T input files. Includes the ability to read and write input files as well as replace string variables found within the file with numeric values.
Installation
The class can be installed from PyPI, using the following command:
pip install impact_input
Read in Input File
Reads in the input file specified by filename. Includes the ability to remove comments (i.e lines beginning with ! or anything occuring after a /) using exclude_comments. By default exclude_comments = True
.
from IMPACT_IN import IMPACT_IN as IMPACT_IN
impact_file = IMPACT_IN(filename="ImpactT_original.in")
Get all Variables
Returns a list of all variables found in the input file. Variable names cannot start with a number.
impact_file.variables()
Replace Variables with Values
Replace the list of variables with the numerical values in the respective order they appear in the list (e.g. gunPhaseF1 becomes 0 below).
replace_var = ["gunPhaseF1","gunPhaseF2"]
val = [0,180]
impact_edit = impact_file.replace(varnames=replace_var,varvals=val)
Write New Input File IMPACT
Write an input file with the specified filename. Note it is best practice to make the new file have a different name than the initial input so as not to overwite it. As the IMPACT-Z/T executables require the input file to be named "ImpactZ.in" or "ImpactT.in", the initial input file should have a name other than those two options.
impact_edit.write(filename='ImpactT.in')
Examples
Examples python scripts that use the IMPACT_IN class to run a phase scan and find the phase with the maximum energy gain for a RF gun can be found here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for impact_input-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cdb133a72388cb7e507b81140e31be68868dac992f57b82b2be371eea0375db |
|
MD5 | b2aaf0db6418ee394a782724c7e8ad2a |
|
BLAKE2b-256 | 6f56eacd0c5f729e903a3ed45af4c3de4badc669c48e44553dc08283715ceb1c |