# unidata/metpy architecture

> Architecture diagram of the GitHub repository unidata/metpy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/unidata/metpy
- Repository: https://github.com/unidata/metpy

## Overview

##### Project type and purpose
- MetPy is an open-source, full-featured Python library for meteorological data: reading, calculating, and visualizing weather data. It is not a web app or microservice suite but a modular library intended for researchers and educators.

##### File structure
- Top‐level:
- src/metpy: core library code, organized into subpackages: calc, interpolate, io, plots, remote, units, constants, etc.
- docs: Sphinx documentation source; build scripts, templates, static assets.
- examples, tutorials: usage scripts demonstrating core functionality.
- tests: unit tests mirroring library subpackages.
- tools: CLI and code-quality scripts (flake8 plugin, nexrad spec parser).
- CI config: GitHub Actions workflows under .github; devcontainer definitions; coverage & linting settings.
- Packaging: pyproject.toml, setup.cfg, MANIFEST.in.
- staticdata: sample datasets for testing or examples.

##### README for additional insights
- Core functionality: reading (io), calculations (calc), interpolation, plotting (matplotlib & cartopy), remote data access (AWS).
- Dependencies: numpy, scipy, pandas, pint, xarray, matplotlib, optional pyproj.
- Philosophy: modular building blocks that “plug” into scientific Python ecosystem.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Core Library"
        C1["metpy.io"]:::library
        C2["metpy.calc"]:::library
        C3["metpy.interpolate"]:::library
        C4["metpy.plots"]:::library
        C5["metpy.remote"]:::library
        C6["metpy.units"]:::library
        C7["metpy.constants"]:::library
        C8["metpy._vendor/_version"]:::library
        C9["metpy.pandas"]:::library
        C10["metpy.xarray"]:::library
        C11["package_tools/deprecation/future"]:::library
    end

    subgraph "Data Sources"
        DS1["staticdata (local)"]:::datasource
        DS2["AWS S3 / NEXRAD"]:::datasource
    end

    subgraph "External Dependencies"
        ED1["NumPy"]:::external
        ED2["SciPy"]:::external
        ED3["Pandas"]:::external
        ED4["Pint"]:::external
        ED5["xarray"]:::external
        ED6["Matplotlib"]:::external
        ED7["Cartopy (opt)"]:::external
        ED8["Pyproj (opt)"]:::external
    end

    subgraph "Consumers"
        U1["examples"]:::consumer
        U2["tutorials"]:::consumer
        U3["downstream apps"]:::consumer
    end

    subgraph "CI / Docs / Packaging"
        CI["GitHub Actions (CI/CD)"]:::ci
        DOC["Sphinx docs"]:::docs
        PKG["Packaging configs"]:::ci
    end

    subgraph "Tests"
        T1["pytest suites"]:::test
        T2["testing utils"]:::test
    end

    %% Data & Control Flow
    U1 -->|imports API| C1
    U2 -->|imports API| C1
    U3 -->|imports API| C1
    DS1 -->|local sample| C1
    DS2 -->|remote fetch| C5
    C5 -->|fetches data| C1
    C1 -->|reads data| C2
    C2 -->|calculates| C3
    C3 -->|interpolates| C4
    C4 -->|plots| U1
    C6 -->|units support| C2
    C6 -->|units support| C3
    C6 -->|units support| C4
    C7 -->|constants| C2
    C7 -->|constants| C3
    C7 -->|constants| C4
    C9 -->|DataFrame adapter| C1
    C10 -->|DataArray adapter| C1

    %% Dependencies
    ED1 -->|required| C2
    ED2 -->|required| C2
    ED3 -->|required| C1
    ED4 -->|required| C6
    ED5 -->|required| C1
    ED6 -->|required| C4
    ED7 -->|optional| C4
    ED8 -->|optional| C4

    %% CI & Docs & Tests
    CI -->|runs| T1
    CI -->|builds| DOC
    CI -->|packages| PKG
    T1 -->|tests| C1
    T1 -->|tests| C2
    T1 -->|tests| C3
    T1 -->|tests| C4
    T2 -->|utils| T1

    %% Click Events
    click C2 "https://github.com/unidata/metpy/tree/main/src/metpy/calc"
    click C3 "https://github.com/unidata/metpy/tree/main/src/metpy/interpolate"
    click C1 "https://github.com/unidata/metpy/tree/main/src/metpy/io"
    click C4 "https://github.com/unidata/metpy/tree/main/src/metpy/plots"
    click C5 "https://github.com/unidata/metpy/tree/main/src/metpy/remote"
    click C6 "https://github.com/unidata/metpy/blob/main/src/metpy/units.py"
    click C7 "https://github.com/unidata/metpy/tree/main/src/metpy/constants"
    click C8 "https://github.com/unidata/metpy/tree/main/src/metpy/_vendor"
    click C9 "https://github.com/unidata/metpy/blob/main/src/metpy/pandas.py"
    click C10 "https://github.com/unidata/metpy/blob/main/src/metpy/xarray.py"
    click C11 "https://github.com/unidata/metpy/blob/main/src/metpy/package_tools.py"
    click DS1 "https://github.com/unidata/metpy/tree/main/staticdata/"
    click U1 "https://github.com/unidata/metpy/tree/main/examples/"
    click U2 "https://github.com/unidata/metpy/tree/main/tutorials/"
    click DOC "https://github.com/unidata/metpy/tree/main/docs/"
    click CI "https://github.com/unidata/metpy/tree/main/.github/workflows"
    click PKG "https://github.com/unidata/metpy/blob/main/pyproject.toml"
    click T1 "https://github.com/unidata/metpy/tree/main/tests/"
    click T2 "https://github.com/unidata/metpy/blob/main/src/metpy/testing.py"

    %% Styles
    classDef library fill:#A7C7E7,stroke:#333,stroke-width:1px
    classDef external fill:#C2FABC,stroke:#333,stroke-width:1px
    classDef datasource fill:#FDE47F,stroke:#333,stroke-width:1px
    classDef consumer fill:#FFC78E,stroke:#333,stroke-width:1px
    classDef ci fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef test fill:#E3CEF6,stroke:#333,stroke-width:1px
```
