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 EndpointFile(filename, verbose=False)[source]

Bases: object

EndpointFile Class.

Parameters
  • filename (string) – Name of the endpoint file

  • verbose (bool) – Write information to the screen. Default is False.

Examples

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

Get endpoint data from the endpoint file for all endpoints.

Returns

ra – A numpy recarray with the endpoint particle data

Return type

numpy record array

Notes

Examples

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

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 – A numpy recarray with the endpoint particle data for endpoint partid.

Return type

numpy record array

Notes

Examples

>>> import flopy
>>> endobj = flopy.utils.EndpointFile('model.mpend')
>>> e1 = endobj.get_data(partid=1)
get_destination_endpoint_data(dest_cells, source=False)[source]

Get endpoint data that terminate in a set of destination cells.

Parameters
  • dest_cells (list or array of tuples) – (k, i, j) of each destination cell for MODPATH versions less than MODPATH 7 or node number of each destination cell. (zero based)

  • source (bool) – Boolean to specify is dest_cells applies to source or destination cells (default is False).

Returns

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

Return type

np.recarray

Examples

>>> import flopy
>>> e = flopy.utils.EndpointFile('modpath.endpoint')
>>> e0 = e.get_destination_endpoint_data([(0, 0, 0),
...                                       (1, 0, 0)])
get_maxid()[source]

Get the maximum endpoint particle id in the file endpoint file

Returns

out – Maximum endpoint particle id.

Return type

int

get_maxtime()[source]

Get the maximum time in the endpoint file

Returns

out – Maximum endpoint time.

Return type

float

get_maxtraveltime()[source]

Get the maximum travel time in the endpoint file

Returns

out – Maximum endpoint travel time.

Return type

float

kijnames = ['k0', 'i0', 'j0', 'node0', 'k', 'i', 'j', 'node', 'particleid', 'particlegroup', 'particleidloc', 'zone0', 'zone']
write_shapefile(endpoint_data=None, shpname='endpoints.shp', direction='ending', mg=None, epsg=None, **kwargs)[source]

Write particle starting / ending locations to shapefile.

endpoint_datanp.recarray

Record array of same form as that returned by EndpointFile.get_alldata. (if none, EndpointFile.get_alldata() is exported).

shpnamestr

File path for shapefile

directionstr

String defining if starting or ending particle locations should be considered. (default is ‘ending’)

mgflopy.discretization.grid instance

Used to scale and rotate Global x,y,z values in MODPATH Endpoint file.

epsgint

EPSG code for writing projection (.prj) file. If this is not supplied, the proj4 string or epgs code associated with mg will be used.

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

class PathlineFile(filename, verbose=False)[source]

Bases: flopy.utils.modpathfile._ModpathSeries

PathlineFile Class.

Parameters
  • filename (string) – Name of the pathline file

  • verbose (bool) – Write information to the screen. Default is False.

Examples

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

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 recarrays with the x, y, z, time, k, and particleid for all pathlines.

Return type

a list of numpy record array

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)[source]

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 – A numpy recarray with the x, y, z, time, k, and particleid for pathline partid.

Return type

numpy record array

Notes

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, to_recarray=False)[source]

Get pathline data that pass through a set of destination cells.

Parameters
  • dest_cells (list or array of tuples) – (k, i, j) of each destination cell for MODPATH versions less than MODPATH 7 or node number of each destination cell. (zero based)

  • to_recarray (bool) – Boolean that controls returned pthldest. If to_recarray is True, a single recarray with all of the pathlines that intersect dest_cells are returned. If to_recarray is False, a list of recarrays (the same form as returned by get_alldata method) that intersect dest_cells are returned (default is False).

Returns

pthldest – Slice of pathline data array (e.g. PathlineFile._data) containing only pathlines that pass through (k,i,j) or (node) dest_cells.

Return type

np.recarray

Examples

>>> import flopy
>>> p = flopy.utils.PathlineFile('modpath.pathline')
>>> p0 = p.get_destination_pathline_data([(0, 0, 0),
...                                       (1, 0, 0)])
get_maxid()[source]

Get the maximum pathline number in the file pathline file

Returns

out – Maximum pathline number.

Return type

int

get_maxtime()[source]

Get the maximum time in pathline file

Returns

out – Maximum pathline time.

Return type

float

kijnames = ['k', 'i', 'j', 'node', 'particleid', 'particlegroup', 'linesegmentindex', 'particleidloc', 'sequencenumber']
write_shapefile(pathline_data=None, one_per_particle=True, direction='ending', shpname='pathlines.shp', mg=None, epsg=None, **kwargs)[source]

Write pathlines to a shapefile

pathline_datanp.recarray

Record array of same form as that returned by PathlineFile.get_alldata(). (if none, PathlineFile.get_alldata() is exported).

one_per_particleboolean (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.

directionstr

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’)

shpnamestr

File path for shapefile

mgflopy.discretization.grid instance

Used to scale and rotate Global x,y,z values in MODPATH Pathline file.

epsgint

EPSG code for writing projection (.prj) file. If this is not supplied, the proj4 string or epgs code associated with mg will be used.

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

class TimeseriesFile(filename, verbose=False)[source]

Bases: flopy.utils.modpathfile._ModpathSeries

TimeseriesFile Class.

Parameters
  • filename (string) – Name of the timeseries file

  • verbose (bool) – Write information to the screen. Default is False.

Examples

>>> import flopy
>>> tsobj = flopy.utils.TimeseriesFile('model.timeseries')
>>> ts1 = tsobj.get_data(partid=1)
get_alldata(totim=None, ge=True)[source]

get timeseries data from the timeseries file for all timeseries and all times.

Parameters
  • totim (float) – The simulation time. All timeseries points for timeseries 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 timeseries times greater than or equal to or less than or equal to totim is used to create a subset of timeseries. Default is True.

Returns

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

Return type

a list of numpy record array

Examples

>>> import flopy
>>> tsobj = flopy.utils.TimeseriesFile('model.timeseries')
>>> ts = tsobj.get_alldata()
get_data(partid=0, totim=None, ge=True)[source]

get timeseries data from the timeseries file for a single timeseries particleid.

Parameters
  • partid (int) – The zero-based particle id. The first record is record 0.

  • totim (float) – The simulation time. All timeseries 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 timeseries times greater than or equal to or less than or equal to totim is used to create a subset of timeseries. Default is True.

Returns

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

Return type

numpy record array

Notes

Examples

>>> import flopy
>>> tsobj = flopy.utils.TimeseriesFile('model.timeseries')
>>> ts1 = tsobj.get_data(partid=1)
get_destination_timeseries_data(dest_cells)[source]

Get timeseries data that pass through a set of destination cells.

Parameters

dest_cells (list or array of tuples) – (k, i, j) of each destination cell for MODPATH versions less than MODPATH 7 or node number of each destination cell. (zero based)

Returns

tsdest – Slice of timeseries data array (e.g. TmeseriesFile._data) containing only timeseries that pass through (k,i,j) or (node) dest_cells.

Return type

np.recarray

Examples

>>> import flopy
>>> ts = flopy.utils.TimeseriesFile('modpath.timeseries')
>>> tss = ts.get_destination_timeseries_data([(0, 0, 0),
...                                           (1, 0, 0)])
get_maxid()[source]

Get the maximum timeseries number in the file timeseries file

Returns

out – Maximum pathline number.

Return type

int

get_maxtime()[source]

Get the maximum time in timeseries file

Returns

out – Maximum pathline time.

Return type

float

kijnames = ['k', 'i', 'j', 'node', 'particleid', 'particlegroup', 'particleidloc', 'timestep', 'timestepindex', 'timepointindex']
write_shapefile(timeseries_data=None, one_per_particle=True, direction='ending', shpname='pathlines.shp', mg=None, epsg=None, **kwargs)[source]

Write pathlines to a shapefile

timeseries_datanp.recarray

Record array of same form as that returned by Timeseries.get_alldata(). (if none, Timeseries.get_alldata() is exported).

one_per_particleboolean (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 Timeseries file). This option can be used to visualize attribute information (time, model layer, etc.) across a pathline in a GIS.

directionstr

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’)

shpnamestr

File path for shapefile

mgflopy.discretization.grid instance

Used to scale and rotate Global x,y,z values in MODPATH Timeseries file.

epsgint

EPSG code for writing projection (.prj) file. If this is not supplied, the proj4 string or epgs code associated with mg will be used.

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