neclib.coordinates.optimize module#

Aliases#

ValueRange

Value range bound by 2 values.

get_logger

Get logger instance which prints operation logs to console.

class DriveLimitChecker(limit, preferred_limit=None, *, unit=None, max_observation_size=<Quantity 5. deg>)[source]#

Bases: object

Find optimum and safe angle to drive to.

The optimization includes:

  1. Apply drive range constraint

  2. Avoid direction unwrapping (360deg drive) during observation

  3. Avoid over-180deg drive

Parameters:
  • limit (ValueRange[Quantity | int | float | ndarray[Any, dtype[number]] | Array[int | float]]) – Drive range limit, the optimization result never go out of this range.

  • preferred_limit (ValueRange[Quantity | int | float | ndarray[Any, dtype[number]] | Array[int | float]] | None) – Drive range limit, which can be violated to continue observation or no other choice found.

  • unit (UnitBase | str | None) – Angular unit in which the parameters are given.

  • max_observation_size (Quantity | int | float | ndarray[Any, dtype[number]] | Array[int | float]) – If separation between current and target coordinates is smaller than this value, direction unwrapping won’t occur, possibly violating preferred_limit, to not interrupt observation.

Examples

>>> checker = neclib.coordinates.DriveLimitChecker(
...     [-260 << u.deg, 260 << u.deg], [-250 << u.deg, 250 << u.deg]
... )
>>> checker.optimize(current=-200 << u.deg, target=170 << u.deg)
<Quantity -190. deg>
optimize(current, target, unit=None)[source]#

Optimize the coordinate to command.

Parameters:
  • current (Quantity | int | float | ndarray[Any, dtype[number]] | Array[int | float]) – Current coordinate, scalar or n-d array of shape […, N].

  • target (Quantity | int | float | ndarray[Any, dtype[number]] | Array[int | float]) – Target coordinate to be optimized, scalar or n-d array of shape […, N] or […, N, T], where T is time series length.

  • unit (UnitBase | str | None) – Angular unit in which the current and target are given.

Return type:

Quantity | None