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

Add testcase for refine_basegrid #757

Closed
veenstrajelmer opened this issue Jan 31, 2024 · 0 comments · Fixed by #761
Closed

Add testcase for refine_basegrid #757

veenstrajelmer opened this issue Jan 31, 2024 · 0 comments · Fixed by #761

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Jan 31, 2024

Todo:

Start with something like this:

import xarray as xr
import dfm_tools as dfmt

# input
crs = 'EPSG:4326'

# domain and resolution
lon_min, lon_max, lat_min, lat_max = -68.55, -67.9, 11.8, 12.6
dxy = 0.05

# grid generation and refinement with GEBCO bathymetry
file_nc_bathy = r'http://opendap.deltares.nl/thredds/dodsC/opendap/deltares/Delft3D/netcdf_example_files/GEBCO_2022/GEBCO_2022_coarsefac08.nc'
data_bathy = xr.open_dataset(file_nc_bathy)
data_bathy_sel = data_bathy.sel(lon=slice(lon_min,lon_max),lat=slice(lat_min,lat_max))
data_bathy_sel["elevation"] = data_bathy_sel["elevation"].astype("int16")

# basegrid
mk_object = dfmt.make_basegrid(lon_min, lon_max, lat_min, lat_max, dx=dxy, dy=dxy, crs=crs)

# refine (fails if wrong type)
min_edge_size = 300 #in meters
dfmt.refine_basegrid(mk=mk_object, data_bathy_sel=data_bathy_sel, min_edge_size=min_edge_size)

# optional plot
import matplotlib.pyplot as plt
plt.close('all')
import contextily as ctx

fig, ax = plt.subplots()
mk_object.mesh2d_get().plot_edges(ax=ax,linewidth=1)
ctx.add_basemap(ax=ax, crs=crs, attribution=False)
dfmt.plot_coastlines(ax=ax, crs=crs)
@veenstrajelmer veenstrajelmer changed the title Add testcase for refine_ Add testcase for refine_basegrid Jan 31, 2024
@veenstrajelmer veenstrajelmer linked a pull request Feb 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant