Exemplo n.º 1
0
def create_many_particle_state(imsize=None,
                               N=None,
                               phi=None,
                               radius=5.0,
                               polydispersity=0.0,
                               seed=None,
                               **kwargs):
    """
    Creates a random packing of spheres and generates the state. In order to
    specify the state, either (phi, imsize) or (N, phi) or (N, imsize) must be
    given. Any more than that and it would be over-specified.

    Parameters:
    -----------
    imsize : tuple, array_like, or integer
        the unpadded image size to fill with particles

    N : integer
        number of particles

    phi : float
        packing fraction

    radius : float
        radius of particles to add

    N : integer
        Number of particles

    seed : integer
        set the seed if desired

    *args, **kwargs : see create_state
    """
    _seed_or_not(seed)

    if imsize is not None:
        imsize = _toarr(imsize)
        tile = util.Tile(imsize)
    else:
        tile = None

    pos, rad, tile = nbody.create_configuration(N,
                                                tile,
                                                radius=radius,
                                                phi=phi,
                                                polydispersity=polydispersity)
    s = create_state(util.NullImage(shape=tile.shape), pos, rad, **kwargs)

    if isinstance(s.get('ilm'), ilms.BarnesStreakLegPoly2P1D):
        ilm = s.get('ilm')
        ilm.randomize_parameters()
        s.reset()
        s.model_to_data(s.sigma)
    return s
Exemplo n.º 2
0
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)
    B = GlobalScalar('bkg', 0.0)
    C = GlobalScalar('offset', 0.0)
    I.randomize_parameters()

    return states.ImageState(im, [B, I, H, P, C], pad=16, model_as_data=True)


def make_image_1():
    P = objs.PlatonicSpheresCollection(pos, rad)
    H = psfs.AnisotropicGaussian()
    I = ilms.LegendrePoly3D(order=(5, 3, 3), constval=1.0)
    B = ilms.Polynomial3D(order=(3, 1, 1), category='bkg', constval=0.01)
    C = GlobalScalar('offset', 0.0)

    return states.ImageState(im, [B, I, H, P, C], pad=16, model_as_data=True)
Exemplo n.º 3
0
from peri import states, util, models
from peri.comp import psfs, objs, ilms, GlobalScalar, ComponentCollection
from peri.test import nbody

import peri.opt.optimize as opt
import peri.opt.addsubtract as addsub

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

P = ComponentCollection(
    [objs.PlatonicSpheresCollection(pos, rad),
     objs.Slab(2)], category='obj')

H = psfs.AnisotropicGaussian()
I = ilms.BarnesStreakLegPoly2P1D(npts=(25, 13, 3),
                                 zorder=2,
                                 local_updates=False)
B = ilms.LegendrePoly2P1D(order=(3, 1, 1), category='bkg', constval=0.01)
C = GlobalScalar('offset', 0.0)
I.randomize_parameters()

s = states.ImageState(im, [B, I, H, P, C], pad=16, model_as_data=True)