Skip to content

Wind speed and direction timeline #302

@s-celles

Description

@s-celles

Hello,

I noticed on Grafana forum https://community.grafana.com/t/wind-direction-speed-timeline/67168 this kind of plot

Image

I think we should provide a way to have such a plot in this library.

I did a quick Marimo notebook to try this.

Here is sample data wind_speed_direction_time.csv: (probably not exactly the same as plot as I have been using WebPlotDigitizer)

wd=where the wind is going

datetime;ws;wd
2025-09-01T00:00Z;8;355
2025-09-01T01:00Z;6;350
2025-09-01T02:00Z;4;350
2025-09-01T03:00Z;5.4;300
2025-09-01T04:00Z;8.3;240
2025-09-01T05:00Z;12.6;200
2025-09-01T06:00Z;21.1;200
2025-09-01T07:00Z;30.8;200
2025-09-01T08:00Z;39.1;180
2025-09-01T09:00Z;43.8;180
2025-09-01T10:00Z;46.2;180
2025-09-01T11:00Z;46.8;180
2025-09-01T12:00Z;46.3;180
2025-09-01T13:00Z;44.6;170
2025-09-01T14:00Z;42.7;170
2025-09-01T15:00Z;41.8;170
2025-09-01T16:00Z;40.8;160
2025-09-01T17:00Z;39.7;160
2025-09-01T18:00Z;37.7;160
2025-09-01T19:00Z;35.1;150
2025-09-01T20:00Z;32.8;100
2025-09-01T21:00Z;30.7;110
2025-09-01T22:00Z;28.7;110
2025-09-01T23:00Z;26.8;100
2025-09-02T00:00Z;25.8;90

or wd=where the wind is coming from (meteorogical convention)

datetime;ws;wd
2025-09-01T00:00Z;8;175
2025-09-01T01:00Z;6;170
2025-09-01T02:00Z;4;170
2025-09-01T03:00Z;5.4;120
2025-09-01T04:00Z;8.3;60
2025-09-01T05:00Z;12.6;20
2025-09-01T06:00Z;21.1;20
2025-09-01T07:00Z;30.8;20
2025-09-01T08:00Z;39.1;0
2025-09-01T09:00Z;43.8;0
2025-09-01T10:00Z;46.2;0
2025-09-01T11:00Z;46.8;0
2025-09-01T12:00Z;46.3;0
2025-09-01T13:00Z;44.6;350
2025-09-01T14:00Z;42.7;350
2025-09-01T15:00Z;41.8;350
2025-09-01T16:00Z;40.8;340
2025-09-01T17:00Z;39.7;340
2025-09-01T18:00Z;37.7;340
2025-09-01T19:00Z;35.1;330
2025-09-01T20:00Z;32.8;280
2025-09-01T21:00Z;30.7;290
2025-09-01T22:00Z;28.7;290
2025-09-01T23:00Z;26.8;280
2025-09-02T00:00Z;25.8;270

and Marimo notebook code marimo_notebook_wind_speed_direction_timeline.py

import marimo

__generated_with = "0.15.2"
app = marimo.App(width="medium")


@app.cell
def _(pd):
    df = pd.read_csv("wind_speed_direction_time.csv", sep=";")
    df["datetime"] = pd.to_datetime(df["datetime"])
    df = df.set_index("datetime")
    df
    return (df,)


@app.cell
def _(df, mdates, np, plt):
    def plot_wind_speed_direction_timeline():
        # Wind direction visualization using all data points
        fig, ax = plt.subplots(figsize=(20, 10))
    
        # Convert wind direction to normalized components
        # Wind direction: where wind comes from (meteorological convention)
        # For arrows, we want to show where wind is going
        wind_dir_rad = np.radians(df["wd"])
        #wind_dir_rad = np.radians(df["wd"] + 180)  # +180 to reverse direction    
    
        u = np.sin(wind_dir_rad)  # normalized east-west component
        v = np.cos(wind_dir_rad)  # normalized north-south component
    
        # Positions
        x = df.index
        y = df["ws"]  # Y-coordinate = intensity
    
        # Create uniform arrows
        cmap = 'RdYlGn_r'
        quiver = ax.quiver(x, y, u, v,
                           df["ws"],  # Color = intensity
                           cmap=cmap,
                           scale=40,  # Uniform size
                           width=0.004,
                           alpha=0.9,
                           angles='uv',  # Use actual vector angles (not xy coordinates)
                           scale_units='width')  # Scale relative to plot width
    
        # Configuration
        ax.set_xlabel('Time')
        ax.set_ylabel('Wind Speed (km/h)')
        ax.set_title('Wind Direction - All Data Points (Uniform Arrows)')
        ax.grid(True, alpha=0.3)
    
        # Format time axis
        ax.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
        ax.xaxis.set_major_locator(mdates.HourLocator(interval=3))
        plt.xticks(rotation=45)
    
        # Colorbar
        cbar = plt.colorbar(quiver, ax=ax)
        cbar.set_label('Wind Speed (km/h)')
    
        plt.tight_layout()
        return fig, ax

    fig, ax = plot_wind_speed_direction_timeline()
    plt.show()
    return


@app.cell
def _():
    import marimo as mo
    import numpy as np
    import pandas as pd
    import datetime
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    from datetime import datetime
    return mdates, np, pd, plt


if __name__ == "__main__":
    app.run()

Result looks like

Image

I'm posting here a Github feature issue... not as a PR because we should probably have a discussion whether it should / could be integrated in windrose and what API sould looks like.

Best regards,
Sébastien

PS: I'm also considering Plotly.js integration https://community.plotly.com/t/wind-direction-and-speed-timeline/94120

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions