polyTEM.crystal_peaks.flow_fields.define_subgrid

polyTEM.crystal_peaks.flow_fields.define_subgrid(a1_shape, a1_spacing, grid_density)

This function returns six functions that allow for easy conversion between cartesian coordinates, row-column coordinates, and subgrids within row-column coordinates. The properties of the grid only need to be entered once, and functions are returned that already know the grid’s shape.

These functions are written to be jit-compatible. Jit is a package that speeds up your code but can make debugging more difficult. Using jit created negligible speed gains, so I would recommend not using it for now, but it’s here for if the code becomes more demanding in the future.

Inputs:

a1_shape is the shape of a matrix, or “grid”, that you want to map onto cartesian coordinates. a1_spacing is the step size of the grid in cartesian units, i.e. 10nm. 2d array or tuple. grid_density is the number of subgrid units per grid unit. For example, a shape of (4, 5) yields a

subgrid that has 4 times as many rows and 5 times as many columns as the original grid.

Outputs:

grid_to_subgrid: function that takes matrix coordinates and returns coordinates on the finer subgrid subgrid_to_grid: inverse of grid_to_subgrid cart_to_grid: function that takes cartesian coordinates and returns the matching grid square as well as the

coordinates within that grid square

grid_to_cart: inverse of cart_to_grid cart_to_subgrid: function that takes cartesian coordinates and returns the matching subgrid square as well

as the coordinates within that subgrid square

subgrid_to_cart: inverse of cart_to_subgrid