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

modelbuilder fix inexact latlon bbox #1066

Closed
4 tasks done
veenstrajelmer opened this issue Jan 17, 2025 · 0 comments · Fixed by #1067
Closed
4 tasks done

modelbuilder fix inexact latlon bbox #1066

veenstrajelmer opened this issue Jan 17, 2025 · 0 comments · Fixed by #1067

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Jan 17, 2025

After merging #1061, the modelbuilder downloads CMEMS data for a too small region. This is due to the fact that meshkernel does not stick to the exact bbox when generating the mesh. bbox code from dfmt.generate_bndpli_cutland():

import dfm_tools as dfmt
import numpy as np

crs = 'EPSG:4326' # coordinate reference system
lon_min, lon_max, lat_min, lat_max = 105.8, 106.85, 17.75, 18.5
dxy = 0.05

# generate spherical regular grid
mk = dfmt.make_basegrid(lon_min, lon_max, lat_min, lat_max, dx=dxy, dy=dxy, crs=crs)

# get bbox
mesh_bnds = mk.mesh2d_get_mesh_boundaries_as_polygons()
if mesh_bnds.geometry_separator in mesh_bnds.x_coordinates:
    raise Exception('use dfmt.generate_bndpli_cutland() on an uncut grid')
mesh_bnds_xy = np.c_[mesh_bnds.x_coordinates,mesh_bnds.y_coordinates]
bbox = (mesh_bnds.x_coordinates.min(), mesh_bnds.y_coordinates.min(), mesh_bnds.x_coordinates.max(), mesh_bnds.y_coordinates.max())
print(bbox)

Prints (xmin, ymin, xmax, ymax):

(105.8, 17.75, 106.85, 18.529811688024356)

So the max latitude is larger than requested.

Todo:

  • move bbox code to separate function
  • fix meshkernel imports in code so all classes are imported directly >> no, since we also use mk.__version__
  • overwrite lat/lons in modelbuilder notebook with meshkernel bbox
  • also fix in modelbuilder example script >> no, discontinue in discontinue modelbuilder example python script #1068
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