Skip to content

Bug in xhfa.local._get_plotting_positions #402

Description

@ospinajulian

Setup Information

  • xhydro version: 0.6.0
  • Python version: 3.11.11
  • Operating System: linux

Description

The function xhfa.local._get_plotting_positions() returns different results when running xhfa.local._get_plotting_positions(ds.sel(x=0,y=0)) or xhfa.local._get_plotting_positions(ds).sel(x=0,y=0)

Steps To Reproduce

import numpy as np
import xarray as xr
import pandas as pd

np.random.seed(42)

time = pd.date_range("2026-01-01", periods=10)
x = np.arange(2)
y = np.arange(2)
data = np.random.rand(10, 2, 2)

ds = xr.Dataset(
{"random_var": (["time", "x", "y"], data)},
coords={"time": time, "x": x, "y": y}
)

p1 = xhfa.local._get_plotting_positions(ds.sel(x=0,y=0))
p2 = xhfa.local._get_plotting_positions(ds).sel(x=0,y=0)

k='random_var'
plt.scatter(p1[f"{k}_pp"], p1[k],label='p1')
plt.scatter(p2[f"{k}_pp"], p2[k], label='p2')
plt.legend()

Image

Additional context

No response

Contribution

  • I would be willing/able to open a Pull Request to address this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions