Skip to content

Auxiliary non-dimension coordinates leak into expressions and break alignment #295

Description

@aurelije

Hi people, I am currently struggling with xarray and linopy.

I have a dimension A whose coordinates can be grouped. For me it was natural to have a dimension A with coordinates for A but also coordinate B that is built on dimension A and then swap dimensions but I failed to do it.

So here is an example.
dimension A has coordinates: [1, 2, 3, 4, 5, 6] but coordinates [1, 2, 3] belong to group 311 and rest of them to group 322. I would like to create constraints based on those 2 groups.

I have a variable with this situation:

var.coords
Coordinates:
* A (A) int64 48B 1 2 3 4 5 6
B (A) int64 48B 311 311 311 322 322 322

Looking at xarray docs this may be the way var.swap_dims({'A': 'B'}) and then I can do sum on other dimensions and set constraint for groups. But Variable doesn't have that method.

Next I tried with groupby on B, I got correct groups but then sum on groupby expression will throw an error that B is already present...

In the end I made B full dimension (I am breaking normalization from Databases theory :D) but looks like suboptimal solution and I have this kind of case for multiple coordinates so instead of having small dimensional case of 7 dimensions I will end with at least 9

Could I do something better?

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions