`angle` is not accepted in `curvilinear_make_uniform_on_extension`

Aperta
#74 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Inizia con lo script di riproduzione e gli entry point curvilinear_compute_rectangular_grid_on_extension e curvilinear_compute_rectangular_grid, quindi confronta il loro comportamento per una griglia sferica ruotata. Esamina la issue #113 per il contesto documentato sull’ortogonalità. Il lavoro è completato quando il percorso dell’estensione accetta l’angolo e produce l’estensione richiesta con un’ortogonalità accettabile, incluso un comportamento sensato per una rotazione di 90 gradi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Describe the bug
When using curvilinear_make_uniform_on_extension instead of curvilinear_make_uniform, angle is not an accepted keyword, it raises:

"MeshKernelError: Exception of type 'AlgorithmError' in libs/MeshKernelApi/include/MeshKernelApi/Utils.hpp (375:45) CreateUniformCurvilinearGridOnExtension: When generating an uniform grid on an defined extension, the grid angle must be equal to 0"

Also, when generating a spherical+rotated grid, the orthogonality is quite high (0.039 for this small extent)

To Reproduce

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

projection = meshkernel.ProjectionType.SPHERICAL #SPERICAL results in non-orthogonal grid (0.039)
on_extension = False #True is not possible with angle!=0

#general settings
lon_min,lon_max = -1,-0.2
lat_min,lat_max = 49.1,49.6
lon_res,lat_res = 0.1,0.1

# Create an instance of MakeGridParameters and set the values
make_grid_parameters = meshkernel.MakeGridParameters()
make_grid_parameters.angle = 10.0
make_grid_parameters.origin_x = lon_min
make_grid_parameters.origin_y = lat_min
if on_extension:
    make_grid_parameters.upper_right_x = lon_max
    make_grid_parameters.upper_right_y = lat_max
else:
    num_x = int(np.ceil((lon_max-lon_min)/lon_res))
    num_y = int(np.ceil((lat_max-lat_min)/lat_res))
    if projection == meshkernel.ProjectionType.SPHERICAL:
        num_y = num_y*2 #TODO: remove *2, necessary to get correct lat grid extent with is_geographic=True
    make_grid_parameters.num_columns = num_x
    make_grid_parameters.num_rows = num_y
make_grid_parameters.block_size_x = lon_res
make_grid_parameters.block_size_y = lat_res

mk2 = meshkernel.MeshKernel(projection=projection)
if on_extension:
    mk2.curvilinear_compute_rectangular_grid_on_extension(make_grid_parameters)
else:
    mk2.curvilinear_compute_rectangular_grid(make_grid_parameters)
mk2.curvilinear_convert_to_mesh2d() #convert to ugrid/mesh2d

mesh2d = mk2.mesh2d_get()
fig, ax = plt.subplots()
mesh2d.plot_edges(ax)
print(mk2.mesh2d_get_orthogonality().values.max())

Expected behavior
A rotated grid, also when using curvilinear_make_uniform_on_extension

Version info (please complete the following information):

Registered also under: https://issuetracker.deltares.nl/browse/GRIDEDIT-1859

Additional context
Spherical grids are sometimes used for small domains, but very often for larger coastal seas or bays. These are some use cases from the real world:

It would be neat if we could generate such meshes with curvilinear_make_uniform_on_extension. The acceptance criterion could be fairly straightforward: a mesh in the desired extent, with an acceptable orthogonality. Additionally, a 90 degree rotated grid should be fairly similar to 0 degree rotation, or we should limit the rotation between -45 degrees and +45 degrees.

More information about resulting orthogonality of the current algorithms is documented in https://github.com/Deltares/MeshKernelPy/issues/113.

Lingua principale
Python
Stelle
30
Fork
5
Merge medio
1g 17h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Deltares/MeshKernelPy

Tutte le issue di Deltares/MeshKernelPy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.