Skip to content

Commit

Permalink
deprecated open_dataset_extra and renamed to open_prepare_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Aug 30, 2024
1 parent 7beefb6 commit 12a56fb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 51 deletions.
48 changes: 3 additions & 45 deletions dfm_tools/deprecated.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,32 @@
def get_ncmodeldata(file_nc=None, varname=None, timestep=None, layer=None, depth=None, station=None, multipart=None, get_linkedgridinfo=False, silent=False):
"""
deprecated
"""
raise DeprecationWarning('dfmt.get_ncmodeldata() is deprecated, use `uds = dfmt.open_partitioned_dataset(file_nc)` instead: https://github.com/Deltares/dfm_tools/blob/main/notebooks/postprocessing_example.ipynb')


def get_netdata(file_nc=None, multipart=None):
"""
deprecated
"""
raise DeprecationWarning('dfmt.get_netdata() is deprecated, use `uds = dfmt.open_partitioned_dataset(file_nc)` instead: https://github.com/Deltares/dfm_tools/blob/main/notebooks/postprocessing_example.ipynb')


def plot_netmapdata(verts=None, values=None, ax=None, **kwargs):
"""
deprecated
"""
raise DeprecationWarning('dfmt.plot_netmapdata() is deprecated, use `uds = dfmt.open_partitioned_dataset(file_nc); uds.mesh2d_s1.isel(time=0).ugrid.plot()` instead: https://github.com/Deltares/dfm_tools/blob/main/notebooks/postprocessing_example.ipynb')


def plot_background(ax=None, projection=None, google_style='satellite', resolution=1, features=None, nticks=6, latlon_format=False, gridlines=False, **kwargs):
"""
deprecated
"""
raise DeprecationWarning('dfmt.plot_background() is deprecated, use contextily instead')


def get_ugrid_verts(data_xr_map=None):
"""
deprecated
"""
raise DeprecationWarning('dfmt.get_ugrid_verts() is deprecated, use uds.grid.face_node_coordinates instead (https://github.com/Deltares/xugrid/issues/48)')


def scatter_to_regulargrid(xcoords=None, ycoords=None, values=None, ncellx=None, ncelly=None, reg_x_vec=None, reg_y_vec=None, method='nearest', maskland_dist=None):
"""
deprecated
"""
raise DeprecationWarning('dfm_tools.regulargrid.scatter_to_regulargrid() is deprecated, use ds = dfmt.rasterize_ugrid(uds) instead')


def get_varnamefromattrs(data_xr=None, varname=None):
"""
deprecated
"""
raise DeprecationWarning('dfmt.get_varnamefromattrs() will be deprecated in a future version of dfm_tools, ds=dfmt.rename_waqvars(ds) is a more convenient alternative')


class Polygon:
"""
deprecated
"""
def __init__(self, data=None, name=None, comments=None):
raise DeprecationWarning('the function dfm_tools.polygon.Polygon() is deprecated, please use the new hydrolib alternative.')

Expand All @@ -59,51 +35,33 @@ def fromfile(self, file_pol=None, pd_output=False, tekmap_output=False):


def write_bcfile(filename=None, datablocks=None, metadatas=None, refdate=None, tzone=0, float_format='%6.2f'):
"""
deprecated
"""
raise DeprecationWarning('the function dfm_tools.io.bc.write_bcfile() is deprecated, please use the new hydrolib alternative. Example script: dfm_tools/tests/examples/CMEMS_interpolate_example.py')


def read_bcfile(filename=None, converttime=False):
"""
deprecated
"""
raise DeprecationWarning('the function dfm_tools.io.bc.read_bcfile() is deprecated, please use the new hydrolib alternative. Example script: dfm_tools/tests/examples/hydrolib_readbc.py')


def write_timfile(filename=None, datablock=None, header=None, converttime=False, refdate=None, float_format='%6.2f'):
"""
deprecated
"""
raise DeprecationWarning('the function dfm_tools.write_timfile() is deprecated, please use the new hydrolib alternative: https://github.com/Deltares/dfm_tools/blob/301-convert-timmodel-to-pandasdataframe/tests/examples/preprocess_hydrolib_readtim.py.')


def read_timfile(filename=None, converttime=False, refdate=None):
"""
deprecated
"""
raise DeprecationWarning('the function dfm_tools.read_timfile() is deprecated, please use the new hydrolib alternative: https://github.com/Deltares/dfm_tools/blob/301-convert-timmodel-to-pandasdataframe/tests/examples/preprocess_hydrolib_readtim.py.')


def generate_bndpli(**kwargs):
"""
deprecated
"""
raise DeprecationWarning('the function dfmt.generate_bndpli() is deprecated, please use dfmt.generate_bndpli_cutland() instead.')


def preprocess_hirlam(ds):
"""
deprecated
"""
raise DeprecationWarning('the function dfmt.preprocess_hirlam() is deprecated, xarray now supports datasets with multidimensional coordinates.')


def interp_regularnc_to_plipoints(ds):
"""
deprecated
"""
raise DeprecationWarning('the function dfmt.interp_regularnc_to_plipoints() is deprecated, '
'use dfmt.interp_regularnc_to_plipointsDataset() instead with gdf_points '
'as in https://github.com/Deltares/dfm_tools/issues/938')

def open_dataset_extra(**kwargs):
raise DeprecationWarning('the function dfmt.open_dataset_extra() is deprecated, dfmt.open_prepare_dataset() is similar but does not support multiple quantities at once')
2 changes: 1 addition & 1 deletion dfm_tools/interpolate_grid2bnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def ds_apply_conversion_dict(data_xr, conversion_dict, quantity):
return data_xr


def open_dataset_extra(dir_pattern, quantity, tstart, tstop, conversion_dict=None, refdate_str=None, chunks=None):
def open_prepare_dataset(dir_pattern, quantity, tstart, tstop, conversion_dict=None, refdate_str=None, chunks=None):
"""
empty docstring
"""
Expand Down
11 changes: 6 additions & 5 deletions dfm_tools/modelbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hydrolib.core.utils import get_path_style_for_current_operating_system
from dfm_tools.hydrolib_helpers import get_ncbnd_construct
from dfm_tools.interpolate_grid2bnd import (ext_add_boundary_object_per_polyline,
open_dataset_extra,
open_prepare_dataset,
ds_apply_conversion_dict,
)

Expand Down Expand Up @@ -64,10 +64,11 @@ def cmems_nc_to_bc(ext_bnd, list_quantities, tstart, tstop, file_pli, dir_patter
ncvarname = get_ncvarname(quantity=quantity_key, conversion_dict=conversion_dict)
dir_pattern_one = str(dir_pattern).format(ncvarname=ncvarname)
#open regulargridDataset and do some basic stuff (time selection, renaming depth/lat/lon/varname, converting units, etc)
data_xr_onevar = open_dataset_extra(dir_pattern=dir_pattern_one, quantity=quantity_key,
tstart=tstart, tstop=tstop,
conversion_dict=conversion_dict,
refdate_str=refdate_str)
data_xr_onevar = open_prepare_dataset(dir_pattern=dir_pattern_one,
quantity=quantity_key,
tstart=tstart, tstop=tstop,
conversion_dict=conversion_dict,
refdate_str=refdate_str)
if quantity_key == quantity_list[0]:
data_xr_vars = data_xr_onevar
else: # only relevant in case of ux/uy, others all have only one quantity
Expand Down
1 change: 1 addition & 0 deletions tests/test_get_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_polyline_mapslice():
assert np.isclose(uds_crs.grid.node_y.max(), 0.9261683648147339)


@pytest.mark.unittest
def test_get_dataset_atdepths_hisfile():

file_nc = dfmt.data.fm_grevelingen_his(return_filepath=True)
Expand Down

0 comments on commit 12a56fb

Please sign in to comment.