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 passing arrays to coordinate transformation methods #370

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

ortk95
Copy link
Owner

@ortk95 ortk95 commented Jun 18, 2024

Array transformation methods (e.g. radec2lonlat) can now transform arrays of coordinates, in addition to coordinates for a single point.

If the input coordinates are both floats, then the method will return a tuple of floats (i.e. the existing behaviour). If either of the input coordinates are arrays, then the inputs will be broadcast together, and a tuple of NumPy arrays will be returned. There are no restrictions on the shape and number of dimensions of the input arrays - the only requirement is that the input arrays can be broadcast together.

For example:

body = planetmapper.Body('Jupiter', utc='2005-01-01T00:00:00')

print(body.lonlat2radec(180, 0))
# (196.3742463154229, -5.566702383405959)
print(body.lonlat2radec(np.arange(360), np.zeros(360)))
# (array([196.36993081, ..., 196.37000169]), array([-5.5652366 , ..., -5.56527024]))
print(body.lonlat2radec(np.array([1,2]), np.array([[1,2],[3,4]])))
# (array([[196.36989221, 196.36985491], [196.3699572, 196.36992117]]), array([[-5.56513378, -5.56503142], [-5.56499563, -5.5648938 ]]))

Closes #358

Pull request checklist

  • Add a clear description of the change
  • Add any new tests needed
  • Run spell check on new text visible to user (documentation, GUI etc.)
  • Check any changes to requirements.txt are reflected in setup.py and conda-forge feedstock
  • Check code passes CI checks (run run_ci.sh or check GitHub Actions)

See CONTRIBUTING.md for more details.

@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9564560155

Details

  • 57 of 57 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.005%) to 99.61%

Totals Coverage Status
Change from base Build 9547931142: 0.005%
Covered Lines: 3101
Relevant Lines: 3113

💛 - Coveralls

@ortk95 ortk95 merged commit f8d954d into dev Jun 18, 2024
38 checks passed
@ortk95 ortk95 deleted the 358-add-array-compatibility-to-coordinate-methods branch June 18, 2024 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants