question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

grid type testing 1 - Voronoi grids

See original GitHub issue

Since (I think) the switch onto the graph structures, we have some unexpected behaviour related to the grid types. Formerly, Hex and Radial were subclasses of VoronoiDelaunayGrid, and on this basis in several places we had type testing that looked like this:

>>> if isinstance(grid, RasterModelGrid):  # shorthand for "patches are square"
...     # stuff
>>> elif isinstance(grid, VoronoiDelaunayGrid):  # shorthand for "patches are triangles"
...     # other stuff
>>> else:
...     raise Error # if you're lucky this is there!

or sometimes simply:

>>> if isinstance(mg, RasterModelGrid):
>>>     # stuff
>>> else:
>>>     # other stuff

But, now we have this - to me very counterintuitive - typing:

>>> isinstance(rmg, VoronoiDelaunayGrid)  # phew!
False
>>> isinstance(hmg, VoronoiDelaunayGrid)  # formerly True I think
False
>>> isinstance(radmg, VoronoiDelaunayGrid)  # formerly True I think
False

Have I missed a grid method (@mcflugen ?) that can now actually perform this “patches are triangles” check as this method isn’t working any more? We need this as a method as letting type checks propagate in lots of different methods seems like a recipe for disaster if this kind of change happens again, or we add more classes.

These if statements also all need finding and tweaking. Tagging @kbarnhart as the place that triggered me noticing this was in the FlowAccumulator (lns 698-9), but there are a couple of others as well where this is actually broken. Fortunately most of the tests are if Raster... else: which holds up under these changes.

A related issue (will be submitted following this) is that now we have a NetworkModelGrid the lazy logic that many components use:

>>> if isinstance(mg, RasterModelGrid):
>>>     # stuff
>>> else:
>>>     # other stuff

Is no longer adequate - we will get weird fails if Networks are supplied to these. There should be explicit tests on our components if they can’t handle network grids.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kbarnhartcommented, May 19, 2021

@SiccarPoint I’ve now read this, good catch. @mcflugen is definitely the person who would know what grid attribute should get used for this. Once he weighs in on what it should be, I’m can help make some of the relevant component changes.

1reaction
kbarnhartcommented, May 14, 2021

@SiccarPoint - Just got back from some fieldwork, so may be middle/end of next week before I am able to actually read this issue (and #1294) carefully. Will respond then. Thx.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using 3D Voronoi grids in radiative transfer simulations
The presented algorithm produces correct results for our test models. Shooting photon packages through the geometrically much more complex 3D Voronoi grid ......
Read more >
Use of Voronoi Grid in Reservoir Simulation - OnePetro
This paper describes a practical way of using Voronoi grids for field scale simulation. Gridpoints are easily generated by using modules of ...
Read more >
Voronoi Diagrams on Discrete Grids - Neil's Notes
Voronoi diagrams are one way to do that – create some random Voronoi cells and choose a subset of them to be land...
Read more >
API for landlab.grid.voronoi
Python implementation of VoronoiDelaunayGrid, a class used to create and manage unstructured, irregular grids for 2D numerical models.
Read more >
Topography-based local spherical Voronoi grid refinement on ...
Locally refined grids for global atmospheric models are attractive since they are expected to provide an alternative to solve local ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found