Feature/signal data operation#90
Conversation
…signal_data_operation # Conflicts: # backend/ibex/endpoints/schemas/request_data_schemas.py
…nto feature/signal_data_operation # Conflicts: # backend/ibex/data_source/imas_python_source_utils.py
…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
|
| # b. Otherwise use raw signal data directly (same shape path) | ||
| # 5. Build a flat uri->array dict and apply all signal operations | ||
|
|
||
| if plot_data_query.signal_operations: |
There was a problem hiding this comment.
After Square / Multiplication operation shown below, should unit of the quantity remains same?
$ curl -G http://127.0.0.1:8000/data/plot_data --data-urlencode "uri=$BASE" --data-urlencode "interpolate_over=$OTHER" --data-urlencode "interpolation_method=exact_value" --data-urlencode "signal_operations=mul:$OTHER" | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7880 100 7880 0 0 769k 0 --:--:-- --:--:-- --:--:-- 769k
{
"data": {
"name": "b0",
"unit": "T",
"shape": [
300
],
"downsampled_shape": [
300
],
There was a problem hiding this comment.
I am not sure concerning physical interpretation of mentioned operations. If we multiply signal1 x signal2 the unit should be unit^2 ?
There was a problem hiding this comment.
I am not sure concerning physical interpretation of mentioned operations. If we multiply
signal1xsignal2the unit should beunit^2?
If signal1 and signal2 have the same unit, yes, this is correct. Combining units is only valid with your mul and div operators thought, with add and sub you shall make sure that units are the same or throw an error.
You may check this short video: https://www.youtube.com/watch?v=2DJjV3I4xGc
There was a problem hiding this comment.
add and sub you shall make sure that units are the same or throw an error. #90 (comment)
I think we are not checking if units are the same. and it did not throw exception.
[sawantp1@98dci4-srv-1005 frontend]$ echo $ANOTHER
imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/134174/117#equilibrium/time_slice[0]/profiles_1d/psi
[sawantp1@98dci4-srv-1005 frontend]$ echo $ANOTHER1
imas:hdf5?path=/work/imas/shared/imasdb/ITER/3/134174/117#equilibrium/time_slice[0]/profiles_1d/pressure
$ curl -G http://127.0.0.1:8000/data/plot_data --data-urlencode "uri=$ANOTHER1" --data-urlencode "signal_operations=add:$ANOTHER" | jq | head -n 20
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13737 100 13737 0 0 353k 0 --:--:-- --:--:-- --:--:-- 353k
{
"data": {
"name": "pressure",
"unit": "Pa",
"shape": [
299
],
"downsampled_shape": [
299
],
"ndim": 1,
"path": "#equilibrium/time_slice[0]/profiles_1d/pressure",
"description": "Pressure",
"coordinates": [
{
"name": "psi",
"target": "#equilibrium/time_slice[0]/profiles_1d/pressure",
"unit": "Wb",
"shape": [
299| if ( | ||
| other_signal["data"]["shape"] != "irregular" | ||
| and other_signal["data"]["shape"] == original_data_shape | ||
| ): |
There was a problem hiding this comment.
other_signal["data"]["shape"] == original_data_shape if shape is same but coordinate has different time stamps, it won't ask for interpolation message and still can go for operation.
There was a problem hiding this comment.
DONE. c218ca2
Now, signal operation fails due to time coordinates incompatibilities. Other signals should be chosen...
There was a problem hiding this comment.
c218ca2 Should we check other coordinates if available for example dim1, dim2 or rho_tor_norm? May be its good to check dynamically..
There was a problem hiding this comment.
Now all coordinates are checked for their mutual compatibility. d213449
Two coordinate are equal only when:
- Both signals contain the same number of coordinates.
- Each coordinate appears in the same position.
- Corresponding coordinate names match exactly, such as "rho" == "rho".
- Corresponding values match in shape and content.
- NaN values at corresponding positions count as equal.
|
@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. |
$ 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 |
…ture/signal_data_operation # Conflicts: # backend/ibex/data_source/imas_python_source.py
…nto feature/signal_data_operation
| ) | ||
|
|
||
| # ============= END signal operations ============= | ||
|
|
There was a problem hiding this comment.
Do you know what I am doing wrong here?
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)
# $ echo $FIRST
# imas:hdf5?path=/tmp/ibex-grid-first#core_profiles:0/profiles_1d[:]/electrons/temperature
# $ echo $SECOND
# imas:hdf5?path=/tmp/ibex-grid-second#core_profiles:0/profiles_1d[:]/electrons/temperature
# $ 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=add:$SECOND" | jq
# {
# "message": "'interpolated_data'"
# }| axis_indices.append(lookup[value]) | ||
|
|
||
| axis_indices = np.searchsorted(np.asarray(target), np.asarray(orig)) | ||
| target_indices.append(axis_indices) |
There was a problem hiding this comment.
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
]
]066171e to
c20ea80
Compare
c20ea80 to
353af26
Compare
/data/plot_data/signal_operationsparameter/info/data_manipulation_methodsendpoint responseoperationsas list["operation:<URI>", "..."]e.g.["add:<uri>","mul:<uri>","div:<uri>"]addsubmuldivWaiting for #89 to be merged first