FunctionTransform#

class astropy.coordinates.FunctionTransform(func, fromsys, tosys, priority=1, register_graph=None)[source]#

Bases: CoordinateTransform

A coordinate transformation defined by a function that accepts a coordinate object and returns the transformed coordinate object.

Parameters:
funccallable()

The transformation function. Should have a call signature func(formcoord, toframe). Note that, unlike CoordinateTransform.__call__, toframe is assumed to be of type tosys for this function.

fromsysclass

The coordinate frame class to start from.

tosysclass

The coordinate frame class to transform into.

priorityfloat or int

The priority if this transform when finding the shortest coordinate transform path - large numbers are lower priorities.

register_graphTransformGraph or None

A graph to register this transformation with on creation, or None to leave it unregistered.

Raises:
TypeError

If func is not callable.

ValueError

If func cannot accept two arguments.

Methods Summary

__call__(fromcoord, toframe)

Does the actual coordinate transformation from the fromsys class to the tosys class.

Methods Documentation

__call__(fromcoord, toframe)[source]#

Does the actual coordinate transformation from the fromsys class to the tosys class.

Parameters:
fromcoordBaseCoordinateFrame subclass instance

An object of class matching fromsys that is to be transformed.

toframeobject

An object that has the attributes necessary to fully specify the frame. That is, it must have attributes with names that match the keys of the dictionary tosys.frame_attributes. Typically this is of class tosys, but it might be some other class as long as it has the appropriate attributes.

Returns:
tocoordBaseCoordinateFrame subclass instance

The new coordinate after the transform has been applied.