Skip to content

[FEATURE] merge_grids: add "merge_ids" mode that only adds new assets #253

Description

@jaapschoutenalliander

Describe the feature request

Extend Grid.merge() / merge_grids() to support a merge mode where overlapping assets (by id) are silently skipped, and only assets from the other grid that are absent in the current grid are added.

Current behavior

mode="keep_ids" appends all arrays from the other grid and then calls check_ids(). If any id collision is found, it raises:

ValueError: Asset ids are not unique after merging! Use mode='recalculate_ids' to avoid this.

There is no way to merge two datasets that share a common subset of assets without recalculating IDs.

Requested behavior

Add a new mode, e.g. mode="merge_ids", that for each array in other_grid, only appends rows whose id is not already present in the corresponding array of the current grid.

Motivation / use case

When two grids are built independently but represent overlapping parts of the same network (e.g. a connecting topology shared between scenarios), merging with "recalculate_ids" breaks cross-references, while "keep_ids" fails. The desired semantics is "add what's new, ignore what's already there".

Community Meeting

  • I wish to discuss this feature in the bi-monthly PGM community meeting. Please join the PGM community meeting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions