Analysis Packages¶
Analyses¶
Here is the full list of analysis functions that can be specified/performed in pyharm. These can be listed as arguments to pyharm-analysis.
Groups of particular related reductions performed over a GRMHD run.
Each function takes a dump object and a dict ‘out’ to fill when computing new variables. This allows collation in analysis.py for the pyharm-analysis script
Variables are organized by remaining independent variable, as described in ana_results.py
-
pyharm.ana.analyses.basic(dump, out, **kwargs)¶ Anything necessary for other functions: t, EH fluxes, whether to average
-
pyharm.ana.analyses.diagnostics(dump, out, **kwargs)¶ Energy ratios on the grid to gauge floor effectiveness, along with total floor hit and inversion flags
-
pyharm.ana.analyses.dynamo(dump, out, **kwargs)¶ Compare magnetization in the upper and lower hemisphere of EH, and at 5 r_g
-
pyharm.ana.analyses.efluxes(dump, out, **kwargs)¶ Total energy fluxes, recorded so that ~div-free steady state flux can be computed
-
pyharm.ana.analyses.gridtotals(dump, out)¶ Total energy and current, summed by shells to allow any cut on radius
-
pyharm.ana.analyses.jet_cut_lite(dump, out, **kwargs)¶ Compute jet powers with just the default cut from EHTC Paper V ‘19. These are the powers used in the table in that paper and the MAD Code Comparison ‘22
-
pyharm.ana.analyses.jet_cuts(dump, out, **kwargs)¶ Blandford-Znajek Luminosity L_BZ, calculated with a sampling of different cuts floated for EHTC V ‘19
-
pyharm.ana.analyses.jet_profile(dump, out, **kwargs)¶ Theta profiles of many (many) different variables at some particular radius. Used to gauge what is/isn’t jet and where it wanders
-
pyharm.ana.analyses.lumproxy(dump, out, **kwargs)¶ Luminosity proxy from GRMHD code comparison ‘19
-
pyharm.ana.analyses.madcc(dump, out, **kwargs)¶ Functions for MAD Code Comparison ‘22, nontrivial mandatory diagnostics. See that paper/doc for full descriptions
-
pyharm.ana.analyses.madcc_optional(dump, out, **kwargs)¶ Functions for MAD Code Comparison ‘22, optional diagnostics
-
pyharm.ana.analyses.omega_bz(dump, out, **kwargs)¶ Field rotation rate, for comparison against Blandford-Znajek prediction
-
pyharm.ana.analyses.omega_bz_advanced(dump, out, **kwargs)¶ A battery of different measurements of the Blandford-Znajek prediction of the B field rotation rate.
-
pyharm.ana.analyses.outfluxes(dump, out, **kwargs)¶ Outflowing portions of fluxes
-
pyharm.ana.analyses.pdfs(dump, out, **kwargs)¶ Probability density functions for certain variables. Even more likely than most analyses to be broken
-
pyharm.ana.analyses.print_divb(dump, out, **kwargs)¶ Just check divB. Used as a cursory check for restart file sanity
-
pyharm.ana.analyses.print_flags(dump, out, **kwargs)¶ Just check floor and failure flags. Used as a cursory check for run sanity
-
pyharm.ana.analyses.r_flux_profiles(dump, out, vars=('FM', 'FE', 'FL'), **kwargs)¶ Radial profiles of conserved mass, energy, angular momentum
-
pyharm.ana.analyses.r_profile_phi(dump, out, **kwargs)¶ Spherical and midplane magnetizations of radial shells, analogous to FM or FE for Phi_b
-
pyharm.ana.analyses.r_profiles(dump, out, vars=('rho', 'Pg', 'u^r', 'u^3', 'u_3', 'b', 'inv_beta', 'Ptot'), **kwargs)¶ Calculate Radial profiles, by averaging over phi and some portion of theta. Separate averages over the comparison “disk” portion and the rest of the domain, marked “notdisk”. Keeps time-dependent versions for averaging post-hoc
-
pyharm.ana.analyses.r_profiles_cc(dump, out, **kwargs)¶ Radial profiles of everything used in the MAD Code Comparison ‘22
-
pyharm.ana.analyses.rth_profiles(dump, out, vars=('betainv', 'rho', 'sigma', 'Theta'), **kwargs)¶ 2D profiles in r/th, time-averaged. Default betainv, rho, sigma, Theta
-
pyharm.ana.analyses.th_profiles(dump, out, vars=('inv_beta', 'sigma'), **kwargs)¶ Calculate any full-theta profiles: 5-zone radial averages starting from ‘rTh’ (also averaged in phi). Keeps time-dependent versions for averaging post-hoc
Reductions¶
Should (when) you want to add your own analysis operations, there are quite a few integrals and other reduction operations defined in pyharm already. Note you can also find sample usage in pyharm.ana.analyses.
The general interface for reductions is (dump, var, options) | dump: FluidDump object, generally pre-slice. | var: either the name of a variable to compute over the necessary slice, or a pre-sliced & computed variable of the right shape.
Other options as described below. Certain zone arguments with defaults are still necessary when a reduction is otherwise ambiguous!
-
pyharm.ana.reductions.corr_length_phi(R, interpolate=True)¶ Correlation “length” (angle) given a correlation function of r,phi
-
pyharm.ana.reductions.corr_midplane(var, norm=True, at_i1=None)¶ Angular correlation function at the midplane, of an array representing a variable in spherical-like coordinates r,th,phi
-
pyharm.ana.reductions.corr_midplane_direct(var, norm=True)¶ Alternate more volatile implementation of corr_midplane
-
pyharm.ana.reductions.flatten_thphi(dump, var, at=5, sum=False)¶ Return a th-phi slice or sum of var. Note sums are not GR-aware!
Parameters: - at – which rank in X1 to take data from.
- sum – whether to sum all ranks. Overrides ‘at’.
-
pyharm.ana.reductions.flatten_xy(dump, var, at=None, sum=False)¶ Return an X-Y slice or sum of var. Note sums are not GR-aware!
Parameters: - at – which rank in X2 to take data from, default N2//2
- sum – whether to sum all ranks. Overrides ‘at’.
-
pyharm.ana.reductions.flatten_xz(dump, var, at=None, sum=False, half_cut=False)¶ Return an X-Z slice or sum of var, generally for use in making a plot. By default takes both the 0-degree (right side) and 180-degree (left side) slices, to make a full slice across the pole. Note sums are not GR-aware!
Parameters: - at – which rank in X3 to take data from
- sum – whether to sum all ranks. Overrides ‘at’
- half_cut – just take the rank ‘at’, not its 180-degree opposite
-
pyharm.ana.reductions.get_i_slice(dump, r_min, r_max)¶ Calculate slice imin:imax for a given range in r
-
pyharm.ana.reductions.get_j_bounds(dump, th_min=1.0471975511965976, th_max=2.0943951023931953)¶ Calculate slice jmin:jmax for a given range in theta: returns tuple Defaults to EHT disk profile: pi/3 to 2pi/3
-
pyharm.ana.reductions.get_j_slice(dump, th_min=1.0471975511965976, th_max=2.0943951023931953)¶ Calculate slice jmin:jmax for a given range in theta: returns slice Defaults to EHT disk profile: pi/3 to 2pi/3
-
pyharm.ana.reductions.midplane_sum(dump, var, zones=2, **kwargs)¶ Average a few zones adjacent to midplane, then sum. Allows specifying an r_slice or i_slice within which to sum.
-
pyharm.ana.reductions.pspec(var, dt=5, window=0.33, half_overlap=False, bin='fib')¶ Power spectrum of a 1D timeseries, with various windows/binning. Currently only supports equally spaced times dt.
-
pyharm.ana.reductions.shell_avg(dump, var, **kwargs)¶ Average a variable over spherical shells. Returns a radial profile (array length N1) or single-shell average. See shell_sum for arguments.
-
pyharm.ana.reductions.shell_sum(dump, var, at_r=None, at_i=None, th_slice=None, j_slice=None, mask=None)¶ Sum a variable over spherical shells. Returns a radial profile (array length N1) or single-shell sum
Parameters: - at_r – Single radius at which to sum (nearest-neighbor smaller zone is used)
- at_zone – Specific radial zone at which to sum, for compatibility
- th_slice – Tuple of minimum and maximum theta value to sum
- j_slice – Tuple of x2 indices instead of specifying theta. Overrides th_slice
- mask – array of 1/0 of the post-slice size of ‘var’, which is multiplied with the result
-
pyharm.ana.reductions.sphere_avg(dump, var, **kwargs)¶ Average everything within a sphere, semi-sphere or thick spherical shell. See sphere_sum for arguments.
-
pyharm.ana.reductions.sphere_sum(dump, var, r_slice=None, i_slice=None, th_slice=None, j_slice=None, mask=None)¶ Sum everything within a sphere, semi-sphere, or thick spherical shell. Extents are specified optionally in r or i, and th or j, with indices taking precedence Mask is multiplied at the end
-
pyharm.ana.reductions.theta_profile(dump, var, start, zones_to_av=1, use_gdet=True, fold=True)¶ Profile in theta by averaging over phi at a particular radius (or average among a few close radii). Note that this function returns an array of size N2 if fold==False, N2//2 if fold==True
Parameters: - start – zone number to average at
- zones_to_av – number of zones to average, starting at ‘start’
- use_gdet – whether or not to make averaging GR-aware
- fold – whether to consider the system as symmetric about the midplane and average hemispheres
-
pyharm.ana.reductions.wrap(x)¶ Append the first rank in axis 1 again after the last rank in axis 1 (i.e. the angular index, after any reductions).
Useful when plotting zone-centered th or phi variables, as it allows shading of the region between ends of the array eliminating an ugly gap.