miranov25 / RootInteractive

5 stars 12 forks source link

2D user defined axis transforms (e.g for rotation, function normalization) #276

Closed pl0xz0rz closed 1 year ago

pl0xz0rz commented 1 year ago

This PR adds 2D axis transforms. Example use case in test_bokehDrawSA.py - conversion between polar and cartesian coordinates How it works: When two input arguments are detected for x_transform or y_transform they are used as the input X and Y coordinates.

Real use case - switch to polar coordinates resp. rotation: https://github.com/pl0xz0rz/RootInteractive/blob/e1561e672d9fc14a221bbb2d648da072690ebd8e/RootInteractive/InteractiveDrawing/bokeh/test_bokehDrawSA.py#L59-L60

    {"name": "transformX", "value":None, "options":[None, "sqrt", "arctan2", "lambda x,y: y*cos(x+paramX)"]},
    {"name": "transformY", "value":None, "options":[None, "sqrt", "lambda x,y: sqrt(x*x+y*y)", "lambda x,y: y*sin(x+paramX)"]},
miranov25 commented 1 year ago

Real use case failed:

file:///lustre/alice/users/miranov/NOTES/alice-tpc-notes2/JIRA/ATO-614/dEdxWithGasGain.html

{'name': "yAxisTransform", "value":None, "options":[None, "sqrt", "lambda x: log(1+x)","lambda x: 1/sqrt(x)", "lambda x: x**exponentX", "lambda x,y: (y/x)", "lambda x,y: (y/x**exponentX)" ]},

->

(function anonymous(xs
) {
'use strict';

                    const ys = data_source.get_column(varY);
                    return xs.map((x, i) => (((x, y)=>((y) / (x)))(x, ys[i])));

})
miranov25 commented 1 year ago

Realistic use case works well: file:///lustre/alice/users/miranov/NOTES/alice-tpc-notes2/JIRA/ATO-614/dEdxWithGasGain.html

Possible problem with heatmap - can be solved later, and heatmap rotation to be added to the test