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 method to interpolate image values for a (lon, lat) coordinate #387

Open ortk95 opened 1 month ago

ortk95 commented 1 month ago

Sometimes, we are only interested in a single point of interest on the target body, rather than the full mapped image, so it would be useful to have some method to interpolate values for a single location. This would effectively be equivalent to performing a mapping for a single lon/lat coordinate with

map_kwargs = planetmapper.MapKwargs(
    projection='manual',
    lon_coords=np.asarray((float(lon),)),
    lat_coords=np.asarray((float(lat),)),
)

but would be much easier to use.

ortk95 commented 1 month ago

Would probably want to add two new public methods to the API:

These methods should ideally accept arrays of coordinates, like we can currently do with _maybe_transform_as_arrays in coordinate conversions. As stuff like constructing the interpolator can potentially be costly, we'll probably want to only do this once for each call, rather than simply vectorising with _maybe_transform_as_arrays.

For DRY and consistency purposes, we'll also probably want to re-write map_img to use interpolate_lonlat/interpolate_xy internally. This will mean that map_img will only need to think about constructing the x and y maps, then the new interpolate methods will handle all the actual logic.

ortk95 commented 1 month ago

Also, for consistency with map_img, we want to be able to natively support cubes in these new interpolation methods.