Skip to content

Feature/signal data operation#90

Open
jwasikpsnc wants to merge 38 commits into
iterorganization:developfrom
jwasikpsnc:feature/signal_data_operation
Open

Feature/signal data operation#90
jwasikpsnc wants to merge 38 commits into
iterorganization:developfrom
jwasikpsnc:feature/signal_data_operation

Conversation

@jwasikpsnc

Copy link
Copy Markdown
Collaborator
  • adds /data/plot_data/ signal_operations parameter
  • adds signal operations description in /info/data_manipulation_methods endpoint response
  • accepts operations as list ["operation:<URI>", "..."] e.g. ["add:<uri>","mul:<uri>","div:<uri>"]
  • operations are executed in order determined by position in the list
  • allowed operations:
    • add
    • sub
    • mul
    • div
  • updated docs
  • if <base_uri> and <operand_uri> have the same shapes - > no interpolation needed
  • if <base_uri> and <operand_uri> have different shapes -> error is being raised

Waiting for #89 to be merged first

@read-the-docs-community

read-the-docs-community Bot commented Jun 22, 2026

Copy link
Copy Markdown

Documentation build overview

📚 imas-ibex | 🛠️ Build #33742210 | 📁 Comparing 6724f87 against latest (9fe753c)

  🔍 Preview build  

136 files changed · + 86 added · ± 50 modified

+ Added

± Modified

…re/signal_data_operation

# Conflicts:
#	backend/ibex/core/data_manipulation_methods.py
#	backend/ibex/data_source/imas_python_source.py
#	backend/ibex/data_source/imas_python_source_utils.py
#	backend/ibex/endpoints/schemas/request_data_schemas.py
#	backend/tests/conftest.py
#	backend/tests/test_data_endpoints.py
#	backend/tests/test_data_manipulation.py
#	docs/source/developers_manual/backend_development/data_manipulation.rst
@jwasikpsnc
jwasikpsnc marked this pull request as ready for review June 30, 2026 10:05
@jwasikpsnc

jwasikpsnc commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

@olivhoenen

  • rebased onto develop
  • fixed bug in pyproject.toml which made pip download https://pypi.org/project/ibex/ instead of imas-ibex when installing pip install -e .[all]

Comment thread backend/ibex/data_source/imas_python_source_utils.py Outdated
Comment thread backend/ibex/data_source/imas_python_source.py
@bpalak

bpalak commented Jul 20, 2026

Copy link
Copy Markdown

@prasad-sawantdesai : Could you provide me info about your test files (BASE and OTHER) ? I would like to reproduce your tests using the same data you are using.

@prasad-sawantdesai

Copy link
Copy Markdown
Contributor

@prasad-sawantdesai : Could you provide me info about your test files (BASE and OTHER) ? I would like to reproduce your tests using the same data you are using.
Here it is --

$ echo $OTHER
imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/134174/117#equilibrium/vacuum_toroidal_field/b0
$ echo $BASE
imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/53299/2#equilibrium/vacuum_toroidal_field/b0

Comment thread backend/ibex/data_source/imas_python_source.py
axis_indices.append(lookup[value])

axis_indices = np.searchsorted(np.asarray(target), np.asarray(orig))
target_indices.append(axis_indices)

@prasad-sawantdesai prasad-sawantdesai Jul 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we verify that target[indices] == orig after searchsorted and reject coordinates missing from the target grid?

import imas
import numpy as np

entries = [
    ("/tmp/ibex-grid-first",  [0.0, 0.5, 1.0], [10.0, 20.0, 30.0]),
    ("/tmp/ibex-grid-second", [0.0, 0.4, 0.8], [100.0, 200.0, 300.0]),
]

for path, rho, temperature in entries:
    with imas.DBEntry(f"imas:hdf5?path={path}", mode="w") as entry:
        cp = entry.factory.core_profiles()
        cp.ids_properties.homogeneous_time = 1
        cp.time = np.array([1.0])
        cp.profiles_1d.resize(1)
        cp.profiles_1d[0].grid.rho_tor_norm = np.array(rho)
        cp.profiles_1d[0].electrons.temperature = np.array(temperature)
        entry.put(cp)

# This works correctly
curl -sS -G http://127.0.0.1:8000/data/plot_data     --data-urlencode "uri=$FIRST"     --data-urlencode "interpolate_over=$SECOND"     --data-urlencode "interpolation_method=exact_value"     --data-urlencode "signal_operations=add:$SECOND"     | jq '.data | {coordinates, value}'

  "value": [
    [
      110.0,
      null,
      null,
      null,
      null
    ]
  ]

# but this one gives wrong result seems. $SECOND coordinates 0.4 and 0.8 do not exist in $FIRST’s grid, should raise an error?
curl -sS -G http://127.0.0.1:8000/data/plot_data     --data-urlencode "uri=$FIRST"     --data-urlencode "interpolate_over=$FIRST"     --data-urlencode "interpolation_method=exact_value"     --data-urlencode "signal_operations=sub:$FIRST"     --data-urlencode "signal_operations=add:$SECOND"     | jq '.data | {coordinates, value}'
  "value": [
    [
      100.0,
      200.0,
      300.0
    ]
  ]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should resample_data_without_interpolation() raise an error when the exact coordinates are not found in the target grid?

Original coordinates: [0.0, 0.4, 0.8]
Data: [100.0, 200.0, 300.0]
Target coordinates: [0.0, 0.5, 1.0]

It returns: [100.0, 200.0, 300.0]

This maps the values at 0.4 and 0.8 to 0.5 and 1.0. Should it raise an error as those exact coordinates are not exists in the target grid?

@bpalak
bpalak force-pushed the feature/signal_data_operation branch from 066171e to c20ea80 Compare July 23, 2026 11:49
@bpalak
bpalak force-pushed the feature/signal_data_operation branch from c20ea80 to 353af26 Compare July 23, 2026 11:53
@olivhoenen

Copy link
Copy Markdown
Contributor

Some linting issues remain in the last version @bpalak

@bpalak

bpalak commented Jul 24, 2026

Copy link
Copy Markdown

@olivhoenen : I am aware of this. The last two things to be done to address all Prasad comments:

  • linting issues
  • tests modification
    Anything else?

@bpalak

bpalak commented Jul 24, 2026

Copy link
Copy Markdown

@olivhoenen : Actually I was aware about few issues and not 157 errors.. All my checks done from the CLI passed. Did you change ruff rules?

@bpalak

bpalak commented Jul 24, 2026

Copy link
Copy Markdown

A new Ruff version, released yesterday enables a much larger set of rules by default (413, up from 59)...

@jwasikpsnc
jwasikpsnc requested a review from SimonPinches as a code owner July 24, 2026 10:41
@jwasikpsnc

Copy link
Copy Markdown
Collaborator Author

ReadTheDocs failed to checkout last commit.
I don't have account nor permissions to re-run it.
@prasad-sawantdesai could you?

@prasad-sawantdesai

Copy link
Copy Markdown
Contributor

ReadTheDocs failed to checkout last commit. I don't have account nor permissions to re-run it. @prasad-sawantdesai could you?

rebuilt..

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants