Skip to content
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

Allow np.ndarray inputs for subpnt, subslr, and pxform #435

Open
medley56 opened this issue Jan 24, 2022 · 1 comment
Open

Allow np.ndarray inputs for subpnt, subslr, and pxform #435

medley56 opened this issue Jan 24, 2022 · 1 comment
Labels
beginners welcome issues that are good for beginners enhancement help wanted not a bug this issue is not a bug

Comments

@medley56
Copy link
Contributor

I often find myself writing np.vectorize calls to allow SpiceyPy functions to take vector inputs. I'd like to see this moved into SpiceyPy itself.

AFAIK, all array input handling is done on the Python side as CSPICE functions never accept array inputs. An example is spkezr, which loops through the array input values in Python, iteratively calling spkezr_c. However, not all wrappers have implemented this convenience.

There are many other routines which would benefit from this type of array input handling. As a start, I suggest pxform, subslr, and subpnt, possibly accepting user suggestions for others.

An alternative implementation could be to write a C extension library that performs these loops in C rather than python to improve performance but that would probably add a lot of additional installation and maintenance headache for @AndrewAnnex.

@AndrewAnnex
Copy link
Owner

PR's are certainly welcome to add additional functions to accept arrays using the style we developed for spekezr but the speed ups are marginal relative to a simple for loop or using np.vectorize. I'd say these additions make easy PRs for me to accept, but they are relatively low priority for me to work on by myself as they only provide slight convenience. You can look at #192 #310 #317 and #324 for examples.

The other topic you raise is an important one but something that will take a lot more time and I want to see if I can apply to get funding for. Issue #363 sort of tracks this issue, I've found that the most likely way I will implement this is by using cython as it may simplify some of the other build tooling when combined with Cmake. But there is also a rust cspice library that could be wrapped with python. Other than these two ideas just implementing them as pure c files in the codebase could also work and present less of a headache, but I am trying to avoid memory management. Theoretically the NAIF could supply these also... In any case, dropping the loops to a lower level language is certainly of interest but it's tricky to do that and reuse the existing ctypes code at the same time.

@AndrewAnnex AndrewAnnex added beginners welcome issues that are good for beginners enhancement help wanted not a bug this issue is not a bug labels Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginners welcome issues that are good for beginners enhancement help wanted not a bug this issue is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants