RotatedFrameFitter

class trackstream.preprocess.RotatedFrameFitter(data: astropy.coordinates.BaseCoordinateFrame, origin: astropy.coordinates.builtin_frames.ICRS, **kwargs)[source]

Bases: object

Class to Fit Rotated Frames.

Todo

include errors.

Parameters
dataBaseCoordinateFrame

In ICRS coordinates.

originICRS

location of point on sky about which to rotate.

Other Parameters
rot_lower, rot_upperQuantity, (optional, keyword-only)

The lower and upper bounds in degrees. Default is (-180, 180] degree.

origin_limQuantity, (optional, keyword-only)

The symmetric lower and upper bounds on origin in degrees. Default is 0.005 degree.

fix_originbool (optional, keyword-only)

Whether to fix the origin point. Default is False.

use_lmfitbool or None, (optional, keyword-only)

Whether to use lmfit package. None (default) falls back to config file.

leastsquaresbool (optional, keyword-only)

If use_lmfit is False, whether to to use least_square() or minimize() Default is False

align_vbool

Whether to align by the velocity.

Attributes Summary

default_fit_options

Methods Summary

align_v_positive_lon(fit_values[, subsel])

Align the velocity along the positive Longitudinal direction.

fit([rot0, bounds, fix_origin, use_lmfit, ...])

Find Best-Fit Rotated Frame.

plot_data()

plot_residual([fitresult, num_rots, scalar])

Plot Residual as a function of rotation angle.

residual(rotation, *[, scalar])

How close phi2, the rotated latitude (dec), is to flat.

set_bounds([rot_lower, rot_upper, origin_lim])

Make bounds on Rotation parameter.

Attributes Documentation

default_fit_options

Methods Documentation

align_v_positive_lon(fit_values: Dict[str, Any], subsel: Union[ellipsis, Sequence, slice] = Ellipsis)[source]

Align the velocity along the positive Longitudinal direction.

Parameters
fit_valuesdict

The rotation and origin. Output of minimize

subselslice

sub-select a portion of the pm_lon_coslat for determining the average velocity.

Returns
valuesdict

fit_values with “rotation” adjusted.

fit(rot0: Optional[astropy.units.quantity.Quantity] = None, bounds: Optional[Sequence] = None, *, fix_origin: Optional[bool] = None, use_lmfit: Optional[bool] = None, leastsquares: Optional[bool] = None, align_v: Optional[bool] = None, **kwargs)[source]

Find Best-Fit Rotated Frame.

Parameters
rot0Quantity, optional

Initial guess for rotation

boundsarray-like, optional

Parameter bounds.

[[rot_low, rot_up],
 [lon_low, lon_up],
 [lat_low, lat_up]]
Returns
resAny

The result of the minimization. Depends on arguments.

Dict[str, Any]

Has fields “rotation” and “origin”.

Other Parameters
fix_originbool (optional, keyword-only)

Whether to fix the origin.

use_lmfitbool (optional, keyword-only)

Whether to use lmfit package

leastsquaresbool (optional, keyword-only)

If use_lmfit is False, whether to to use least_square() or minimize() (default)

align_vbool (optional, keyword-only)

Whether to align velocity to be in positive direction

fit_kwargs:

Into whatever minimization package / function is used.

Raises
ImportError

If use_lmfit and lmfit is not installed.

plot_data()[source]
plot_residual(fitresult=None, num_rots: int = 3600, scalar: bool = True)[source]

Plot Residual as a function of rotation angle.

residual(rotation, *, scalar: bool = False)[source]

How close phi2, the rotated latitude (dec), is to flat.

Parameters
rotationfloat

The final rotation of the frame about the origin. The sign of the rotation is the left-hand rule. That is, an object at a particular position angle in the un-rotated system will be sent to the positive latitude (z) direction in the final frame. In degrees.

Returns
resfloat or Sequence

\(\rm{lat} - 0\). If scalar is True, then sum array_like to return float.

Other Parameters
scalarbool (optional, keyword-only)

Whether to sum res into a float. Note that if res is also a float, it is unaffected.

set_bounds(rot_lower: astropy.units.quantity.Quantity = <Quantity -180. deg>, rot_upper: astropy.units.quantity.Quantity = <Quantity 180. deg>, origin_lim: astropy.units.quantity.Quantity = <Quantity 0.005 deg>) Tuple[float, float][source]

Make bounds on Rotation parameter.

Parameters
rot_lower, rot_upperQuantity, optional

The lower and upper bounds in degrees.

origin_limQuantity, optional

The symmetric lower and upper bounds on origin in degrees.