pymarthe.utils.grid_utils

Contains the MartheGrid class Handle single Marthe grid

Classes

MartheGrid

Class to handle Marthe single grid.

Module Contents

class pymarthe.utils.grid_utils.MartheGrid(istep, layer, inest, nrow, ncol, xl, yl, dx, dy, xcc, ycc, array, field=None)

Class to handle Marthe single grid.

get_cell_vertices(i, j, closed=False)

DOES NOT WORK PROPERLY!

to_records(fmt='light', base=0)

Convert grid values to flatten recarray.

Parameters:

fmt (str)output format.
Can be:
  • ‘light’ : output columns: ‘layer,inest,i,j,x,y,value’

  • ‘full’ : output columns: ‘node,layer,inest,i,j,x,y,dx,dy,vertices,value’

Default is ‘light’. Note: the ‘full’ format is obviously slower.

base (int)n-based array format
Can be :
  • 0 (Python)

  • 1 (Fortran)

Default is 0.

Returns:

Write data inplace. (record files, listm files, pastp file)

Examples:

mg.to_records(fmt=’light’)

to_string(maxlayer=None, maxnest=None, rlevel=None, keep_uniform_fmt=False)

Convert grid to a single string with Marthe Grid file format. Parameters: ———– maxlayer (int/None, optional) : maximum number of layer.

If None, value will be ‘0’. Default is None.

maxnest (int/None, optional)maximum number of nested grid.

If None, value will be ‘0’. Default is None.

rlevel (int/None, optional)refine level to extract adjacent

cells informations. Default is None.

keep_uniform_fmt (bool, optional)whatever to conserve marthe light format

for uniform grid. If True, light format will be conserved. If False, all grids will be written explictly. Default is False. /!/ CAREFULL /!/ keeping uniform light format on permh field can modify the model geometry.

Return:

lines_str (str)Marthe Grid string format

(ready to write)

Example

mygrid = MartheGrid(0, 0, 125, 126, 325., 750., dx, dy, xcc, ycc, array, field = ‘PERMEAB’) with open(‘mymarthegrid.prop’, ‘r’) as f:

f.write(mygrid.to_string())

to_pyshp()

Convert grid to list of polygons with vertices coordinates.

Parameters:

self (MartheGrid) : MartheGrid instance

Return:

pyshp_parts (list) = polygons parts with

xy-vertices coordinates.

Example

parts = mg.to_pyshp()

to_patches()

Convert grid to list of matplotlib.Path

Parameters:

self (MartheGrid) : MartheGrid instance

Return:

patches (list) = list of Path objects

Example

patches = mg.to_patches()

__str__()

Internal string method.