New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add to numpy simple functions for transform coordinate systems #5228
Comments
I'm not sure this is something that needs to be in numpy, the functions are simple enough to implement yourself optimally. |
Even if we draw the line at just the spherical transformations, there are a number of different conventions that are not represented here. I believe that these functions are more appropriate to a package that actually uses them internally (e.g. astropy) and follows a particular convention through its code. |
I understand what you are talking about. However, these functions are used very often while working with the coordinate systems in geometric algorithms, computer graphics software, etc. Generalization on n-dimensions is required infrequently. In MATLAB these functions exist and, I should say, they are rather convenient. I consider these functions as simple mathematical routines, for example, functions rad2deg and deg2rad. These functions, as you know, are frequently used functions and exist in numpy. |
As a general rule there's certainly a place in numpy for basic utility So if we're going to draw a line we should actually do that based on some Some potential criteria to consider for these kinds of simple helpers:
I think these functions score pretty well on these criteria. Everyone uses One thing I'm uncertain about is whether everyone uses the same conventions
|
Unfortunately, there are indeed quite a few conventions used for handling spherical coordinates: http://en.wikipedia.org/wiki/Spherical_coordinate_system I think it is better to let users define the specific spherical coordinate transforms they want themselves. |
There is also an ISO standard that specifies what the "proper" format is... I don't think that multiple conventions are really an issue, as long as what gets returned is clearly documented: switching from one convention to another is much easier than transforming cartesian coordinates to any one of the possible spherical coordinate systems. On the other hand, I don't see this fitting in numpy as a handful of standalone functions. Polar coordinates, especially as related to complex numbers, maybe, but spherical coordinates, not really. |
Well, I am rather inclined to agree with you. Let’s not discuss the function of spherical coordinates now. However, functions of polar coordinates may be applied in many cases. |
There's 5 different norms implemented in |
Agree with this. Most people seem to be neutral to positive for adding the polar coordinate transforms. So if someone wants to make a concrete proposal and then work on implementing, I think that's welcome. Some other thoughts:
|
Found this as we were discussing speed-ups of coordinate transformations in astropy (astropy/astropy#5735) and I wondered what happened with One suggestion might be to start by following [1] https://docs.python.org/3.5/library/cmath.html#conversions-to-and-from-polar-coordinates |
3D versions of these helpers would also be helpful. |
Hello, I am new here and since I am into deep learning, I have this question. Thanks |
@fdkssdks Wrong place to ask those questions, try stackoverflow. |
Or here: Tensorflow API Documentation. |
Hi, Should "el = np.arctan2(z, hxy)" be "el = np.arctan2(hxy,z)" in cart2sph of #5228 (comment)? Thanks |
I think we should close this as "good idea, the API should be worked out in a package outside of NumPy and then we can think about merging in". Please reopen (or ask for it to be reopened) if you disagree. |
There are a couple of Python packages in this space providing all sorts of bits and pieces. I keep collecting what I need for each project from multiple packages - or implement the conversions myself. The weak spot, other than that this is time consuming, is literally performance. Implementing this sort of thing in pure Python with a bunch of calls into numpy ufuncs introduces significant overhead. This is what is suggested here and this is also what most packages tend to do. I usually compile this stuff down with numba, though again this solution is less than ideal. If someone tries to implement this as "actual" ufuncs (in just any compiled language) with all bells and whistles of a ufunc (such as the |
It would be convenient to have these functions as a part of numpy mathematical routines.
cart2pol -- Transform Cartesian to polar coordinates
pol2cart -- Transform polar to Cartesian coordinates
cart2sph -- Transform Cartesian to spherical coordinates
sph2cart -- Transform spherical to Cartesian coordinates
The text was updated successfully, but these errors were encountered: