ortk95 / planetmapper

PlanetMapper: An open source Python package for visualising, navigating and mapping Solar System observations
https://planetmapper.readthedocs.io
MIT License
10 stars 1 forks source link

Add option option to return NaN values for point that are not visible when using `lonlat2...` methods #369

Closed ortk95 closed 2 months ago

ortk95 commented 2 months ago

Added an additional not_visible_nan keyword only parameter to transformations from longitude/latitude coordinates (i.e. lonlat2... methods). With not_visible_nan=True, the returned coordinates will be NaN if the longitude/latitude coordinates aren't visible to the observer (e.g. if the coordinates are on the far side of the target body). not_visible_nan defaults to False, so the default behaviour is unchanged.

For example:

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

# By default, lonlat2radec will always return values, even if the point is hidden
print(body.lonlat2radec(180, 0))
# (196.3742463154229, -5.566702383405959)
print(body.lonlat2radec(0, 0))
# (196.36993081145695, -5.565236600066979)

# With not_visible_nan=True, hidden points return (nan, nan)
print(body.lonlat2radec(180, 0, not_visible_nan=True))
# (196.3742463154229, -5.566702383405959)
print(body.lonlat2radec(0, 0, not_visible_nan=True))
# (nan, nan)

Previously, this behaviour was only possible by manually using test_if_lonlat_visible.

Closes #367

Pull request checklist

See CONTRIBUTING.md for more details.

coveralls commented 2 months ago

Pull Request Test Coverage Report for Build 9547803744

Details


Totals Coverage Status
Change from base Build 9546469376: 0.0%
Covered Lines: 3051
Relevant Lines: 3063

💛 - Coveralls