Class CUniformGrid handles a uniform grid of 3, 2 or 1 dimension (i.e. cuboid, plane or line segment, respectively). It is meant to be filled with data from the CBlockGrid object and written to a disk in various formats. The CUniformGrid axes are denoted by AXIS1, AXIS2 and AXIS3 constants, contrary to XAXIS, YAXIS and YAXIS of the CBlockGrid (in practice, both sets of constants are 0, 1, and 2, however, it is conceptually important to make difference when writing the code). The correspondence between the two systems of coordinates is controlled by the --mode command line argument and the axord - the uniform grid property and an argument of several methods. For instance, axord = (0,1,2) means one-to-one correspondence, or xy-plane integrated in the z direction; or axord = (1,2,0) is the yz-plane integrated in the x-direction, or the y-line segment integrated in the z and x directions. See table in the conv command description.
Constructor
- init(axes, axord, pos, quans, rlevel, bbox) - Args: axes is a tuple of axes (1dim npa) defining the uniform grid dimension and bbox; axord is the ordering of axes, a three element list mapping the CBlockGrid directions to the CUniformGrid directions; pos is a 3-element list defining the position of the uniform grid in the AMR grid (None means this dimension has only 1 element in the AMR grid, "RANGE" means that this direction is copied, a number defines the position); quans is a CQList object defining quantities of 4 types ('s', 'i', 'd', and 'n') being handled the the uniform grid; rlevel is the refinement level of the AMR grid to which the uniform grid corresponds; and bbox is the 3D bounding box (3D, because 1D/2D grids need to know integration ranges in normal directions).
Basic uniform grid properties
- axes - coordinate axes, a tuple of 1, 2 or 3 npa(dir) arrays
- axord - ordering of the axes (see above)
- bbox - bounding box, npa(dir,LO/HI)
- cs - cell size in individual directions, npa(dim)
- dim - dimensionality of the uniform grid, integer
- quans - list of quantities stored in this object, class CQList object
- pos - a 3-element list defining the position of the uniform grid in the AMR grid (see above in the constructor)
- rlevel - refinement level of the related AMR grid (class CBlockGrid), integer
- shape - shape of the uniform grid, i.e. number of grid cells along each axis, list of integers
Derived uniform grid properties and their calculations
- getBlockGridBox(integr, mincs) - Determines 3D box for the associated CBlockGrid object taking into account whether an integration or a cut should be made. Used by the CBlockGrid objects to determine list of blocks to be read and ranges of integration. Args: integr is logical determining whether to integrate (True) or to make cut (False); mincs is the minimum cell size of the CBlockGrid (npa(dir)). Ret: npa(dir,LO/HI), ordering of axes is X, Y, Z (CBlockGrid).
Manipulation with uniform grid data
- insertBlock(block, aslice, mask = None) - Inserts a block to a given position in the uniform grid. The block must have the same dimension and grid cell size as the uniform grid. Args: block is the 1, 2 or 3 dimensional block (npa(dir1[, dir2[, dir3]], quans)); aslice is a list of dim+1 slices defining the osition of the insertion; mask is an integer added to the "mask quantity" to the same position as the block.
- cumCalc() - Calculates cumulative sums and products of all c-quantities in the internal quans list.
Input / output
- writeAsc() - Write the uniform grid into an ascii file. It uses gnuplot compatible format, i.e. it skips a line after a change in the 2nd dimension, and 2 lines after a change in the 3rd dimension. Args: fn is the file name (string). Ret: nothing.
- writeFits