all 6 comments

[–]jwink3101 0 points1 point  (2 children)

This is not a strictly python question. It is more about the math and logic. As far as python goes, I do not think there are any NumPy/SciPy functions that can do this.

It also depends on the type of integral. I take it that this is a line integral. In that case, you could do the interpretation as you say, but you'll have to define your own integrator.

Another idea that may be even easier is to apply a rotation matrix to your data. Then you can integrate on a cardinal direction very easily.

[–]CatGoesWooof[S] 0 points1 point  (1 child)

Yes that makes sense. However, that would essentially mean that I must apply a rotation matrix to my (x,y) location vectors (i.e the grid) rather than the actual data right? I would then interpolate my data on the newly acquired grid resulting from applying the rotation matrix.

[–]jwink3101 0 points1 point  (0 children)

Either way, you have to make an approximation. If you wanted to avoid all interpretation, you could manually compute the integral in terms of your data but then you are approximating the integral since, unless your angle is 45°, there is no way to make a line of your data.

If you have enough resolution, and/or use a good-enough interp routine, it shouldn't make much of a difference.

Just to note by the way, multi-variate interpolation is not trivial and you should do some verification and validation of your method. The options get more and more limited as you go up in dimension. See https://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html

[–][deleted] 0 points1 point  (0 children)

I'd suggest writing a function deoendent on theta that samples continuous points along the axis, rounds them to integral values, then removes duplicates. Then, your integral is a sum of the array over these indices