Comments (2)
Hi! Sorry I'm getting back to this late—I'm catching up to issues from the weekend.
The idea of uproot-methods was to be user-contributed—not because I'm trying to offload work, but because the scope that it represents (Pythonic method for any ROOT classes that users need) is very open-ended.
You've seen the code: each of these methods assumes Numpy-like arrays (which can be awkward arrays, thanks to their shared behavior) and performs vectorized calculations on them. The corresponding rotation code for TVector3 (https://github.com/scikit-hep/uproot-methods/blob/master/uproot_methods/classes/TVector3.py#L32-L80) is much more complicated than it would be for TVector2, since that just takes a scalar angle.
It would be something like this:
def rotate(self, angle):
cosangle = self.awkward.numpy.cos(angle)
sinangle = self.awkward.numpy.sin(angle)
xprime = self.x*cosangle - self.y*sinangle
yprime = self.x*sinangle + self.y*cosangle
return TVector2Array.from_cartesian(xprime, yprime)
Okay, I guess there's a slight complication from the fact that we want to get numpy
from an object attached to the array itself (so that in the future, this can be swapped for cupy
for GPU processing).
Also, looking into it, I wonder how deep your use-case goes—if you're only interested in Numpy arrays of 2-vectors or any level of jaggedness. The TLorentzVector.from_cartesian
constructor has been expanded to handle arbitrary jaggedness, but not the TVector2.from_cartesian
constructor. (Oh, TVector3 uses a different trick to get both flat-Numpy and jagged arrays; it uses empty_like()
: https://github.com/scikit-hep/uproot-methods/blob/master/uproot_methods/classes/TVector3.py#L119-L125 . Maybe we could do the same here.)
See what I mean about the open-ended scope? If you try to implement this for your case (and open a pull request), I'll help you with any issues you run into. Thanks!
from uproot3-methods.
Hi, I open a PR #64, mimicking what TVector3 is implemented. What do you think? Thanks!
from uproot3-methods.
Related Issues (20)
- ROOT::Math::LorentzVector HOT 1
- boosting 4-vectors does not work on TLorentzVectorArray HOT 3
- broken __repr__ on ObjectArrays from ChunkedArrays and inconsistent behavior of choose() HOT 1
- Multidimensional TLorentzVectorArray doesn't work HOT 3
- from_ptetaphi() should be from_ptetaphie() HOT 2
- Bug in TH1.py, line 146, in show method HOT 1
- TH3 not writeable HOT 3
- Setters for TH1? HOT 3
- Behavior of eta if x, y = 0 in TLorenzVector HOT 3
- Deprecation warning due to invalid escape sequences
- ValueError/KeyError after boosting PtEtaPhiMassLorentzVectorArray
- TH1 physt() method doesn't preserve errors
- Consistent method resolution order (MRO) issue with TLorentzVector HOT 3
- TLorentzVectorArray.p3 and TLorentzVectorArray.boostp3 broken, TLorentzVectorArray.empty_like returns invalid
- angle between two vectors HOT 3
- Adding TLorentzVectorArray HOT 1
- awkeard.array module not found on importing uproot_methods HOT 1
- Question on behavior of weights and variances HOT 9
- Status bits for a TH1? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uproot3-methods.