Deltares / Deltares/imod-python

imod.select.point_values no longer returns index of input x and y dataset

Open
#607 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Deltares has attachment
Dominant language
Python
Stars
41
Forks
12
Avg merge
21h 8m
Merged PRs (30d)
1

Description

In GitLab by @tessodk on Oct 26, 2023, 14:40

In older versions of iMDOD python when using the function imod.select.point_values the index in the observation dataframe and the resulting dataframe after the imod.select.point_values was the same. Thus when the observation ID's where set as index, they were returned as index after selecting from the output dataset.

Below a simplified version of the code and a simple output dataset that's used in the selection.

I'm using iMOD version 0.13.1

import imod

import pandas as pd
import xarray as xr


# Open dataset to plot
ds_obs = pd.DataFrame({"x": [504009, 504101], "y": [791146,789039], "id": ["obs_1", "obs_2"]})
ds_obs.set_index(ds_obs["id"], inplace=True)

output_ds = xr.open_dataarray("conc2.nc")

# Extract modelled data
model_ds = imod.select.points_values(
    output_ds, x=ds_obs["x"], y=ds_obs["y"]
).to_dataframe()
model_ds = model_ds.reset_index()
model_ds = model_ds.rename(columns={"index": "id"})

conc2.nc

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied example at imod.select.points_values using the shown pandas observation DataFrame and conc2.nc. Trace how the input x and y values become the resulting DataFrame index; done means the observation IDs or equivalent input index are preserved after selection.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.