Exemplo n.º 1
0
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.º 2
0
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)
Exemplo n.º 3
0
def table_psfs():
    np.random.seed(12)
    s = create_image()
    sh = s.psf.shape

    lpsfs = [
        psfs.IdentityPSF(shape=sh, params=np.array([0.0])),
        psfs.AnisotropicGaussian(shape=sh, params=(2.0, 1.0, 3.0)),
        psfs.Gaussian4DLegPoly(shape=sh, order=(3, 3, 3)),
        exactpsf.FixedSSChebLinePSF(
            shape=sh,
            zrange=(0, sh[0]),
            cheb_degree=3,
            cheb_evals=6,
            support_size=FIXEDSS,
            zslab=10.,
            cutoffval=1. / 255,
            measurement_iterations=3,
        ),
        exactpsf.FixedSSChebLinePSF(
            shape=sh,
            zrange=(0, sh[0]),
            cheb_degree=6,
            cheb_evals=8,
            support_size=FIXEDSS,
            zslab=10.,
            cutoffval=1. / 255,
            measurement_iterations=3,
        ),
    ]
    names = [
        r'Identity',
        r'Gaussian$(x,y)$',
        r'Gaussian$(x,y,z,z^{\prime})$',
        r'Cheby linescan (3,6)',
        r'Cheby linescan (6,8)',
    ]

    def vary_func(s, data):
        s.set_psf(data)

    return table(s, lpsfs, names, vary_func)
Exemplo n.º 4
0
def table():
    s = create_image(identity=True)

    lpoly = [0.0, 0.0, 0.01, 0.05, 0.10]
    dnames = ['0.0', '0.0', '0.01', '0.05', '0.10']

    lilms = [
        ilms.LegendrePoly2P1D(shape=s.ilm.shape, order=(1, 1, 1)),
        ilms.LegendrePoly2P1D(shape=s.ilm.shape, order=(3, 3, 3)),
        ilms.BarnesStreakLegPoly2P1DX3(shape=s.ilm.shape,
                                       order=(1, 1, 1),
                                       npts=(10, 5)),
        ilms.BarnesStreakLegPoly2P1DX3(shape=s.ilm.shape,
                                       order=(1, 1, 2),
                                       npts=(30, 10)),
        ilms.BarnesStreakLegPoly2P1DX3(shape=s.ilm.shape,
                                       order=s.ilm.order,
                                       npts=(30, 10, 5)),
    ]
    lnames = [
        r'Legendre 2+1D (0,0,0)',
        r'Legendre 2+1D (2,2,2)',
        r'Barnes (10, 5), $N_z=1$',
        r'Barnes (30, 10), $N_z=2$',
        r'Barnes (30, 10, 5), $N_z=3$',
    ]

    lpsfs = [
        psfs.IdentityPSF(shape=s.psf.shape, params=np.array([0.0])),
        psfs.AnisotropicGaussian(shape=s.psf.shape, params=(2.0, 1.0, 3.0)),
        psfs.Gaussian4DLegPoly(shape=s.psf.shape, order=(3, 3, 3)),
        exactpsf.FixedSSChebLinePSF(
            shape=s.psf.shape,
            zrange=(0, s.psf.shape[0]),
            cheb_degree=3,
            cheb_evals=6,
            support_size=FIXEDSS,
            zslab=10.,
            cutoffval=1. / 255,
            measurement_iterations=3,
        ),
        exactpsf.FixedSSChebLinePSF(
            shape=s.psf.shape,
            zrange=(0, s.psf.shape[0]),
            cheb_degree=6,
            cheb_evals=8,
            support_size=FIXEDSS,
            zslab=10.,
            cutoffval=1. / 255,
            measurement_iterations=3,
        ),
    ]
    pnames = [
        r'Identity',
        r'Gaussian$(x,y)$',
        r'Gaussian$(x,y,z,z^{\prime})$',
        r'Cheby linescan (3,6)',
        r'Cheby linescan (6,8)',
    ]

    results = OrderedDict()

    for i in xrange(len(lpoly)):
        print dnames[i], lnames[i], pnames[i]
        poly = lpoly[i]
        ilm = lilms[i]
        psf = lpsfs[i]

        s = create_image(polydispersity=poly)
        s.set_ilm(ilm)
        s.set_psf(psf)
        if isinstance(s.ilm, ilms.BarnesStreakLegPoly2P1DX3):
            s.ilm.randomize_parameters(ptp=0.4, vmax=1.0, fourier=False)
        s.reset()
        s.model_to_true_image()

        pos1 = trackpy(s)
        pos0 = s.obj.pos.copy()

        s.obj.set_pos_rad(pos1, s.obj.rad.mean() * np.ones(pos1.shape[0]))
        s.reset()

        slicer = s.get_difference_image().shape[0] / 2
        results[i] = (
            dnames[i],
            lnames[i],
            pnames[i],
            s.get_difference_image()[slicer].copy(),
            pos0,
            pos1,
        )

    return results
Exemplo n.º 5
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, tile = 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)