the libutil module

pNbody.libutil.Extract1dMeanFrom2dMap(x, y, mass, val, kx, ky, nmin, momentum=0)

Extract the mean along one axis, from a 2d mean or sigma matrix

x : pos in first dim. (beetween 0 and 1) y : pos in sec dim. (beetween 0 and 1) mass : mass of particles val : value to compute

kx : number of bins in x ky : number of bins in y

nmin : min number of particles needed to compute value

momentum : 0,1,2 (-1=number)

pNbody.libutil.GetMassMap(pos, mass, shape)
pNbody.libutil.GetMeanMap(m0, m1)

Return a MeanMap using the 0 and 1 momentum

m0 : zero momentum m1 : first momentum

pNbody.libutil.GetMeanValMap(pos, mass, val, shape)
pNbody.libutil.GetNumberMap(pos, shape)
pNbody.libutil.GetSigmaMap(m0, m1, m2)

Return a MeanMap using the 0 and 1 and 2 momentum

m0 : zero momentum m1 : first momentum m2 : second momentum

pNbody.libutil.GetSigmaValMap(pos, mass, val, shape)
pNbody.libutil.RotateAround(angle, axis, point, ObsM)

this should be C

pNbody.libutil.add_box(matint, shape=(256, 256), size=(30.0, 30.0), center=None, box_opts=(1, None, None, 255))

add a box on the frame

pNbody.libutil.apply_filter(mat, name=None, opt=None)

Apply a filter to an image

pNbody.libutil.compress_from_lst(x, num, lst, reject=False)

Return the compression of x

pNbody.libutil.contours(m, matint, nl, mn, mx, kx, ky, color, crush='no')

Compute iso-contours on a n x m float array. If “l_min” equal “l_max”, levels are automatically between the minimum and maximum values of the matrix “mat”.

m = matrice (real values) matint = matrice (interger values) kx = num of sub-boxes ky = num of sub-boxes nl = # of levels mn = min mx = max color = color of contours

pNbody.libutil.drawxticks(matint, m0, d0, n0, h0, shape, size, center, color)

draw x ticks in a matrix

pNbody.libutil.drawyticks(matint, m0, d0, n0, h0, shape, size, center, color)

draw x ticks in a matrix

pNbody.libutil.extract_parameters(arg, kw, defaultparams)

this function extract parameters given to a function it returns a dictionary of parameters with respective value

defaultparams : dictionary of default parameters

pNbody.libutil.get_eyes(x0, xp, alpha, dr)

Return the position of two eyes.

x0 : position of the head xp : looking point theta : rotation of the head dr : distance of the eyes

pNbody.libutil.get_image(mat, name=None, palette_name='light', mode='RGB')

Return an image (PIL object).

data : numpy 2x2 object name : name of the output palette_name : name of a palette

pNbody.libutil.geter(n, rmin, rmax, g, gm)

Generate a one dimentional non linear array of r

pNbody.libutil.geter2(n, rmin, rmax, g, gm)

Generate a one dimentional non linear array of r

pNbody.libutil.getr(nr=31, nt=32, rm=100.0)

Return a sequence of number (n x 1 array), where n=nr+1 defined by: Pfenniger & Friedli (1994)

pNbody.libutil.getval(nb, mode='m', obs=None)

For each point, return a specific value linked to this point

Parameters

mode

m : moment 0

0 : moment 0

x : first moment in x

y : first moment in y

z : first moment in z

Notes

Three types of values:

  1. scalar values

    pos,m,tem,u,rho,ne vx,vx2,vy,vy2,vz,vz2,vxyr,vxyr2,vxyt,vxyt2

  2. values computed with respect to xp

    z,z2 Lx,Ly,Lz,lx,ly,ly

  3. values computed with respect to absolute position in space

    empty for the moment (do not have the initial positions…)

pNbody.libutil.getvaltype(mode='m')

list values that depends on projection

pNbody.libutil.invgetr(r, nr=31, nt=32, rm=100.0)

From r, return the corresponding indexes. Inverse of getr function.

pNbody.libutil.log_filter(x, xmin, xmax, xc, kx=1.0)

map a value between 0 and kx

pNbody.libutil.log_filter_inv(k, xmin, xmax, xc, kx=1.0)

map a value betwen xmin and xmax

pNbody.libutil.mplot(mat, palette='light', save=None, marker=None, header=None)

plot a 2d array

pNbody.libutil.myhistogram(a, bins)

Return the histogram (n x 1 float array) of the n x 1 array “a”. “bins” (m x 1 array) specify the bins of the histogram.

pNbody.libutil.phys2img(shape, size, center, x, y)

convert physical position into the image pixel

pNbody.libutil.sbox(shape, size, lweight=1, xticks=None, yticks=None, color=255)

simple box

return a matrix of integer, containing a box with labels

xticks = (m0,d0,h0,m1,d1,h1)

0 = big 1 = small

m0,m1 = dist between ticks d0,d1 = first tick h0,h1 = height of the ticks

pNbody.libutil.set_ranges(mat, scale='log', mn=None, mx=None, cd=None)

Transform an n x m float array into an n x m int array that will be used to create an image. The float values are rescaled and cutted in order to range between 0 and 255.

mat : the matrice scale : lin or log mn : lower value for the cutoff mx : higer value for the cutoff cd : parameter

pNbody.libutil.tranfert_functions(rmin, rmax, g=None, gm=None)

This function computes the normalized transfer function from g and gm It is very useful to transform a linear vector in a non linear one

example of g:

g = lambda r:np.log(r/rc+1) gm = lambda r:rc*(np.exp(r)-1)

pNbody.libutil.vel_cart2cyl(pos, vel)

Transform velocities in carthesian coordinates vx,vy,vz into cylindrical coodinates vr,vz,vz. Pos is the position of particles in cart. coord. Vel is the velocity in cart. coord. Return a 3xn float array.

pNbody.libutil.vel_cyl2cart(pos=None, vel=None)

Transform velocities in cylindrical coordinates vr,vt,vz into carthesian coodinates vx,vy,vz. Pos is the position of particles in cart. coord. Vel is the velocity in cylindrical coord. Return a 3xn float array.