5.18 Data manipulation

MGL command: hist RES xdat adat
MGL command: hist RES xdat ydat adat
MGL command: hist RES xdat ydat zdat adat
Method on mglGraph: mglData Hist (const mglDataA &x, const mglDataA &a, const char *opt="")
Method on mglGraph: mglData Hist (const mglDataA &x, const mglDataA &y, const mglDataA &a, const char *opt="")
Method on mglGraph: mglData Hist (const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &a, const char *opt="")
C function: HMDT mgl_hist_x (HMGL gr, HCDT x, HCDT a, const char *opt)
C function: HMDT mgl_hist_xy (HMGL gr, HCDT x, HCDT y, HCDT a, const char *opt)
C function: HMDT mgl_hist_xyz (HMGL gr, HCDT x, HCDT y, HCDT z, HCDT a, const char *opt)

These functions make distribution (histogram) of data. They do not draw the obtained data themselves. These functions can be useful if user have data defined for random points (for example, after PIC simulation) and he want to produce a plot which require regular data (defined on grid(s)). The range for grids is always selected as axis range. Arrays x, y, z define the positions (coordinates) of random points. Array a define the data value. Number of points in output array res is defined by option value (default is mglFitPnts=100).

MGL command: fill dat 'eq'
MGL command: fill dat 'eq' vdat
MGL command: fill dat 'eq' vdat wdat
Method on mglGraph: void Fill (mglData &u, const char *eq, const char *opt="")
Method on mglGraph: void Fill (mglData &u, const char *eq, const mglDataA &v, const char *opt="")
Method on mglGraph: void Fill (mglData &u, const char *eq, const mglDataA &v, const mglDataA &w, const char *opt="")
C function: void mgl_data_fill_eq (HMGL gr, HMDT u, const char *eq, HCDTv, HCDTw, const char *opt)

Fills the value of array ‘u’ according to the formula in string eq. Formula is an arbitrary expression depending on variables ‘x’, ‘y’, ‘z’, ‘u’, ‘v’, ‘w’. Coordinates ‘x’, ‘y’, ‘z’ are supposed to be normalized in axis range. Variable ‘u’ is the original value of the array. Variables ‘v’ and ‘w’ are values of arrays v, w which can be NULL (i.e. can be omitted).

MGL command: datagrid dat xdat ydat zdat
Method on mglGraph: void DataGrid (mglData &u, const mglDataA &x, const mglDataA &y, const mglDataA &z, const char *opt="")
C function: void mgl_data_grid (HMGL gr, HMDT u, HCDT x, HCDT y, HCDT z, const char *opt)

Fills the value of array ‘u’ according to the linear interpolation of triangulated surface, found for arbitrary placed points ‘x’, ‘y’, ‘z’. Interpolation is done at points equidistantly distributed in axis range. NAN value is used for grid points placed outside of triangulated surface. See Making regular data, for sample code and picture.

MGL command: refill dat xdat vdat [sl=-1]
MGL command: refill dat xdat ydat vdat [sl=-1]
MGL command: refill dat xdat ydat zdat vdat
Method on mglData: void Refill (mglDataA &dat, const mglDataA &x, const mglDataA &v, long sl=-1, const char *opt="")
Method on mglData: void Refill (mglDataA &dat, const mglDataA &x, const mglDataA &y, const mglDataA &v, long sl=-1, const char *opt="")
Method on mglData: void Refill (mglDataA &dat, const mglDataA &x, const mglDataA &y, const mglDataA &z, const mglDataA &v, const char *opt="")
C function: void mgl_data_refill_gr (HMGL gr, HMDT a, HCDT x, HCDT y, HCDT z, HCDT v, long sl, const char *opt)

Fills by interpolated values of array v at the point {x, y, z}={X[i], Y[j], Z[k]} (or {x, y, z}={X[i,j,k], Y[i,j,k], Z[i,j,k]} if x, y, z are not 1d arrays), where X,Y,Z are equidistantly distributed in axis range and have the same sizes as array dat. If parameter sl is 0 or positive then changes will be applied only for slice sl.

MGL command: pde RES 'ham' ini_re ini_im [dz=0.1 k0=100]
Method on mglGraph: mglData PDE (const char *ham, const mglDataA &ini_re, const mglDataA &ini_im, mreal dz=0.1, mreal k0=100, const char *opt="")
C function: HMDT mgl_pde_solve (HMGL gr, const char *ham, HCDT ini_re, HCDT ini_im, mreal dz, mreal k0, const char *opt)

Solves equation du/dz = i*k0*ham(p,q,x,y,z,|u|)[u], where p=-i/k0*d/dx, q=-i/k0*d/dy are pseudo-differential operators. Parameters ini_re, ini_im specify real and imaginary part of initial field distribution. Coordinates ‘x’, ‘y’, ‘z’ are supposed to be normalized in axis range. Note, that really this ranges are increased by factor 3/2 for purpose of reducing reflection from boundaries. Parameter dz set the step along evolutionary coordinate z. At this moment, simplified form of function ham is supported – all “mixed” terms (like ‘x*p’->x*d/dx) are excluded. For example, in 2D case this function is effectively ham = f(p,z) + g(x,z,u). However commutable combinations (like ‘x*q’->x*d/dy) are allowed. Here variable ‘u’ is used for field amplitude |u|. This allow one solve nonlinear problems – for example, for nonlinear Shrodinger equation you may set ham="p^2 + q^2 - u^2". You may specify imaginary part for wave absorption, like ham = "p^2 + i*x*(x>0)", but only if dependence on variable ‘i’ is linear (i.e. ham = hre+i*him). See PDE solving hints, for sample code and picture.