#!/usr/bin/env python
from typing import Iterable
import numpy as np
from ..ast_object import ASTObject
[docs]class ASTMapping(ASTObject):
'''
:param ast_object: an existing :class:`starlink.Ast.Mapping` object
'''
def __init__(self, ast_object=None):
super().__init__(ast_object=ast_object)
@property
def numberOfInputCoordinates(self):
'''
Number of dimensions of the space in which the Mapping’s input points reside.
This property gives the number of coordinate values required to specify an input point for a Mapping.
:returns: number of input dimensions described by this mapper
'''
return self.astObject.get("Nin")
@property
def numberOfOutputCoordinates(self):
'''
Number of dimensions of the space in which the Mapping’s output points reside.
This property gives the number of coordinate values required to specify an output point for a Mapping.
:returns: number of output dimensions described by this mapper
'''
return self.astObject.get("Nout")
@property
def isLinear(self) -> bool:
'''
Returns True if the mapping is linear
'''
return self.astObject.get("IsLinear") == 1
@property
def isSimple(self) -> bool:
'''
Returns True if the mapping has been simplified.
'''
return self.astObject.get("IsSimple") == 1
[docs] def inverseMapping(self):
'''
Returns a new mapping object that is the inverse of this mapping.
For example, if the forward transformation of this mapping is pixel to sky,
then the forward transformation of the returned mapping
will be sky to pixel.
'''
inv_mapping = self.astObject.copy() # creates a new mapping
return ASTMapping(ast_object=inv_mapping.invert())
# TODO, test "out" param, out:Iterable=None): # ? use forward=T/F