Analysis Results Tools¶
These are still a work in progress, functionality (& hopefully documentation) will update frequently.
This file defines an object representing post-processing results, i.e. after time-averaging or other reductions. It also provides several functions for reading such objects.
-
class
pyharm.ana_results.AnaResults(fname, tag='')¶ Tools for dealing with the results computed by scripts/pyharm-analysis.
Results are organized by remaining independent variable – so, a phi- and time-average will be under ‘rth’ since these are its remaining independent variables.
This is more logical than it sounds: this way, most quantity names contain all the info needed to plot them. Also, multiple reductions of the same quantity can be stored with logical names, e.g. a phi,t average of rho in ‘rth/rho’ and a further average over th in ‘r/rho’. Basic EH fluxes are e.g. t/Mdot or t/phi_b. Suffix ‘_per’ normalizes dimensionless values to the un-smoothed accretion rate, which can increase their variability.
When using __getitem__ (i.e. res[]), the name after the slash doesn’t have to be something directly present in the file – it can include many of the ‘key’ features available in FluidDump, notably unary operators (sqrt_, abs_, etc), but this is all separate functions so YMMV. Time-dependent variables may also append ‘_smoothed’ or ‘_smoothed_xx’ to calculate a running average over xx values (that is, samples, not simulation time units).
A few variables (beta, sigma, etc) should be suffixed ‘_post’ if they should be calcuated by AnaResults. This is because versions calculated and averaged per-zone might also be present in the reductions file.
For a little more control, you can call res.get_result() specifically, which takes a few more arguments documented there.
-
get_dvar(ivar, dvar)¶ Takes an independent and dependent variable name, and attempts to read or derive the appropriate reduction of the dependent variable. Usually, this is called from __getitem__.
In implementation, this is the closest analog to FluidDump’s __getitem__ function – it’s the place to add any complex new tags/operations/whatever.
-
get_ivar(ivar, th_r=None, mesh=True)¶ Get a list of grids of independent variable values. ‘ivar’ must be a string containing the desired combination of r, th or hth (half theta), phi, or t. The list must always follow the above ordering and cannot contain >2 variables (use grid)
examples: ‘rt’, ‘t’, ‘hth’, ‘rth’
Always returns a list, e.g. the array of timestamps will be res.get_ivar(‘t’)[0]
-
get_time_slice(tmin, tmax=0)¶ Get the indices in the (correct, potentially reordered) timeline corresponding to stated tmin, tmax. Allows negative tmin to specify a slice to the end of the run
-
-
pyharm.ana_results.load_result(fname, **kwargs)¶ Wrapper to read diagnostic output or results of reductions
-
pyharm.ana_results.load_results(fname, **kwargs)¶ Wrapper to read diagnostic output or results of reductions
-
pyharm.ana_results.load_results_glob(paths, fname, tag_fn=None)¶ Load results from a path/glob/list of paths/globs, add appropriate tags, and return as a dictionary.
-
pyharm.ana_results.smoothed(a, window_sz=101)¶ A potentially reasonably fast smoothing operation. Averages only available data, i.e. only half window-size at edges.