flopy.utils.particletrackfile module
Utilities for parsing particle tracking output files.
- class ParticleTrackFile(filename: str | PathLike, verbose: bool = False)[source]
Bases:
ABC
Abstract base class for particle track output files. Exposes a unified API supporting MODPATH versions 3, 5, 6 and 7, as well as MODFLOW 6 PRT models.
Notes
- Parameters:
- get_alldata(totim=None, ge=True, minimal=False)[source]
Get all particle tracks separately, optionally filtering by time.
- Parameters:
- Returns:
data – List of recarrays with dtype ParticleTrackFile.outdtype
- Return type:
list of numpy record arrays
- get_data(partid=0, totim=None, ge=True, minimal=False) recarray [source]
Get a single particle track, optionally filtering by time.
- Parameters:
partid (int) – Zero-based particle id. Default is 0.
totim (float) – The simulation time. Default is None.
ge (bool) – Filter tracking times greater than or equal to or less than or equal to totim. Only used if totim is not None.
minimal (bool) – Whether to return only the minimal, canonical fields. Default is False.
- Returns:
data – Recarray with dtype ParticleTrackFile.outdtype
- Return type:
np.recarray
- get_destination_data(dest_cells, to_recarray=True) recarray [source]
Get data for 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 series. 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:
data – Slice of data array (e.g. PathlineFile._data, TimeseriesFile._data) containing endpoint, pathline, or timeseries data that intersect (k,i,j) or (node) dest_cells.
- Return type:
np.recarray
- get_maxid() int [source]
Get the maximum particle ID.
- Returns:
out – Maximum particle ID.
- Return type:
- get_maxtime() float [source]
Get the maximum tracking time.
- Returns:
out – Maximum tracking time.
- Return type:
- abstract intersect(cells, to_recarray) recarray [source]
Find intersection of pathlines with cells.
- outdtype = dtype([('x', '<f4'), ('y', '<f4'), ('z', '<f4'), ('time', '<f4'), ('k', '<i4'), ('particleid', '<i4')])
Minimal information shared by all particle track file formats. Track data are converted to this dtype for internal storage and for return from (sub-)class methods.
- write_shapefile(data=None, one_per_particle=True, direction='ending', shpname='endpoints.shp', mg=None, crs=None, **kwargs)[source]
Write particle track data to a shapefile.
- datanp.recarray
Record array of same form as that returned by get_alldata(). (if none, 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.
- crspyproj.CRS, int, str, optional
Coordinate reference system (CRS) for the model grid (must be projected; geographic CRS are not supported). The value can be anything accepted by
pyproj.CRS.from_user_input()
, such as an authority string (eg “EPSG:26916”) or a WKT string.
kwargs : keyword arguments to flopy.export.shapefile_utils.recarray2shp
Deprecated since version 3.5: The following keyword options will be removed for FloPy 3.6:
epsg
(int): usecrs
instead.