Skip to content

Feature: Add diagnostic visualization for isolated/disconnected mesh nodes #99

@ArnabTechiee

Description

@ArnabTechiee

Motivation

When configuring Local Area Models (LAM) and tuning parameters like mesh_node_distance, it is easy to accidentally create spatial configurations where certain grid nodes become completely disconnected (0-degree nodes). It is highly beneficial to visualize these "graph holes" early in the data pipeline.

I built a standalone diagnostic tool to map these boundaries (original Gist here: https://gist.github.com/ArnabTechiee/7fc757f79379709943300d879af3baec), and following a discussion on Slack with @joeloskarsson and @leifdenby, I would like to integrate this directly into weather-model-graphs.

Current Standalone Output

Image

Proposed Implementation in WMG

Currently, my standalone script uses a mock generator and raw matplotlib. To integrate this cleanly into the WMG architecture, I propose adapting the logic to utilize WMG's native networkx data structures and existing visualization modules.

Here is the proposed integration plan:

  1. New Utility Function: Add a new function (e.g., plot_isolated_nodes(graph, ax=None)) inside src/weather_model_graphs/visualise/plot_2d.py.
  2. Identify Isolates: Instead of my custom distance thresholds, leverage the backend by using networkx.isolates(graph) to find all nodes with a degree of 0.
  3. Attribute Tagging: Iterate through the graph and tag the nodes with a new string attribute (e.g., graph.nodes[node]["Connection Status"] = "Isolated" vs "Connected").
  4. Native Rendering: Pass the tagged graph directly into WMG's existing nx_draw_with_pos_and_attr function. This avoids redundant matplotlib code and ensures the diagnostic plot perfectly matches WMG's native aesthetic, colorbars, and discrete legends.
  5. Exposure: Expose this function in visualise/__init__.py so downstream users (or CLI arguments in neural-lam) can easily call wmg.visualise.plot_isolated_nodes(graph).

Does this architectural approach look good to you both? If so, I’d be happy to open a draft PR for this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions