Deltares / Deltares/imod-python
imod.select.point_values no longer returns index of input x and y dataset
Nobody has claimed this yet.
- 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"})
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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