pp_utils
Pilot point support utilities
get_zoned_ppoints_for_vertexgrid(spacing, zone_array, mg, zone_number=None, add_buffer=True)
Generate equally spaced pilot points for active area of DISV type MODFLOW6 grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spacing
|
`float`
|
spacing in model length units between pilot points. |
required |
zone_array
|
`numpy.ndarray`
|
the modflow 6 idomain integer array. This is used to set pilot points only in active areas and to assign zone numbers. |
required |
mg
|
`flopy.discretization.vertexgrid.VertexGrid`
|
a VertexGrid flopy discretization derived type. |
required |
zone_number
|
`int`
|
zone number |
None
|
add_buffer
|
`boolean`
|
specifies whether pilot points ar eplaced within a buffer zone of size |
True
|
Returns:
| Type | Description |
|---|---|
|
|
Example::
get_zoned_ppoints_for_vertexgrid(spacing=100, ib=idomain, mg, zone_number=1, add_buffer=False)
pilot_points_from_shapefile(shapename)
read pilot points from shapefile into a dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapename
|
`str`
|
the shapefile name to read. |
required |
Notes
requires pyshp
pilot_points_to_tpl(pp_file, tpl_file=None, name_prefix=None)
write a template file for a pilot points file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pp_file
|
( |
required | |
tpl_file
|
`str`
|
template file name to write. If None,
|
None
|
name_prefix
|
`str`
|
name to prepend to parameter names for each
pilot point. For example, if |
None
|
Returns:
| Type | Description |
|---|---|
|
|
|
|
(name,x,y,zone,parval1) with the parameter information |
|
|
(parnme,tpl_str) |
Example::
pyemu.pp_utils.pilot_points_to_tpl("my_pps.dat",name_prefix="my_pps")
pp_file_to_dataframe(pp_filename)
read a space-delim pilot point file to a pandas Dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pp_filename
|
`str`
|
path and name of an existing pilot point file |
required |
Returns:
| Type | Description |
|---|---|
|
|
Example::
df = pyemu.pp_utils.pp_file_to_dataframe("my_pp.dat")
pp_tpl_to_dataframe(tpl_filename)
read a pilot points template file to a pandas dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tpl_filename
|
`str`
|
path and name of an existing pilot points template file |
required |
Returns:
| Type | Description |
|---|---|
|
|
Notes
Use for processing pilot points since the point point file itself may have generic "names".
Example::
df = pyemu.pp_utils.pp_tpl_file_to_dataframe("my_pp.dat.tpl")
prep_pp_hyperpars(file_tag, pp_filename, pp_info, out_filename, grid_dict, geostruct, arr_shape, pp_options, zone_array=None, ws='.')
Make preparation for hyperparameter ppu setup.
Writes files that to be used at apply time incl: ".gridinfo.dat" : target model cell location definition ".corrlen.dat", ".bearing.dat", ".aniso.dat", ".zone.dat" : arrays of hyperparamters to be used by calc_kriging_factors_2d() at apply time these arrays can also be paramterised (e.g. within a PstFrom add_pars setup).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_tag
|
str
|
tag for hyperpar files (will be cleaned of illegal chars) |
required |
pp_filename
|
str
|
pilot point file (filled by PEST) |
required |
pp_info
|
DataFrame
|
DataFrame of pilotpoint data -- written to pp_filename temporarily for testing apply_ppu_hyperpars func |
required |
out_filename
|
Path - like
|
Location of result of applying kriging interpolation after hyperpar factor calcs |
required |
grid_dict
|
dict
|
Dictionary of {node: (x,y)} for interp target. Note, sorted node keys defines the order for output arrays and of zone_array (if passed). |
required |
geostruct
|
GeoStruct
|
Geostructure used for filling initial hyperpar arrays. Note, Geostruct should only contain one variogram |
required |
arr_shape
|
(list - like, int)
|
shape of array in output file |
required |
pp_options
|
dict
|
Dictionary of pilot-point definition options to propagate to facotr calculation. Incl. "search_radius", "search_dist", "maxpts_interp", "minpts_interp", "fill_value" |
required |
zone_array
|
array - like
|
array of integer zonal values for target array locations. Default will be all target locations (in grid_dict) assigned to same zone. |
None
|
ws
|
Path - like
|
Location of saving files. |
'.'
|
Returns:
setup_pilotpoints_grid(ml=None, sr=None, ibound=None, prefix_dict=None, every_n_cell=4, ninst=1, use_ibound_zones=False, pp_dir='.', tpl_dir='.', shapename='pp.shp', pp_filename_dict={})
setup a regularly-spaced (gridded) pilot point parameterization
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ml
|
`flopy.mbase`
|
a flopy mbase derived type. If None, |
None
|
sr
|
`flopy.utils.reference.SpatialReference`
|
a spatial reference use to
locate the model grid in space. If None, |
None
|
ibound
|
`numpy.ndarray`
|
the modflow ibound integer array. THis is used to
set pilot points only in active areas. If None and ml is None, then pilot points
are set in all rows and columns according to |
None
|
prefix_dict
|
`dict`
|
a dictionary of layer index, pilot point parameter prefix(es) pairs.
For example : |
None
|
ninst
|
`int`
|
Number of instances of pilot_points to set up. e.g. number of layers. If ml is None and prefix_dict is None, this is used to set up default prefix_dict. |
1
|
use_ibound_zones
|
`bool`
|
a flag to use the greater-than-zero values in the ibound as pilot point zones. If False ,ibound values greater than zero are treated as a single zone. Default is False. |
False
|
pp_dir
|
`str`
|
directory to write pilot point files to. Default is '.' |
'.'
|
tpl_dir
|
`str`
|
directory to write pilot point template file to. Default is '.' |
'.'
|
shapename
|
`str`
|
name of shapefile to write that contains pilot point information. Default is "pp.shp" |
'pp.shp'
|
pp_filename_dict
|
`dict`
|
optional dict of prefix-pp filename pairs. prefix values must
match the values in |
{}
|
Returns:
| Type | Description |
|---|---|
|
|
|
|
written to |
Example::
m = flopy.modflow.Modflow.load("my.nam")
df = pyemu.pp_utils.setup_pilotpoints_grid(ml=m)
write_pp_file(filename, pp_df)
write a pilot points dataframe to a pilot points file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
`str`
|
pilot points file to write |
required |
pp_df
|
`pandas.DataFrame`
|
a dataframe that has at least columns "x","y","zone", and "value" |
required |
write_pp_shapfile(pp_df, shapename=None)
write pilot points dataframe to a shapefile
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pp_df
|
`pandas.DataFrame`
|
pilot point dataframe (must include "x" and "y"
columns). If |
required |
shapename
|
`str`
|
the shapefile name to write. If |
None
|
Notes
requires pyshp