flopy.utils.modpathfile Module

Module to read MODPATH output files. The module contains two important classes that can be accessed by the user.

  • EndpointFile (ascii endpoint file)
  • PathlineFile (ascii pathline file)
class flopy.utils.modpathfile.EndpointFile(filename, verbose=False)

EndpointFile Class.

Parameters:

filename : string

Name of the endpoint file

verbose : bool

Write information to the screen. Default is False.

Notes

The EndpointFile class provides simple ways to retrieve MODPATH 6 endpoint data from a MODPATH 6 ascii endpoint file.

Examples

>>> import flopy
>>> endobj = flopy.utils.EndpointFile('model.mpend')
>>> e1 = endobj.get_data(partid=1)
get_alldata()

Get endpoint data from the endpoint file for all endpoints.

Returns:

ra : numpy record array

A numpy recarray with the endpoint particle data

Examples

>>> import flopy
>>> endobj = flopy.utils.EndpointFile('model.mpend')
>>> e = endobj.get_alldata()
get_data(partid=0)

Get endpoint data from the endpoint file for a single particle.

Parameters:

partid : int

The zero-based particle id. The first record is record 0. (default is 0)

Returns:

ra : numpy record array

A numpy recarray with the endpoint particle data for endpoint partid.

Examples

>>> import flopy
>>> endobj = flopy.utils.EndpointFile('model.mpend')
>>> e1 = endobj.get_data(partid=1)
get_destination_endpoint_data(dest_cells)

Get endpoint data for set of destination cells.

Parameters:

dest_cells : list or array of tuples

(k, i, j) of each destination cell (zero-based)

Returns:

epdest : np.recarray

Slice of endpoint data array (e.g. EndpointFile.get_alldata) containing only data with final k,i,j in dest_cells.

get_maxid()

Get the maximum endpoint particle id in the file endpoint file

Returns:

out : int

Maximum endpoint particle id.

get_maxtime()

Get the maximum time in the endpoint file

Returns:

out : float

Maximum endpoint time.

get_maxtraveltime()

Get the maximum travel time in the endpoint file

Returns:

out : float

Maximum endpoint travel time.

write_shapefile(endpoint_data=None, shpname='endpoings.shp', direction='ending', sr=None, epsg=None, **kwargs)

Write particle starting / ending locations to shapefile.

endpoint_data
: np.recarry
Record array of same form as that returned by EndpointFile.get_alldata. (if none, EndpointFile.get_alldata() is exported).
shpname
: str
File path for shapefile
direction
: str
String defining if starting or ending particle locations should be considered. (default is ‘ending’)
sr
: flopy.utils.reference.SpatialReference instance
Used to scale and rotate Global x,y,z values in MODPATH Endpoint file
epsg
: int
EPSG code for writing projection (.prj) file. If this is not supplied, the proj4 string or epgs code associated with sr will be used.

kwargs : keyword arguments to flopy.export.shapefile_utils.recarray2shp

class flopy.utils.modpathfile.PathlineFile(filename, verbose=False)

PathlineFile Class.

Parameters:

filename : string

Name of the pathline file

verbose : bool

Write information to the screen. Default is False.

Notes

The PathlineFile class provides simple ways to retrieve MODPATH 6 pathline data from a MODPATH 6 ascii pathline file.

Examples

>>> import flopy
>>> pthobj = flopy.utils.PathlineFile('model.mppth')
>>> p1 = pthobj.get_data(partid=1)
get_alldata(totim=None, ge=True)

get pathline data from the pathline file for all pathlines and all times.

Parameters:

totim : float

The simulation time. All pathline points for particle partid that are greater than or equal to (ge=True) or less than or equal to (ge=False) totim will be returned. Default is None

ge : bool

Boolean that determines if pathline times greater than or equal to or less than or equal to totim is used to create a subset of pathlines. Default is True.

Returns:

plist : a list of numpy record array

A list of numpy recarrays with the x, y, z, time, k, and particleid for all pathlines.

Examples

>>> import flopy.utils.modpathfile as mpf
>>> pthobj = flopy.utils.PathlineFile('model.mppth')
>>> p = pthobj.get_alldata()
get_data(partid=0, totim=None, ge=True)

get pathline data from the pathline file for a single pathline.

Parameters:

partid : int

The zero-based particle id. The first record is record 0.

totim : float

The simulation time. All pathline points for particle partid that are greater than or equal to (ge=True) or less than or equal to (ge=False) totim will be returned. Default is None

ge : bool

Boolean that determines if pathline times greater than or equal to or less than or equal to totim is used to create a subset of pathlines. Default is True.

Returns:

ra : numpy record array

A numpy recarray with the x, y, z, time, k, and particleid for pathline partid.

Examples

>>> import flopy.utils.modpathfile as mpf
>>> pthobj = flopy.utils.PathlineFile('model.mppth')
>>> p1 = pthobj.get_data(partid=1)
get_destination_pathline_data(dest_cells)

Get pathline data for set of destination cells.

Parameters:

dest_cells : list or array of tuples

(k, i, j) of each destination cell (zero-based)

Returns:

pthldest : np.recarray

Slice of pathline data array (e.g. PathlineFile._data) containing only pathlines with final k,i,j in dest_cells.

get_maxid()

Get the maximum pathline number in the file pathline file

Returns:

out : int

Maximum pathline number.

get_maxtime()

Get the maximum time in pathline file

Returns:

out : float

Maximum pathline time.

write_shapefile(pathline_data=None, one_per_particle=True, direction='ending', shpname='endpoings.shp', sr=None, epsg=None, **kwargs)

Write pathlines to shapefile.

pathline_data
: np.recarry
Record array of same form as that returned by EndpointFile.get_alldata. (if none, EndpointFile.get_alldata() is exported).
one_per_particle
: boolean (default True)
True writes a single LineString with a single set of attribute data for each particle. False writes a record/geometry for each pathline segment (each row in the PathLine file). This option can be used to visualize attribute information (time, model layer, etc.) across a pathline in a GIS.
direction
: str
String defining if starting or ending particle locations should be included in shapefile attribute information. Only used if one_per_particle=False. (default is ‘ending’)
shpname
: str
File path for shapefile
sr
: flopy.utils.reference.SpatialReference instance
Used to scale and rotate Global x,y,z values in MODPATH Endpoint file
epsg
: int
EPSG code for writing projection (.prj) file. If this is not supplied, the proj4 string or epgs code associated with sr will be used.

kwargs : keyword arguments to flopy.export.shapefile_utils.recarray2shp