meshrefinement module

This was originally from Niki Zahdah. [Zad20b]

class gridtools.meshrefinement.MeshRefinement(shape=None, lon=None, lat=None, area=None, lon0=- 180.0, from_cell_center=False, rfl=0)

Bases: object

Describes 2D meshes for ESMs.

Meshes have shape=(nj,ni) cells with (nj+1,ni+1) vertices with coordinates (lon,lat).

When constructing, either provide 1d or 2d coordinates (lon,lat), or assume a uniform spherical grid with ‘shape’ cells covering the whole sphere with longitudes starting at lon0.


shape - (nj,ni) ni - number of cells in i-direction (last) nj - number of cells in j-direction (first) lon - longitude of mesh (cell corners), shape (nj+1,ni=1) lat - latitude of mesh (cell corners), shape (nj+1,ni=1) area - area of cells, shape (nj,ni)


Set the height for lower level Mesh by coarsening


Dump Mesh to tty.

find_nn_uniform_source(lon, lat)

Returns the i,j arrays for the indexes of the nearest neighbor point to grid (lon,lat)

least_square_plane_estimate(xs, ys, zs)

This function returns the estimates for h2 and h and also mean,min,max of the date in each grid cell.


Returns positive distance modulo 360.

pcolormesh(axis, data, **kwargs)
plot(axis, subsample=1, linecolor='k', **kwargs)
refine_loop(src_lon, src_lat, max_stages=32, max_mb=500, verbose=True, singularity_radius=0.25)

Repeatedly refines the mesh until all cells in the source grid are intercepted by mesh nodes. Returns a list of the refined meshes starting with parent mesh.


Returns new Mesh instance with twice the resolution

rotate(y_rot=0, z_rot=0)

Sequentially apply a rotation about the Y-axis and then the Z-axis.

sample_source_data_on_target_mesh(xs, ys, zs)

Returns the array on target mesh with values equal to the nearest-neighbor source point data

source_hits(xs, ys, singularity_radius=0.25)

Returns an mask array of 1’s if a cell with center (xs,ys) is intercepted by a node on the mesh, 0 if no node falls in a cell

gridtools.meshrefinement.is_mesh_uniform(lon, lat)

Returns True if the input grid (lon,lat) is uniform and False otherwise