JuliaArrays / AxisArrays.jl

Performant arrays where each dimension can have a named axis with values
http://JuliaArrays.github.io/AxisArrays.jl/latest/
Other
200 stars 41 forks source link

Weighted mean #134

Open yakir12 opened 6 years ago

yakir12 commented 6 years ago

When indexing into an AxisArray, how can I get the value of the axis at the indexed value?

This becomes relevant for instance in the last example (btw, I PR:ed a version that works after following what you concluded in #127), it would make extra sense (to me at least) when the intensity-weighted mean is performed on the actual axis values, not on the integer indices. So in this specific example the axis are just integers, but if B was say AxisArray(randn(100,100,100), Axis{:x}(1:100), Axis{:y}(1:100), Axis{:z}(linspace(1mm, 3mm, 100))), how would you perform the weighted mean then?

yakir12 commented 6 years ago

Answered by @iamed2 on slack. For seeing the :z axis value for array B at index say 45:

julia> axisvalues(axes(B, Axis{:z}))[1][45]
1.8888888888888888 mm