Source code for irfpy.cena.centralpixel
''' A CENA FoV module.
CENA FoV is indeed a finite area in the angular space.
However, for simple investigation, the center vectors for each channel
can be used as a representation. This module provides an implementation.
Use :mod:`irfpy.cena.fov` module for advanced and generic use.
'''
import math
from irfpy.util.vector3d import Vector3d
from irfpy.cena import frame
[docs]class Fov:
''' Abstract class of CENA FoV.
'''
[docs]class FovIss1Rev1(Fov):
''' An implementation of CENA FoV.
CENA FoV with central direction approximation.
Data based on the calibration report issue 1 revision1.
'''
def __init__(self):
'''
'''
[docs] def getDirection(self, ch):
''' Get the viewing vector in SC frame corresponding to the looking direction.
Central azimuth direction, phi_c[n], is formulated as
phi_c[n] = -19.06*n + 57.19 ... Eq 3.2.
FWHM is 45 degrees, but in this implementation, it is ignored.
The elevation theta_c[n] is -6.05 degs in Eq. 3.4.
FWHM is 6.44 degs while is ignored.
>>> fov = FovIss1Rev1()
The returned value is an instance of Vector3d.
>>> v = fov.getDirection(0)
>>> # print v.x, v.y, v.z
If you specify the unexisting ch (other than 0 to 6),
IndexError will be raised.
>>> try:
... fov.getDirection(-1)
... print("Why didn't exception raised?")
... except IndexError as e:
... print("Correct exception is raised.")
... except:
... print("Unknonw exception raised.")
Correct exception is raised.
'''
if ch<0 or ch>6:
raise IndexError("CENA channels should be 0..6 (%s given)" % str(ch))
theta = -6.05
phi = (-19.06 * ch + 57.19)
v_cena = self._angle2vec(theta, phi)
v_sc = frame.cena2sc(v_cena)
return v_sc
@classmethod
def _angle2vec(self, theta, phi):
''' Calculate the vector corresponding to theta and phi.
According to the calibration report, theta is the angle from XY plane
and -Z direction is +theta.
phi is an azimuthal angle, and the origin is +Y and +X direction
is +phi.
theta and phi is in degrees.
>>> v = FovIss1Rev1._angle2vec(0, 0)
>>> v = FovIss1Rev1._angle2vec(90, 0)
'''
t = theta * math.pi / 180.
p = phi * math.pi / 180.
z = math.sin(-t)
y = math.cos(-t) * math.cos(p)
x = math.cos(-t) * math.sin(p)
return Vector3d(x, y, z)