Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Improve orthogonality of rotated spherical grid

Open
#113 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
matplotlib, numpy, python

Research direction

Start with the reproduction script and the MeshKernel entry points curvilinear_compute_rectangular_grid, curvilinear_convert_to_mesh2d, mesh2d_set, and mesh2d_get_orthogonality. Compare direct spherical generation with Cartesian generation followed by spherical conversion using the reported parameters. Done would require an agreed approach or documented result that addresses whether the target orthogonality is achievable.

Written by the indexing model from the issue text.

Description

enhancement

Feature Request
To be discussed. Is it possible to generate more orthogonal spherical rotated grids? When we generate a sperical rotated grid like the example below, it results in a max orthogonality of approximately 0.18. When we start with a cartesian grid (orthogonality of approximately 0) and set it on a spherical meshkernel instance, the orthogonality is 0.05

To Reproduce


import meshkernel
import numpy as np
import matplotlib.pyplot as plt
plt.close("all")
import dfm_tools as dfmt

lon_min, lon_max, lat_min, lat_max = 105.7, 106.59, 18.2, 18.46
dxy = 0.02
angle = -43

make_grid_parameters = meshkernel.MakeGridParameters(angle=angle,
                                                     origin_x=lon_min,
                                                     origin_y=lat_min,
                                                     num_columns=45,
                                                     num_rows=45,
                                                     block_size_x=dxy,
                                                     block_size_y=dxy)

fig,(ax1,ax2) = plt.subplots(1,2, figsize=(9,4))

# generate spherical rotated grid: max ortho 0.1642
mk0 = meshkernel.MeshKernel(projection=meshkernel.ProjectionType.SPHERICAL)
mk0.curvilinear_compute_rectangular_grid(make_grid_parameters)
mk0.curvilinear_convert_to_mesh2d() #convert to ugrid/mesh2d
ortho_values = mk0.mesh2d_get_orthogonality().values
ortho_values[ortho_values == -999] = np.nan
print(np.nanmin(ortho_values), np.nanmax(ortho_values))
mk0.mesh2d_get().plot_edges(ax=ax1)
dfmt.plot_coastlines(ax=ax1, aspect=None, min_area=1000)

# generate cartesian rotated grid: max ortho 1.272853350497083e-12
mk1 = meshkernel.MeshKernel(projection=meshkernel.ProjectionType.CARTESIAN)
mk1.curvilinear_compute_rectangular_grid(make_grid_parameters)
mk1.curvilinear_convert_to_mesh2d() #convert to ugrid/mesh2d
ortho_values = mk1.mesh2d_get_orthogonality().values
ortho_values[ortho_values == -999] = np.nan
print(np.nanmin(ortho_values), np.nanmax(ortho_values))

# convert to spherical: max ortho 0.0548
mk2 = meshkernel.MeshKernel(projection=meshkernel.ProjectionType.SPHERICAL)
mk2.mesh2d_set(mk1.mesh2d_get())
ortho_values = mk2.mesh2d_get_orthogonality().values
ortho_values[ortho_values == -999] = np.nan
print(np.nanmin(ortho_values), np.nanmax(ortho_values))
mk2.mesh2d_get().plot_edges(ax=ax2)
dfmt.plot_coastlines(ax=ax2, aspect=None, min_area=1000)

Resulting figure:
image

Reference RGFGRID grid: n:\Projects\11209500\11209671\B. Measurements and calculations\01_Updated_course_materials\02_exercises\Ex01_rectilinear_grd
Main difference is that in these course materials we start with cartesian, then convert to spherical. This also results in an orthogonality of 0.05. Would this also be possible if we start with spherical directly?

Version info (please complete the following information):

  • OS: Windows
  • Version 3.0.0
Dominant language
Python
Stars
27
Forks
5
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Deltares/MeshKernelPy

All issues in Deltares/MeshKernelPy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.