Grids Tutorial#

Grids are one of the main parts in up4. They determine where (spatially) and in which way we want to have a look at the data. The grid is generated by the up4.Grid class.

Two different grid species are supported:

  1. Cartesian

  2. Cylindrical

the simplest way to generate a grid is to use up4.Grid.

Grid Generation#

Grids, cylindical and cartesian, can be generated in a variety of ways. To offer full flexiility one can generate grids in the following ways:

  • with an up4.Data object -> uses system dimensions to wrap around the region of interest
    • with cell number

    • with cell size

    • with cell number + x/y/z limits

    • with cell size + x/y/z limits

  • given a region of interest and a cell size or cell numbers

  • given x/y/z limitations and a cell size or cell numbers

Here some examples:

import up4
data = up4.Data("path/to/data.hdf5")

# Default grid, wraps the whole system with [50,50,50] cells
default_gird = up4.Grid(data)

# grid that wraps whole system with changed cell number
grid1 = up4.Grid(data, num_cells=[20,30,40])

# grid that wraps whole system with [50,50,50] cells but has some limitations in x-axis
# it only looks in the x-region around 100-200.4 mm
grid2 = up4.Grid(data, xlim=[100,200.4])

# same as before, however it has cells that are 5 mm cubes.
grid3 = up4.Grid(data, xlim=[100,200.4], cell_size = [5,5,5])

# grid in random space:
grid4 = up4.Grid(xlim=[100,200], ylim=[20,100], zlim=[100,300], cell_size=[3,3,3])

# print all grids:
print(f"default_gird:{default_gird}\ngrid1:{grid1}\ngrid2:{grid2}\ngrid3:{grid3}\ngrid4:{grid4}\n")

"""
    default_gird:Grid3D:
        Cells: [50, 50, 50]
        xlim: [174.02695648134886, 372.21089969650967]
        ylim: [74.71161491723201, 203.37554460929758]
        zlim: [52.291522049547666, 239.25612145076877]
        Data information:
                Mean: 0.0
                Std: 0.0
                Min: 0.0
                Max: 0.0
    grid1:Grid3D:
            Cells: [20, 30, 40]
            xlim: [174.02695648134886, 372.21089969650967]
            ylim: [74.71161491723201, 203.37554460929758]
            zlim: [52.291522049547666, 239.25612145076877]
            Data information:
                    Mean: 0.0
                    Std: 0.0
                    Min: 0.0
                    Max: 0.0
    grid2:Grid3D:
            Cells: [50, 50, 50]
            xlim: [100.0, 200.4]
            ylim: [74.71161491723201, 203.37554460929758]
            zlim: [52.291522049547666, 239.25612145076877]
            Data information:
                    Mean: 0.0
                    Std: 0.0
                    Min: 0.0
                    Max: 0.0
    grid3:Grid3D:
            Cells: [20, 25, 37]
            xlim: [100.0, 200.4]
            ylim: [74.71161491723201, 203.37554460929758]
            zlim: [52.291522049547666, 239.25612145076877]
            Data information:
                    Mean: 0.0
                    Std: 0.0
                    Min: 0.0
                    Max: 0.0
    grid4:Grid3D:
            Cells: [33, 26, 66]
            xlim: [100.0, 200.0]
            ylim: [20.0, 100.0]
            zlim: [100.0, 300.0]
            Data information:
                    Mean: 0.0
                    Std: 0.0
                    Min: 0.0
                    Max: 0.0
"""

All grids can be generated with: mode = "cylindrical" to generate a system in cylindrical coordinates. Those coordinates are then r, \(\theta\), z instead of x,y,z, in that order.

import up4
data = up4.Data("path/to/data.hdf5")
default_gird = up4.Grid(data, grid_style=  "cylindrical")

print(default_gird)
"""
Grid3D:
    Cells: [50, 50, 50]
    xlim: [0.0, 99.09197160758043]
    ylim: [-3.14159, 3.14159]
    zlim: [52.291522049547666, 239.25612145076877]
    Data information:
            Mean: 0.0
            Std: 0.0
            Min: 0.0
            Max: 0.0
"""

Grid Outlier Removal#