peri/test/nbody.py
def create_configuration(N, tile, radius=5.0, **kwargs):
def initialize_particles(N=None, tile=None, phi=None, radius=5., polydispersity=0.):
    def __init__(self, pos, rad, tile, D=0.2, epsilon=10.0, dt=1e-1):
    def force_noise(self):
    def boundary_condition(self):
    def integrate(self, forces):
    def step(self, steps=100, mask=None):
    def relax(self, steps=1000):
    def force_hardsphere(self, mask=None):
    def neighbors(self, cutoff, indices=None):
        N = int(phi * vbox / vparticle)
class BrownianHardSphereSimulation(object):
peri/states.py
class UpdateError(Exception):
class State(comp.ParameterGroup):
        class _Statewrap(object):
class PolyFitState(State):
class ImageState(State, comp.ComponentCollection):
def sample(field, inds=None, slicer=None, flat=True):
    def __init__(self, params, values, logpriors=None, hyper_params=['sigma'],
                hyper_values=[0.04], **kwargs):
    def data(self):
    def model(self):
    def residuals(self):
    def error(self):
    def loglikelihood(self):
    def logposterior(self):
    def logprior(self):
    def update(self, params, values):
    def update_hyper(self, params, values):
    def update_sigma(self, sigma):
    def push_update(self, params, values):
    def pop_update(self):
    def temp_update(self, params, values):
    def param_all(self):
    def _grad_one_param(self, funct, p, dl=2e-5, rts=False, nout=1, **kwargs):
    def _hess_two_param(self, funct, p0, p1, dl=2e-5, rts=False, **kwargs):
    def _grad(self, funct, params=None, dl=2e-5, rts=False, nout=1, out=None,
            **kwargs):
    def _jtj(self, funct, params=None, dl=2e-5, rts=False, **kwargs):
    def _hess(self, funct, params=None, dl=2e-5, rts=False, **kwargs):
    def _dograddoc(self, f):
    def build_funcs(self):
        def m(inds=None, slicer=None, flat=True):
        def r(inds=None, slicer=None, flat=True):
        def l():
        def r_e(**kwargs):
        def m_e(**kwargs):
            def __init__(self, obj):
            def __getitem__(self, d=None):
    def crb(self, params=None, *args, **kwargs):
    def __str__(self):
    def __repr__(self):
    def __init__(self, x, y, order=2, coeffs=None, sigma=1.0):
    def update(self, params, values):
    def data(self):
    def model(self):
    def __init__(self, image, comps, mdl=models.ConfocalImageModel(), sigma=0.04,
            priors=None, pad=24, model_as_data=False):
    def set_model(self, mdl):
    def set_image(self, image):
    def set_tile_full(self):
    def model_to_data(self, sigma=0.0):
    def reset(self):
    def calculate_model(self):
    def data(self):
    def model(self):
    def residuals(self):
    def loglikelihood(self):
    def get_update_io_tiles(self, params, values):
    def update(self, params, values):
    def get(self, name):
    def set(self, name, obj):
    def _calc_model(self):
    def _calc_residuals(self):
    def _calc_logprior(self):
    def _calc_loglikelihood(self, model=None, tile=None):
    def update_sigma(self, sigma):
    def update_from_model_change(self, oldmodel, newmodel, tile):
    def exports(self):
    def register(self, parent):
    def __str__(self):
        def _pad(s):
    def __getstate__(self):
    def __setstate__(self, idct):
    def set_mem_level(self, mem_level='hi'):
def save(state, filename=None, desc='', extra=None):
def load(filename):
        N = np.size(self.data)
                J = j + i
peri/comp/comp.py
class GlobalScalar(Component):
    def __init__(self, name, value, shape=None):
        self.shape = shape
        super(GlobalScalar, self).__init__(
            [name], [value], ordered=False, category=name
        )

    def initargs(self):
        return {
            'name': self.params[0], 'value': self.values[0],
            'shape': self.shape
        }

    def get(self):
        return self.values[0]

    def get_update_tile(self, params, values):
        return self.shape
peri/runner.py
RLOG = logger.log.getChild('runner')
    I = ilms.LegendrePoly2P1D(order=order, constval=image.get_image().mean())
def locate_spheres(image, feature_rad, dofilter=False, order=(3 ,3, 3),
                    trim_edge=True, **kwargs):
def get_initial_featuring(statemaker, feature_rad, actual_rad=None,
        im_name=None, tile=None, invert=True, desc='', use_full_path=False,
        featuring_params={}, statemaker_kwargs={}, **kwargs):
def feature_from_pos_rad(statemaker, pos, rad, im_name=None, tile=None,
        desc='', use_full_path=False, statemaker_kwargs={}, **kwargs):
def optimize_from_initial(s, max_mem=1e9, invert='guess', desc='', rz_order=3,
        min_rad=None, max_rad=None):
def translate_featuring(state_name=None, im_name=None, use_full_path=False,
        **kwargs):
def get_particles_featuring(feature_rad, state_name=None, im_name=None,
        use_full_path=False, actual_rad=None, invert=True, featuring_params={},
        **kwargs):
def _pick_state_im_name(state_name, im_name, use_full_path=False):
def _translate_particles(s, max_mem=1e9, desc='', min_rad='calc',
        max_rad='calc', invert='guess', rz_order=0, do_polish=True):
def link_zscale(st):
def finish_state(st, desc='finish-state', invert='guess'):
peri/comp/psfs.py
class PSF(Component):
class IdentityPSF(PSF):
class AnisotropicGaussian(PSF):
class AnisotropicGaussianXYZ(PSF):
class PSF4D(PSF):
class Gaussian4D(PSF4D):
class Gaussian4DPoly(Gaussian4D):
class Gaussian4DLegPoly(Gaussian4DPoly):
class GaussianMomentExpansion(PSF4D):
class FromArray(PSF):
    def __init__(self, params, values, shape=None):
    def initialize(self):
    def calculate_kpsf(self, shape):
    def calculate_min_rpsf(self):
    def set_tile(self, tile):
    def update(self, params, values):
    def execute(self, field):
    def get(self):
    def get_update_tile(self, params, values):
    def get_padding_size(self, tile):
    def nopickle(self):
    def _rvecs(self, shape, centered=True):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __str__(self):
    def __repr__(self):
    def __init__(self):
    def set_tile(self, tile):
    def execute(self, field):
    def get_padding_size(self, tile):
    def update(self, params, values):
    def __init__(self, sigmas=(2.0, 1.0), error=1.0/255, shape=None):
    def rpsf_func(self, vecs):
    def get_padding_size(self, tile):
    def __init__(self, sigmas=(2.0, 0.5, 1.0), error=1.0/255, shape=None):
    def rpsf_func(self, vecs):
    def get_padding_size(self, tile):
    def __init__(self, params, values, shape=None):
    def rvecs(self, tile):
    def _zpos(self, tile):
    def _calc_tile_2d_psf(self, tile):
    def set_tile(self, tile):
    def update(self, params, values):
    def execute(self, field):
    def rpsf_xy(self, vecs, z):
    def rpsf_z(self, z, zp):
    def __init__(self, sigmas=(2.0,0.5,1.0), order=(1,1,1), error=1.0/255,
            zrange=128, shape=None):
    def _sigma_coeffs(self, d=0):
    def _poly(self, z, coeffs):
    def _sigma(self, z, d=0):
    def get_padding_size(self, tile, z=None):
    def rpsf_z(self, z, zp):
    def rpsf_xy(self, vecs, zp):
    def __init__(self, sigmas=(2.0,0.5,1.0), order=(1,1,1), shape=None,
            error=1.0/255, zrange=128):
    def _sigma_coeffs(self, d=0):
    def _poly(self, z, coeffs):
    def _sigma(self, z, d=0):
    def __init__(self, sigmas=(2.0,0.5,1.0), order=(1,1,1), error=1.0/255,
            zrange=128, shape=None):
    def _poly(self, z, coeffs):
    def __init__(self, sigmas=(2.0,0.5,1.0), order=(1,1,1),
            moment_order=(3,3), error=1.0/255, zrange=128, shape=None):
    def _sigma_coeffs(self, d=0):
    def _poly(self, z, coeffs):
    def _sigma(self, z, d=0):
    def _moment(self, x, z, d=0):
    def _kurtosis_coeffs(self, d):
    def _skew_coeffs(self, d):
    def _skew(self, x, z, d=0):
    def _kurtosis(self, x, z, d=0):
    def get_padding_size(self, tile, z=None):
    def rpsf_z(self, z, zp):
    def rpsf_xy(self, vecs, zp):
    def __init__(self, array, *args, **kwargs):
    def set_tile(self, tile):
    def _pad(self, field):
    def execute(self, field):
    def get_padding_size(self, tile, z=None):
peri/util.py
def oddify(num):
def listify(a):
def delistify(a, b=None):
def amin(a, b):
def amax(a, b):
def aN(a, dim=3, dtype='int'):
def getdtype(types):
def getdim(a):
def isint(dtype):
    def patch(self, var):
    def __init__(self, left, right=None, mins=None, maxs=None,
                 size=None, centered=False, dim=None, dtype='int'):
    def _build_caches(self):
    def slicer(self):
    def oslicer(self, tile):
    def shape(self):
    def bounds(self):
    def center(self):
    def volume(self):
    def kcenter(self):
    def corners(self):
    def _format_vector(self, vecs, form='broadcast'):
    def coords(self, norm=False, form='broadcast'):
    def kvectors(self, norm=False, form='broadcast', real=False, shift=False):
    def __str__(self):
    def __repr__(self):
    def contains(self, items, pad=0):
    def intersection(tiles, *args):
    def boundingtile(tiles, *args):
    def __eq__(self, other):
    def __ne__(self, other):
    def __and__(self, other):
    def __or__(self, other):
    def copy(self):
    def translate(self, dr):
    def pad(self, pad):
    def overhang(self, tile):
    def reflect_overhang(self, clip):
    def astype(self, dtype):
    def __getstate__(self):
    def __setstate__(self, idct):
    def __init__(self, image, tile=None, filters=None):
    def get_image(self):
    def get_padded_image(self, pad, padval=0):
    def filtered_image(self, im):
    def set_tile(self, tile):
    def set_filter(self, slices, values):
    def __repr__(self):
    def __str__(self):
    def __init__(self, image=None, shape=None):
    def __getstate__(self):
    def __setstate__(self, idct):
    def __repr__(self):
    def __str__(self):
    def __init__(self, filename, tile=None, invert=False, exposure=None,
            float_precision=np.float64):
    def load_image(self):
    def set_scale(self, exposure):
    def get_scale(self):
    def get_scale_from_raw(raw, scaled):
    def __getstate__(self):
    def __setstate__(self, idct):
    def __repr__(self):
    def __str__(self):
def cdd(d, k):
    def __init__(self, num, label='Progress', value=0, screen=79,
            time_remaining=True, bar=True, bar_symbol='=', bar_caps='[]',
            bar_decimals=2, display=True):
    def _estimate_time(self):
    def _draw(self):
    def increment(self):
    def update(self, value=0):
    def end(self):
def newcache():
def memoize(cache_max_size=1e9):
    def memoize_inner(obj):
        def wrapper(self, *args, **kwargs):
                def clear_cache(self):
def patch_docs(subclass, superclass):
def indir(path):
class CompatibilityPatch(object):
class Tile(CompatibilityPatch):
class Image(object):
class NullImage(Image):
class RawImage(Image, CompatibilityPatch):
class ProgressBar(object):
peri/comp/exactpsf.py
def moment(p, v, order=1):
    def __init__(self, shape=None, zrange=None, laser_wavelength=0.488,
            zslab=0., zscale=1.0, kfki=0.889, n2n1=1.44/1.518, alpha=1.173,
            polar_angle=0., pxsize=0.125, support_factor=2, normalize=False,
            sigkf=0.0, nkpts=None, cutoffval=None, measurement_iterations=None,
            k_dist='gaussian', use_J1=True, sph6_ab=None, global_zscale=False,
            cutbyval=False, cutfallrate=0.25, cutedgeval=1e-12,
            pinhole_width=None, do_pinhole=False, *args, **kwargs):
    def psffunc(self, *args, **kwargs):
    def zscale(self):
    def set_shape(self, shape, inner):
    def psf_slice(self, zint, size=11, zoffset=0., getextent=False):
    def todict(self):
    def pack_args(self):
    def _p2k(self, v):
    def _tz(self, z):
    def drift(self, z):
    def measure_size_drift(self, z, size=31, zoffset=0.):
    def characterize_psf(self):
    def get_padding_size(self, tile, z=None):
    def update(self, params, values):
    def update_values(self, params, values):
    def set_tile(self, tile):
    def _kpad(self, field, finalshape, zpad=False, norm=True):
    def execute(self, field):
    def nopickle(self):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __init__(self, shape=None, zrange=None, laser_wavelength=0.488, zslab=0.,
            zscale=1.0, kfki=0.889, n2n1=1.44/1.518, alpha=1.173, polar_angle=0.,
            pxsize=0.125, support_factor=2, normalize=False, sigkf=0.0,
            nkpts=None, cutoffval=None, measurement_iterations=None,
            k_dist='gaussian', use_J1=True, sph6_ab=None, global_zscale=False,
            cutbyval=False, cutfallrate=0.25, cutedgeval=1e-12,
            pinhole_width=None, do_pinhole=False, *args, **kwargs):
    def pack_args(self):
    def psffunc(self, *args, **kwargs):
    def __init__(self, shape=None, zrange=None, laser_wavelength=0.488, zslab=0.,
            zscale=1.0, kfki=0.889, n2n1=1.44/1.518, alpha=1.173, polar_angle=0.,
            pxsize=0.125, support_factor=2, normalize=False, sigkf=0.0,
            nkpts=None, cutoffval=None, measurement_iterations=None,
            k_dist='gaussian', use_J1=True, sph6_ab=None, global_zscale=False,
            cutbyval=False, cutfallrate=0.25, cutedgeval=1e-12,
            *args, **kwargs):
    def pack_args(self):
    def psffunc(self, x, y, z, **kwargs):
    def __init__(self, cheb_degree=6, cheb_evals=8, *args, **kwargs):
    def update(self, params, values):
    def psf(self, z):
    def execute(self, field):
    def __str__(self):
    def __init__(self, support_size=[35,17,25], *args, **kwargs):
    def characterize_psf(self):
    def __str__(self):
class ExactPSF(psfs.PSF):
class ExactLineScanConfocalPSF(ExactPSF):
class ExactPinholeConfocalPSF(ExactPSF):
class ChebyshevPSF(ExactPSF):
class FixedSSChebPSF(ChebyshevPSF):
class ChebyshevLineScanConfocalPSF(ChebyshevPSF, ExactLineScanConfocalPSF):
class FixedSSChebLinePSF(FixedSSChebPSF, ExactLineScanConfocalPSF):
class ChebyshevPinholeConfocalPSF(ChebyshevPSF, ExactPinholeConfocalPSF):
class FixedSSChebPinholePSF(FixedSSChebPSF, ExactPinholeConfocalPSF):
peri/comp/objs.py
MAX_VOLUME_ITERATIONS = 10
    N = self.N
class PlatonicParticlesCollection(Component):
class PlatonicSpheresCollection(PlatonicParticlesCollection):
class Slab(Component):
    def __init__(self, pos, shape=None, param_prefix='sph', category='obj',
                support_pad=4, float_precision=np.float64):
    def _draw_particle(self, pos, sign=1):
    def _update_type(self, params):
    def setup_variables(self):
    def get_values(self, params):
    def set_values(self, params, values):
    def add_particle(pos):
    def remove_particle(pos):
    def _drawargs(self):
    def _tile(self, n):
    def param_particle(self, ind):
    def exports(self):
    def _p2i(self, param):
    def initialize(self):
    def get(self):
    def N(self):
    def _vps(self, inds):
    def param_positions(self):
    def param_particle_pos(self, ind):
    def _trans(self, pos):
    def get_positions(self):
    def closest_particle(self, x):
    def params(self):
    def values(self):
    def _i2p(self, ind, coord):
    def get_update_tile(self, params, values):
    def update(self, params, values):
    def __str__(self):
def norm(a):
def inner(r, p, a, zscale=1.0):
def sphere_bool(dr, a, alpha):
def sphere_lerp(dr, a, alpha):
def sphere_logistic(dr, a, alpha):
def sphere_triangle_cdf(dr, a, alpha):
def sphere_analytical_gaussian(dr, a, alpha=0.2765):
def sphere_analytical_gaussian_trim(dr, a, alpha=0.2765, cut=1.6):
def sphere_analytical_gaussian_fast(dr, a, alpha=0.2765, cut=1.20):
def sphere_constrained_cubic(dr, a, alpha):
def exact_volume_sphere(rvec, pos, radius, zscale=1.0, volume_error=1e-5,
        function=sphere_analytical_gaussian, max_radius_change=1e-2, args=()):
    def __init__(self, pos, rad, shape=None, zscale=1.0, support_pad=4,
            method='exact-gaussian-fast', alpha=None, user_method=None,
            exact_volume=True, volume_error=1e-5, max_radius_change=1e-2,
            param_prefix='sph', grouping='particle', category='obj',
            float_precision=np.float64):
    def _drawargs(self):
    def setup_variables(self):
    def get_values(self, params):
    def set_values(self, params, values):
    def set_draw_method(self, method, alpha=None, user_method=None):
    def _draw_particle(self, pos, rad, sign=1):
    def param_radii(self):
    def param_particle(self, ind):
    def param_particle_pos(self, ind):
    def param_particle_rad(self, ind):
    def add_particle(self, pos, rad):
    def remove_particle(self, inds):
    def get_radii(self):
    def exports(self):
    def _p2i(self, param):
    def _update_type(self, params):
    def _tile(self, n):
    def update(self, params, values):
    def __str__(self):
    def __repr__(self):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __init__(self, zpos=0, angles=(0,0), param_prefix='slab', shape=None,
            float_precision=np.float64, category='obj'):
    def rmatrix(self):
    def normal(self):
    def _setup(self):
    def _draw_slab(self):
    def initialize(self):
    def set_tile(self, tile):
    def update(self, params, values):
    def get(self):
    def get_update_tile(self, params, values):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __str__(self):
    def __repr__(self):
peri/comp/ilms.py
class Polynomial3D(Component):
class LegendrePoly3D(Polynomial3D):
class Polynomial2P1D(Polynomial3D):
class LegendrePoly2P1D(Polynomial2P1D):
class ChebyshevPoly2P1D(Polynomial2P1D):
class BarnesPoly(Component, util.CompatibilityPatch):
class BarnesStreakLegPoly2P1D(BarnesPoly):
class BarnesXYLegPolyZ(BarnesPoly):
    def __init__(self, order=(1,1,1), tileinfo=None, constval=None,
            category='ilm', shape=None, float_precision=np.float64):
    def initialize(self):
    def rvecs(self):
    def term_ijk(self, index):
    def term(self, index):
    def set_tile(self, tile):
    def update(self, params, values):
    def get(self):
    def get_params(self):
    def get_update_tile(self, params, values):
    def nopickle(self):
    def __str__(self):
    def __repr__(self):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __init__(self, *args, **kwargs):
    def rvecs(self):
    def term_ijk(self, index):
    def __init__(self, order=(1,1,1), tileinfo=None, constval=None,
            operation='*', category='ilm', shape=None,
            float_precision=np.float64):
    def initialize(self):
    def calc_field(self):
    def term_ijk(self, index):
    def update(self, params, values):
    def nopickle(self):
    def __init__(self, order=(1,1,1), **kwargs):
    def rvecs(self):
    def term_ijk(self, index):
    def __init__(self, order=(1,1,1), **kwargs):
    def term_ijk(self, index):
    def __init__(self, npts=(40,20), zorder=7, op='*', barnes_dist=1.75,
            barnes_clip_size=3, local_updates=True, category='ilm', shape=None,
            float_precision=np.float64, donorm=True):
    def _setup_barnes_params(self):
    def _setup_rvecs(self):
    def _barnes(self, y):
    def _barnes_val(self):
    def _barnes_full(self):
    def get_update_tile(self, params, values):
    def randomize_parameters(self, params, values):
    def param_barnes_scales(self):
    def param_barnes_pts(self, ind=None):
    def param_barnes_poly(self):
    def _barnes_poly(self, n=0):
    def _term(self, index):
    def off(self):
    def scale(self):
    def calc_field(self):
    def calc_poly(self):
    def initialize(self):
    def set_tile(self, tile):
    def update(self, params, values):
    def get(self):
    def nopickle(self):
    def __str__(self):
    def __repr__(self):
    def __getstate__(self):
    def __setstate__(self, idict):
    def __init__(self, npts=(40,20), zorder=7, op='*', barnes_dist=1.75,
            barnes_clip_size=3, local_updates=True, category='ilm', shape=None,
            float_precision=np.float64, donorm=True):
    def _setup_barnes_params(self):
    def _setup_rvecs(self):
    def _barnes(self, y, n=0):
    def _barnes_val(self, n=0):
    def _barnes_full(self):
    def get_update_tile(self, params, values):
    def randomize_parameters(self, ptp=0.2, fourier=False, vmin=None, vmax=None):
    def __setstate__(self, idict):
    def __init__(self, npts=(40,20), zorder=7, op='*', barnes_dist=1.75,
            barnes_clip_size=3, category='ilm', shape=None,
            float_precision=np.float64):
    def _setup_barnes_params(self):
    def _barnes(self, pos):
    def _barnes_val(self):
    def _setup_rvecs(self):
    def _barnes_full(self):
    def get_update_tile(self, params, values):
    def randomize_parameters(self, **kwargs):
    def nopickle(self):
            N = len(p)
peri/viz/interaction.py
def make_clean_figure(figsize, remove_tooltips=False, remove_keybindings=False):
    def __init__(self, state, size=8, cmap_abs='bone', cmap_diff='RdBu',
            incsize=18.0, orientation=None, vrange_img=1.0, vrange_diff=0.1):
    def _format_ax(self, ax):
    def set_field(self):
    def draw(self):
    def draw_ortho(self, im, g, cmap=None, vmin=0, vmax=1):
    def register_events(self):
    def mouse_press_grab(self, event):
    def mouse_release_grab(self, event):
    def mouse_move_grab(self, event):
    def mouse_scroll_grab(self, event):
    def _pt_xyz(self, event):
    def mouse_press_view(self, event):
    def mouse_press_add(self, event):
    def mouse_press_remove(self, event):
    def mouse_press_optimize(self, event):
    def cycle(self, c, clist):
    def key_press_event(self, event):
    def __init__(self, field, onesided=True, vmin=None, vmax=None, cmap=None,
                 dohist=False, fourier=False, tooltips=False, size=8):
    def _format_ax(self, ax):
    def draw(self):
    def draw_ortho(self, im, g, cmap=None, vmin=0, vmax=1):
    def register_events(self):
    def _pt_xyz(self, event):
    def mouse_press_view(self, event):
    def __init__(self, image, pos, viewrad=None, cmap='Greys_r', part_col=
                [0., 1., 1., 1.], **kwargs):
    def _draw_im(self):
    def _particle_func(self, coords, pos, wid):
    def update_particle_field(self, poses=None, add=True):
    def update_field(self, poses=None):
    def draw_ortho(self, im, g, cmap=None, vmin=0, vmax=1):
    def register_events(self):
    def key_press_event(self, event):
    def mouse_press_add(self, event):
    def mouse_press_remove(self, event):
    def _remove_closest_particle(self, p):
    def _pt_xyz(self, event):
class OrthoManipulator(object):
class OrthoViewer(object):
class OrthoPrefeature(OrthoViewer):


Question: import pylab as pl
import numpy as np
from peri import states, runner, util
from peri.comp import psfs, objs, ilms, exactpsf, GlobalScalar
from peri.viz import interaction
from peri.test import nbody


im = util.NullImage(np.zeros((32,)*3))
pos, rad, tile = nbody.create_configuration(30, im.tile)

def make_image_0():
    P = objs.PlatonicSpheresCollection(pos, rad)
    H = psfs.AnisotropicGaussian()
    I = ilms.BarnesStreakLegPoly2P1D(npts=(20,10), local_updates=True)

Answer:     B = GlobalScalar('bkg', 0.0)