use anyhow::Error;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum FeedPol {
X,
Y,
R,
L,
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum VisPol {
XX,
XY,
YX,
YY,
RR,
RL,
LR,
LL,
I,
Q,
U,
V,
}
impl VisPol {
pub fn feedpol1(self) -> FeedPol {
match self {
VisPol::XX | VisPol::XY => FeedPol::X,
VisPol::YX | VisPol::YY => FeedPol::Y,
VisPol::RR | VisPol::RL => FeedPol::R,
VisPol::LR | VisPol::LL => FeedPol::L,
VisPol::I | VisPol::Q | VisPol::U | VisPol::V => {
panic!("cannot convert Stokes VisPol into FeedPol")
}
}
}
pub fn feedpol2(self) -> FeedPol {
match self {
VisPol::XX | VisPol::YX => FeedPol::X,
VisPol::XY | VisPol::YY => FeedPol::Y,
VisPol::RR | VisPol::LR => FeedPol::R,
VisPol::RL | VisPol::LL => FeedPol::L,
VisPol::I | VisPol::Q | VisPol::U | VisPol::V => {
panic!("cannot convert Stokes VisPol into FeedPol")
}
}
}
}
type AntNum = u16;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct AntPol {
pub ant: AntNum,
pub pol: FeedPol,
}
impl AntPol {
pub fn new(ant: AntNum, pol: FeedPol) -> Self {
AntPol { ant, pol }
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BasePol {
pub ant1: AntNum,
pub ant2: AntNum,
pub pol: VisPol,
}
impl BasePol {
pub fn new(ant1: AntNum, ant2: AntNum, pol: VisPol) -> Self {
BasePol { ant1, ant2, pol }
}
pub fn antpol1(self) -> AntPol {
AntPol {
ant: self.ant1,
pol: self.pol.feedpol1(),
}
}
pub fn antpol2(self) -> AntPol {
AntPol {
ant: self.ant2,
pol: self.pol.feedpol2(),
}
}
}
pub trait VisStream {
fn next(&mut self) -> Result<bool, Error>;
fn basepol(&self) -> BasePol;
}