Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Inputs in ``from_frame``, separate inputs for each dimension.
output_with_units : bool
If ``True`` - returns a `~astropy.coordinates.SkyCoord` or
`~astropy.units.Quantity` object.
with_bounding_box : bool, optional
If True(default) values in the result which correspond to any of the inputs being
outside the bounding_box are set to ``fill_value``.
fill_value : float, optional
Output value for inputs outside the bounding_box (default is np.nan).
"""
transform = self.get_transform(from_frame, to_frame)
if not utils.isnumerical(args[0]):
inp_frame = getattr(self, from_frame)
args = inp_frame.coordinate_to_quantity(*args)
if not transform.uses_quantity:
args = utils.get_values(inp_frame.unit, *args)
with_units = kwargs.pop("with_units", False)
if 'with_bounding_box' not in kwargs:
kwargs['with_bounding_box'] = True
if 'fill_value' not in kwargs:
kwargs['fill_value'] = np.nan
result = transform(*args, **kwargs)
if with_units:
to_frame_name, to_frame_obj = self._get_frame_name(to_frame)
if to_frame_obj is not None:
if to_frame_obj.naxes == 1:
result = to_frame_obj.coordinates(result)
else:
result = to_frame_obj.coordinates(*result)
def world_to_array_index(self, *world_objects):
"""
Convert world coordinates (represented by Astropy objects) to array
indices.
"""
result = self.invert(*world_objects, with_units=True)[::-1]
return tuple([utils._toindex(r) for r in result])