Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feed flip term. #355

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion quartical/calibration/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ def solver_wrapper(
corr_mode
)
else:
jhj = np.zeros(getattr(active_spec, "pshape", active_spec.shape))
pshape, gshape = active_spec.pshape, active_spec.shape
jhj = np.zeros(pshape if term.is_parameterized else gshape)
conv_iter, conv_perc = 0, 1

# If reweighting is enabled, do it when the epoch changes, except
Expand Down
1 change: 1 addition & 0 deletions quartical/config/gain_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gain:
- crosshand_phase_null_v
- leakage
- parallactic_angle
- feed_flip
info:
Type of gain to solve for.

Expand Down
4 changes: 3 additions & 1 deletion quartical/gains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from quartical.gains.leakage import Leakage
from quartical.gains.delay_and_tec import DelayAndTec
from quartical.gains.parallactic_angle import ParallacticAngle
from quartical.gains.feed_flip import FeedFlip


TERM_TYPES = {
Expand All @@ -26,5 +27,6 @@
"crosshand_phase_null_v": CrosshandPhaseNullV,
"leakage": Leakage,
"delay_and_tec": DelayAndTec,
"parallactic_angle": ParallacticAngle
"parallactic_angle": ParallacticAngle,
"feed_flip": FeedFlip
}
47 changes: 47 additions & 0 deletions quartical/gains/feed_flip/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import numpy as np
from quartical.gains.gain import Gain
from quartical.gains.conversion import amp_trig_to_complex


class FeedFlip(Gain):

solver = None # This is not a solvable term.
# Conversion functions required for interpolation NOTE: Non-parameterised
# gains will always be reinterpreted and parameterised in amplitude and
# phase for the sake of simplicity.
# TODO: Make this a real valued term - took simple approach for now.
native_to_converted = (
(0, (np.abs,)),
(0, (np.angle, np.cos)),
(1, (np.angle, np.sin))
)
converted_to_native = (
(3, amp_trig_to_complex),
)
converted_dtype = np.float64
native_dtype = np.complex128

def __init__(self, term_name, term_opts):

super().__init__(term_name, term_opts)

self.time_interval = 0
self.freq_interval = 0

def init_term(self, term_spec, ref_ant, ms_kwargs, term_kwargs, meta=None):
"""Initialise the gains (and parameters)."""

(_, _, gain_shape, _) = term_spec

gains = np.ones(gain_shape, dtype=np.complex128)

if gain_shape[-1] == 4:
gains[..., (0, 3)] = 0 # 2-by-2 antidiagonal.
else:
raise ValueError(
"Feed flip unsupported for less than four correlations"
)

gain_flags = np.zeros(gains.shape[:-1], dtype=np.int8)

return gains, gain_flags