Skip to content

Commit

Permalink
Rotation solver (#238)
Browse files Browse the repository at this point in the history
* Commit stable changes as a prelude to tidying up recent work.

* Multiply chan freq by 2pi - removes all other usage of this factor.

* Formalise ability to write model data.

* Add hacky delay estimator - checkpointing before incorporating it properly.

* Formalise gain inits - now unique per term (with a standard default). Increase numbness on delay flags.

* Make reference antenna controllable.

* Upgrade phase-only solver to be insensitive to amplitudes.

* Update crosshand phase solver.

* Add rudimentary init for the crosshand phase - assumes solution int of 0 in time and 1 in freq.

* Improve phase only solver tests in pursuit of other problems.

* Zero flagged data when estimating delays.

* Add funtionality to load terms with fewer/more correlations than the present solve requires.

* Fix to prevent gains loaded from disk being reinitialised.

* Remove X init method - it is incorrect when not using corrected data.

* Fix converged perc going over 100. Change normalisation approach.

* Revert bad change to normalisation code.

* Make alteration to delay kernel to ignore off-diagonal residuals - aids convergence.

* Make diag_complex ignore off diagonal components of the residual.

* Add beginnings of revision to amplitude only solver. Currently in a hacky form to test the maths - checkpointing before refining.

* Finish up changes to amplitude solver. Rely on modified (phase-locked) residual computation.

* Minor modification to make tec solver consistent with delay solver.

* Fix error in delay init when data contains autocorrelations.

* Allow initial estimates to be disabled.

* Add a pure rotation solver.

* Actually add all files.

* Attempt to update rotation solver.

* Mix some bad merging.

* Fix some bad merging.

* Fix some bad merging.

* Fix some bad merging.

* Fix some bad merging.

* Fix bug + tests.
  • Loading branch information
JSKenyon authored Mar 24, 2023
1 parent 4e57140 commit 3f328c3
Show file tree
Hide file tree
Showing 5 changed files with 784 additions and 0 deletions.
1 change: 1 addition & 0 deletions quartical/config/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class Gain(Input):
"pure_delay",
"phase",
"tec",
"rotation",
"rotation_measure",
"crosshand_phase",
"leakage"])
Expand Down
2 changes: 2 additions & 0 deletions quartical/gains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from quartical.gains.phase import Phase
from quartical.gains.delay import Delay, PureDelay
from quartical.gains.tec import TEC
from quartical.gains.rotation import Rotation
from quartical.gains.rotation_measure import RotationMeasure
from quartical.gains.crosshand_phase import CrosshandPhase
from quartical.gains.leakage import Leakage
Expand All @@ -15,6 +16,7 @@
"delay": Delay,
"pure_delay": PureDelay,
"tec": TEC,
"rotation": Rotation,
"rotation_measure": RotationMeasure,
"crosshand_phase": CrosshandPhase,
"leakage": Leakage}
42 changes: 42 additions & 0 deletions quartical/gains/rotation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from quartical.gains.gain import Gain, gain_spec_tup, param_spec_tup
from quartical.gains.rotation.kernel import rotation_solver, rotation_args
import numpy as np


class Rotation(Gain):

solver = rotation_solver
term_args = rotation_args

def __init__(self, term_name, term_opts, data_xds, coords, tipc, fipc):

Gain.__init__(self, term_name, term_opts, data_xds, coords, tipc, fipc)

self.n_param = 1 # This term only makes sense in a 2x2 chain.
self.gain_chunk_spec = gain_spec_tup(self.n_tipc_g,
self.n_fipc_g,
(self.n_ant,),
(self.n_dir,),
(self.n_corr,))
self.param_chunk_spec = param_spec_tup(self.n_tipc_g, # Check!
self.n_fipc_g,
(self.n_ant,),
(self.n_dir,),
(self.n_param,))

self.gain_axes = ("gain_t", "gain_f", "ant", "dir", "corr")
self.param_axes = ("param_t", "param_f", "ant", "dir", "param")

def make_xds(self):

xds = Gain.make_xds(self)

xds = xds.assign_coords({"param": np.array(["rotation"]),
"param_t": self.gain_times,
"param_f": self.gain_freqs})
xds = xds.assign_attrs({"GAIN_SPEC": self.gain_chunk_spec,
"PARAM_SPEC": self.param_chunk_spec,
"GAIN_AXES": self.gain_axes,
"PARAM_AXES": self.param_axes})

return xds
Loading

0 comments on commit 3f328c3

Please sign in to comment.