Skip to content

[Shear.BySector] IndexError when direction_bin_labels is given #636

Open

Description

@olivia-bentley

Describe the bug
Shear.BySector fails with an IndexError when custom direction_bin_labels are passed. plot_shear_by_sector() reads the sector bin edges from the index labels of the wind rose data using a regex (plot.py, ~line 1977), so any label that isn't of the form '0.0-90.0' breaks it.

To Reproduce

import brightwind as bw
data = bw.load_csv(bw.demo_datasets.demo_data)
bw.Shear.BySector(data[['Spd80mN', 'Spd60mN', 'Spd40mN']], [80, 60, 40], data['Dir78mS'],
                  direction_bin_array=[0, 90, 130, 200, 360],
                  direction_bin_labels=['northerly', 'easterly', 'southerly', 'westerly'])

IndexError: list index out of range in plot_shear_by_sector.

Expected behaviour
The labels are used for display only. The bin edges should come from direction_bin_array (or the default sector bins), not be parsed from the labels.

Found while working on #408.

Activity

  1. Jah-yee commented on Oct 3, 2026

    @Jah-yee

    Hi! I noticed this issue and have submitted PR #643 with a fix. The problem is that plot_shear_by_sector() uses a regex to extract bin edges from index labels, which fails when custom text labels (like 'northerly', 'easterly') are used. My fix adds a fallback to use direction_bin_array when the regex returns fewer than 2 numbers. Please let me know if you would like any adjustments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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