Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename 2 to to #105

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/examples/02_surface_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"metadata": {},
"outputs": [],
"source": [
"sfw_grid = nlmod.mdims.gdf2grid(sfw, gwf)\n"
"sfw_grid = nlmod.mdims.gdf_to_grid(sfw, gwf)\n"
]
},
{
Expand Down Expand Up @@ -705,7 +705,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.7 ('artesia')",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -719,7 +719,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.4"
},
"vscode": {
"interpreter": {
Expand Down
28 changes: 14 additions & 14 deletions docs/examples/07_resampling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@
"source": [
"fig, axes = plt.subplots(ncols=4, figsize=(20,5))\n",
"\n",
"da1 = nlmod.mdims.gdf2data_array_struc(point_gdf, gwf, field='values', agg_method='max')\n",
"da2 = nlmod.mdims.gdf2data_array_struc(point_gdf, gwf, field='values', agg_method='mean')\n",
"da3 = nlmod.mdims.gdf2data_array_struc(point_gdf, gwf, field='values', agg_method='nearest')\n",
"da1 = nlmod.mdims.gdf_to_data_array_struc(point_gdf, gwf, field='values', agg_method='max')\n",
"da2 = nlmod.mdims.gdf_to_data_array_struc(point_gdf, gwf, field='values', agg_method='mean')\n",
"da3 = nlmod.mdims.gdf_to_data_array_struc(point_gdf, gwf, field='values', agg_method='nearest')\n",
"\n",
"vmin = min(da1.min(), da2.min(), da3.min())\n",
"vmax = max(da1.max(), da2.max(), da3.max())\n",
Expand Down Expand Up @@ -646,8 +646,8 @@
"source": [
"fig, axes = plt.subplots(ncols=3, figsize=(15,5))\n",
"\n",
"da1 = nlmod.mdims.gdf2data_array_struc(point_gdf, gwf, field='values', interp_method='nearest')\n",
"da2 = nlmod.mdims.gdf2data_array_struc(point_gdf, gwf, field='values', interp_method='linear')\n",
"da1 = nlmod.mdims.gdf_to_data_array_struc(point_gdf, gwf, field='values', interp_method='nearest')\n",
"da2 = nlmod.mdims.gdf_to_data_array_struc(point_gdf, gwf, field='values', interp_method='linear')\n",
"\n",
"vmin = min(da1.min(), da2.min())\n",
"vmax = max(da1.max(), da2.max())\n",
Expand Down Expand Up @@ -682,9 +682,9 @@
"source": [
"fig, axes = plt.subplots(ncols=4, figsize=(20,5))\n",
"\n",
"da1 = nlmod.mdims.gdf2data_array_struc(line_gdf, gwf, field='values', agg_method='max_length')\n",
"da2 = nlmod.mdims.gdf2data_array_struc(line_gdf, gwf, field='values', agg_method='length_weighted')\n",
"da3 = nlmod.mdims.gdf2data_array_struc(line_gdf, gwf, field='values', agg_method='nearest')\n",
"da1 = nlmod.mdims.gdf_to_data_array_struc(line_gdf, gwf, field='values', agg_method='max_length')\n",
"da2 = nlmod.mdims.gdf_to_data_array_struc(line_gdf, gwf, field='values', agg_method='length_weighted')\n",
"da3 = nlmod.mdims.gdf_to_data_array_struc(line_gdf, gwf, field='values', agg_method='nearest')\n",
"\n",
"vmin = min(da1.min(), da2.min(), da3.min())\n",
"vmax = max(da1.max(), da2.max(), da3.max())\n",
Expand Down Expand Up @@ -722,9 +722,9 @@
"source": [
"fig, axes = plt.subplots(ncols=4, figsize=(20,5))\n",
"\n",
"da1 = nlmod.mdims.gdf2data_array_struc(pol_gdf, gwf, field='values', agg_method='max_area')\n",
"da2 = nlmod.mdims.gdf2data_array_struc(pol_gdf, gwf, field='values', agg_method='area_weighted')\n",
"da3 = nlmod.mdims.gdf2data_array_struc(pol_gdf, gwf, field='values', agg_method='nearest')\n",
"da1 = nlmod.mdims.gdf_to_data_array_struc(pol_gdf, gwf, field='values', agg_method='max_area')\n",
"da2 = nlmod.mdims.gdf_to_data_array_struc(pol_gdf, gwf, field='values', agg_method='area_weighted')\n",
"da3 = nlmod.mdims.gdf_to_data_array_struc(pol_gdf, gwf, field='values', agg_method='nearest')\n",
"\n",
"vmin = min(da1.min(), da2.min(), da3.min())\n",
"vmax = max(da1.max(), da2.max(), da3.max())\n",
Expand Down Expand Up @@ -760,9 +760,9 @@
"metadata": {},
"outputs": [],
"source": [
"gdf_point_grid = nlmod.mdims.gdf2grid(point_gdf, gwf)\n",
"gdf_line_grid = nlmod.mdims.gdf2grid(line_gdf, gwf)\n",
"gdf_pol_grid = nlmod.mdims.gdf2grid(pol_gdf, gwf)"
"gdf_point_grid = nlmod.mdims.gdf_to_grid(point_gdf, gwf)\n",
"gdf_line_grid = nlmod.mdims.gdf_to_grid(line_gdf, gwf)\n",
"gdf_pol_grid = nlmod.mdims.gdf_to_grid(pol_gdf, gwf)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/09_schoonhoven.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
"\n",
"mg = nlmod.mgrid.modelgrid_from_ds(ds)\n",
"gi = flopy.utils.GridIntersect(mg, method=\"vertex\")\n",
"bgt_grid = nlmod.mdims.gdf2grid(bgt, ix=gi).set_index(\"cellid\")\n",
"bgt_grid = nlmod.mdims.gdf_to_grid(bgt, ix=gi).set_index(\"cellid\")\n",
"\n",
"bgt_grid[\"cond\"] = bgt_grid.area / bed_resistance\n",
"mask = bgt_grid[\"bronhouder\"] == \"L0002\"\n",
Expand Down Expand Up @@ -719,7 +719,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.7 ('artesia')",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -733,7 +733,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.4"
},
"vscode": {
"interpreter": {
Expand Down
2 changes: 1 addition & 1 deletion nlmod/gwf/horizontal_flow_barrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def line2hfb(gdf, gwf, prevent_rings=True, plot=False):
# for the idea, sea:
# https://gis.stackexchange.com/questions/188755/how-to-snap-a-road-network-to-a-hexagonal-grid-in-qgis

gdfg = mdims.gdf2grid(gdf, gwf)
gdfg = mdims.gdf_to_grid(gdf, gwf)

cell2d = pd.DataFrame(gwf.disv.cell2d.array).set_index("icell2d")
vertices = pd.DataFrame(gwf.disv.vertices.array).set_index("iv")
Expand Down
6 changes: 3 additions & 3 deletions nlmod/gwf/surface_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from shapely.geometry import Polygon
import flopy

# from ..mdims.mgrid import gdf2grid
# from ..mdims.mgrid import gdf_to_grid
from ..read import bgt, waterboard
from ..mdims import resample, mgrid

Expand Down Expand Up @@ -631,7 +631,7 @@ def get_gdf(ds=None, extent=None, fname_ahn=None):
extent = [bs[0], bs[2], bs[1], bs[3]]
gdf = add_stages_from_waterboards(gdf, extent=extent)
if ds is not None:
return mgrid.gdf2grid(gdf, ds).set_index("cellid")
return mgrid.gdf_to_grid(gdf, ds).set_index("cellid")
return gdf


Expand Down Expand Up @@ -695,7 +695,7 @@ def gdf_to_seasonal_pkg(
"""
if gdf.index.name != "cellid":
# if "cellid" not in gdf:
# gdf = gdf2grid(gdf, gwf)
# gdf = gdf_to_grid(gdf, gwf)
gdf = gdf.set_index("cellid")
else:
# make sure changes to the DataFrame are temporarily
Expand Down
11 changes: 6 additions & 5 deletions nlmod/mdims/mgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def polygon_to_area(modelgrid, polygon, da, gridtype="structured"):
return area_array


def gdf2data_array_struc(gdf, gwf, field="VALUE", agg_method=None, interp_method=None):
def gdf_to_data_array_struc(gdf, gwf, field="VALUE", agg_method=None, interp_method=None):
"""Project vector data on a structured grid. Aggregate data if multiple
geometries are in a single cell

Expand Down Expand Up @@ -685,7 +685,7 @@ def gdf2data_array_struc(gdf, gwf, field="VALUE", agg_method=None, interp_method

return da

gdf_cellid = gdf2grid(gdf, gwf)
gdf_cellid = gdf_to_grid(gdf, gwf)

if gdf_cellid.cellid.duplicated().any():
# aggregate data
Expand All @@ -709,7 +709,8 @@ def gdf2data_array_struc(gdf, gwf, field="VALUE", agg_method=None, interp_method

def gdf_to_da(gdf, ds, column, agg_method=None, fill_value=np.NaN):
"""Project vector data on a structured grid. Aggregate data if multiple
geometries are in a single cell. This method replaces gdf2data_array_struc.
geometries are in a single cell. This method replaces
gdf_to_data_array_struc.

Parameters
----------
Expand All @@ -733,7 +734,7 @@ def gdf_to_da(gdf, ds, column, agg_method=None, fill_value=np.NaN):
The DataArray with the projected vector data.

"""
gdf_cellid = gdf2grid(gdf, ds)
gdf_cellid = gdf_to_grid(gdf, ds)
if gdf_cellid.cellid.duplicated().any():
# aggregate data
if agg_method is None:
Expand Down Expand Up @@ -1037,7 +1038,7 @@ def gdf_to_bool_dataset(ds, gdf, mfgrid, da_name):
return ds_out


def gdf2grid(
def gdf_to_grid(
gdf,
ml=None,
method="vertex",
Expand Down