Skip to content

Commit

Permalink
moved function
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Oct 17, 2023
1 parent 5bdf1e6 commit 28fdd83
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
19 changes: 19 additions & 0 deletions dfm_tools/hydrolib_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,25 @@ def PolyFile_to_geodataframe_points(polyfile_object:hcdfm.PolyFile, crs:str=None
return gdf


def _da_from_gdf_points(gdf_points):

ncbnd_construct = get_ncbnd_construct()
dimn_point = ncbnd_construct['dimn_point']
varn_pointx = ncbnd_construct['varn_pointx']
varn_pointy = ncbnd_construct['varn_pointy']
varn_pointname = ncbnd_construct['varn_pointname']
attrs_pointx = ncbnd_construct['attrs_pointx']
attrs_pointy = ncbnd_construct['attrs_pointy']

da_plipoints = xr.Dataset()
da_plipoints[varn_pointx] = xr.DataArray(gdf_points.geometry.x.tolist(), dims=dimn_point).assign_attrs(attrs_pointx)
da_plipoints[varn_pointy] = xr.DataArray(gdf_points.geometry.y.tolist(), dims=dimn_point).assign_attrs(attrs_pointy)
da_plipoints[varn_pointname] = xr.DataArray(gdf_points[varn_pointname].tolist(), dims=dimn_point)
da_plipoints = da_plipoints.set_coords([varn_pointx,varn_pointy,varn_pointname])

return da_plipoints


def PolyFile_to_geodataframe_linestrings(polyfile_object, crs=None):
"""
empty docstring
Expand Down
29 changes: 5 additions & 24 deletions dfm_tools/interpolate_grid2bnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import os
import glob
import datetime as dt
import numpy as np
Expand All @@ -22,11 +21,12 @@
from dfm_tools.hydrolib_helpers import (Dataset_to_TimeSeries,
Dataset_to_T3D,
Dataset_to_Astronomic,
pointlike_to_DataFrame,
PolyFile_to_geodataframe_linestrings,
# pointlike_to_DataFrame,
# PolyFile_to_geodataframe_linestrings,
PolyFile_to_geodataframe_points,
gdf_linestrings_to_points,
get_ncbnd_construct)
# gdf_linestrings_to_points,
get_ncbnd_construct,
_da_from_gdf_points)
from dfm_tools.errors import OutOfRangeError


Expand Down Expand Up @@ -372,25 +372,6 @@ def interp_regularnc_to_plipoints(data_xr_reg, file_pli, nPoints=None, load=True
return data_interp


def _da_from_gdf_points(gdf_points):

ncbnd_construct = get_ncbnd_construct()
dimn_point = ncbnd_construct['dimn_point']
varn_pointx = ncbnd_construct['varn_pointx']
varn_pointy = ncbnd_construct['varn_pointy']
varn_pointname = ncbnd_construct['varn_pointname']
attrs_pointx = ncbnd_construct['attrs_pointx']
attrs_pointy = ncbnd_construct['attrs_pointy']

da_plipoints = xr.Dataset()
da_plipoints[varn_pointx] = xr.DataArray(gdf_points.geometry.x.tolist(), dims=dimn_point).assign_attrs(attrs_pointx)
da_plipoints[varn_pointy] = xr.DataArray(gdf_points.geometry.y.tolist(), dims=dimn_point).assign_attrs(attrs_pointy)
da_plipoints[varn_pointname] = xr.DataArray(gdf_points[varn_pointname].tolist(), dims=dimn_point)
da_plipoints = da_plipoints.set_coords([varn_pointx,varn_pointy,varn_pointname])

return da_plipoints


def interp_regularnc_to_plipointsDataset(data_xr_reg, gdf_points, load=True):

ncbnd_construct = get_ncbnd_construct()
Expand Down

0 comments on commit 28fdd83

Please sign in to comment.