pyro.util package#
This module provides utility functions for pyro
Submodules#
pyro.util.compare module#
pyro.util.io_pyro module#
This manages the reading of the HDF5 output files for pyro.
pyro.util.msg module#
support output in highlighted colors
- pyro.util.msg.fail(string)[source]#
Output a string to the terminal and abort if we are running non-interactively. The string is colored red to indicate a failure
pyro.util.plot_tools module#
Some basic support routines for configuring the plots during runtime visualization
pyro.util.profile_pyro module#
A very simple profiling class, to use to determine where most of the time is spent in a code. This supports nested timers and outputs a report at the end.
Warning: At present, no enforcement is done to ensure proper nesting.
- class pyro.util.profile_pyro.Timer(name, stack_count=0)[source]#
Bases:
object
A single timer – this simply stores the accumulated time for a single named region
- class pyro.util.profile_pyro.TimerCollection[source]#
Bases:
object
A timer collection—this manages the timers and has methods to start and stop them. Nesting of timers is tracked so we can pretty print the profiling information.
To define a timer:
tc = TimerCollection() a = tc.timer('my timer')
This will add ‘my timer’ to the list of Timers managed by the TimerCollection. Subsequent calls to timer() will return the same Timer object.
To start the timer:
a.begin()
and to end it:
a.end()
For best results, the block of code timed should be large enough to offset the overhead of the timer class method calls.
tc.report() prints out a summary of the timing.
pyro.util.runparams module#
basic syntax of the parameter file is:
# simple parameter file
[driver]
nsteps = 100 ; comment
max_time = 0.25
[riemann]
tol = 1.e-10
max_iter = 10
[io]
basename = myfile_
The recommended way to use this is for the code to have a master list of parameters and their defaults (e.g. _defaults), and then the user can override these defaults at runtime through an inputs file. These two files have the same format.
The calling sequence would then be:
rp = RuntimeParameters()
rp.load_params("_defaults")
rp.load_params("inputs")
The parser will determine what datatype the parameter is (string, integer, float), and store it in a RuntimeParameters object. If a parameter that already exists is encountered a second time (e.g., there is a default value in _defaults and the user specifies a new value in inputs), then the second instance replaces the first.
Runtime parameters can then be accessed via any module through the get_param method:
tol = rp.get_param('riemann.tol')
If the optional flag no_new=1 is set, then the load_params function will not define any new parameters, but only overwrite existing ones. This is useful for reading in an inputs file that overrides previously read default values.
- class pyro.util.runparams.RuntimeParameters[source]#
Bases:
object
- load_params(pfile, *, no_new=False)[source]#
Reads line from file and makes dictionary pairs from the data to store.
- Parameters:
- filestr
The name of the file to parse
- no_newint, optional
If no_new = 1, then we don’t add any new parameters to the dictionary of runtime parameters, but instead just override the values of existing ones.
- print_paramfile()[source]#
Create a file, inputs.auto, that has the structure of a pyro inputs file, with all known parameters and values