fix netlink contours for spherical grids

オープン
#296 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

Start with the spherical grid and netlink contour property path exercised by the reproduction, especially curvilinear_compute_rectangular_grid_on_extension, curvilinear_convert_to_mesh2d, and mesh2d_get_property. Compare contour widths in longitude and latitude against cell circumcenters for the supplied 0.3-degree grid. Done when spherical-grid contours reach the circumcenters in both directions.

索引モデルが issue の本文から書いたものです。

説明

bug

Describe the bug
When deriving the netlink contours for spherical grids, they seem too wide in the longitude direction, but they are as expected in the latitude direction.

To Reproduce

import xugrid as xu
from meshkernel.py_structures import Mesh2dProperty, Mesh2dLocation
import matplotlib.pyplot as plt

plt.close('all')
import numpy as np
from meshkernel import (
    MeshKernel,
    ProjectionType,
    GeometryList,
    MakeGridParameters,
    Mesh2dProperty,
    Mesh2dLocation,
)

# create basegrid
lon_min, lon_max, lat_min, lat_max = 1, 2, 48.5, 49.2
dxy = 0.3
make_grid_parameters = MakeGridParameters(
    origin_x=lon_min,
    origin_y=lat_min,
    upper_right_x=lon_max,
    upper_right_y=lat_max,
    block_size_x=dxy,
    block_size_y=dxy,
)
mk = MeshKernel(projection=ProjectionType.SPHERICAL)
mk.curvilinear_compute_rectangular_grid_on_extension(make_grid_parameters)
mk.curvilinear_convert_to_mesh2d()  # convert to ugrid/mesh2d

mesh2d = mk.mesh2d_get()

net_contour = mk.mesh2d_get_property(
    mesh2d_location=Mesh2dLocation.EDGES,
    property=Mesh2dProperty.NETLINK_CONTOUR_POLYGON,
)

fig, ax = plt.subplots(1, 1, sharex=True, sharey=True)
mesh2d.plot_edges(ax=ax)

# reshape netcontours
_LINK_CONTOUR_MAX_VERTICES = 4
n_edges = mesh2d.edge_nodes.size // 2
contour_x = np.asarray(net_contour.x_coordinates, dtype=np.float64).reshape(
    n_edges, _LINK_CONTOUR_MAX_VERTICES
)
contour_y = np.asarray(net_contour.y_coordinates, dtype=np.float64).reshape(
    n_edges, _LINK_CONTOUR_MAX_VERTICES
)
ncontours = range(len(contour_x))

for n, x, y in zip(ncontours, contour_x, contour_y):
    x = np.concatenate([x, [x[0]]])
    y = np.concatenate([y, [y[0]]])
    # only plot some of the netlink contours to not flood the figures
    if np.remainder(n, 8) != 0:
        continue
    # plt.text(np.mean(x), np.mean(y), str(n))
    ax.plot(x, y, "r")
ax.set_aspect("equal")
fig.tight_layout()
plt.show()

Gives the following figure:
image

Expected behavior
Netlink contours should reach until the circumcenter of the cells, which is the center in case of square cells.

Version info (please complete the following information):

  • OS: Windows
  • Version 8.4.1
主要言語
Python
スター
30
フォーク
5
平均マージ
1日 17時間
マージ済み PR(30日)
4

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Deltares/MeshKernelPy のほかの issue

Deltares/MeshKernelPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。