pyro.util package#

This module provides utility functions for pyro

Submodules#

pyro.util.compare module#

pyro.util.compare.compare(data1, data2, rtol=1e-12)[source]#

given two CellCenterData2d objects, compare the data, zone-by-zone and output any errors

Parameters:
data1, data2CellCenterData2d object

Two data grids to compare

rtolfloat

relative tolerance to use to compare grids

pyro.util.compare.main()[source]#

pyro.util.io_pyro module#

This manages the reading of the HDF5 output files for pyro.

pyro.util.io_pyro.read(filename)[source]#

read an HDF5 file and recreate the simulation object that holds the data and state of the simulation.

pyro.util.io_pyro.read_bcs(f)[source]#

read in the boundary condition record from the HDF5 file

pyro.util.msg module#

support output in highlighted colors

pyro.util.msg.bold(string)[source]#

Output a string in a bold weight

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.msg.success(string)[source]#

Output a string to the terminal colored green to indicate success

pyro.util.msg.warning(string)[source]#

Output a string to the terminal colored orange to indicate a warning

pyro.util.plot_tools module#

Some basic support routines for configuring the plots during runtime visualization

pyro.util.plot_tools.setup_axes(myg, num)[source]#

create a grid of axes whose layout depends on the aspect ratio of the domain

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

begin()[source]#

Start timing

end()[source]#

Stop timing. This does not destroy the timer, it simply stops it from counting time.

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.

report()[source]#

Generate a timing summary report

timer(name)[source]#

Create a timer with the given name. If one with that name already exists, then we return that timer.

Parameters:
namestr

Name of the timer

Returns:
outTimer object

A timer object corresponding to the name.

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

get_param(key)[source]#

returns the value of the runtime parameter corresponding to the input key

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_all_params()[source]#

Print out all runtime parameters and their values

print_paramfile()[source]#

Create a file, inputs.auto, that has the structure of a pyro inputs file, with all known parameters and values

print_sphinx_tables(outfile='params-sphinx.inc')[source]#

Output Sphinx-formatted tables for inclusion in the documentation. The table columns will be: param, default, description.

print_unused_params()[source]#

Print out the list of parameters that were defined by never used

set_param(key, value, *, no_new=True)[source]#

manually set one of the existing runtime parameters

write_params(f)[source]#

Write the runtime parameters to an HDF5 file. Here, f is the h5py file object

pyro.util.runparams.is_float(string)[source]#

is the given string a float?

pyro.util.runparams.is_int(string)[source]#

is the given string an integer?