Grids#
- class up4.Grid(data=None, num_cells=[50, 50, 50], grid_style='cartesian', cell_size=None, limits=None, xlim=None, ylim=None, zlim=None)[source]#
Bases:
RustGrid
- static cartesian3d(cells, limit)#
Create a 3D cartesian grid with limits and spacing provided by user.
- Parameters:
- Returns:
- grid
Grid
A up4.Grid object with the same dimensions dimensions defined by user
- grid
- static cartesian3d_from_data(pydata, cells)#
Create a 3D cartesian grid with limits and spacing from a PyData object.
- cell_id(x, y, z)#
Return the cell id of a given position.
- cell_positions()#
Return the positions of all cells in the grid.
- Returns:
- positions
Tuple
(np.ndarray
) A tuple containing the 1D arrays of the x, y and z positions of the cells
- positions
- collapse(axis)#
Collapse the grid along an axis.
This is basically cell based depth averaging
- collapse_two(axis1, axis2)#
Collaps the grid along an axis This is basically cell based depth averaging.
- static cylindrical3d(cells, limit, mode='volume')#
Create a 3D cylindrical grid with limits provided by user.
- Parameters:
- cells
List
(int
) A list containing the number of cells in each direction. Must be of length 3
- limit
List
(float
) A list containing the limits of the grid in each direction. Must be of length 6 The order is [rmin, rmax, zmin, zmax, phimin, phimax]
- mode
str
, optional The mode of the grid. Can be “volume”. Other methods are not implemented yet, by default “volume”
- cells
- Returns:
- grid
Grid
A up4.Grid object with the same dimensions dimensions defined by user
- grid
- static cylindrical3d_from_data(pydata, cells, mode='volume')#
Create a 3D cylindrical grid with limits and spacing from a PyData object.
- Parameters:
- Returns:
- grid
Grid
A up4.Grid object with the same dimensions as the input data
- grid
- is_inside(position)#
Check if the particle is within the grid.
- plot(axis)#
Plot the grid using plotly plotter. A simple depth averaged plot.
- remove_outliers(mode, threshold)#
Detect outliers and remove them depending on the mode Three different modes are available: 1. Set the outlier to zero 2. Set the outlier to the threshold 3. Set the outlier to the mean of surrounding cells.
- shape()#
Return the shape of the grid.
- Returns:
- shape
List
(int
) A list containing the number of cells in each dimension.
- shape
- slice(axis, index)#
Return a slice of the grid as a numpy array.
- slice_pos(axis, position)#
Return a slice of the grid as a numpy array at a given position and axis.
- Parameters:
- axis
int
The axis to slice the grid on
- position
f64
The position of the slice
- axis
- to_numpy()#
Return the grid as a numpy array.
- Returns:
- grid
ndarray
A numpy array containing the grid-data with the same shape as grid
- grid
- weights_to_numpy()#
Return the weights of each cell as a numpy array.
- Returns:
- weights
ndarray
A numpy array containing the weights of each cell with the same shape as grid
- weights
- xpositions()#
Return the x-positions of the grid.
- Returns:
- x
ndarray
A numpy array containing the x-positions of the grid
- x