def precompute_attributes(self, model_arr, flags_arr, noise):
        """
        Set the initial weights to 1 and set the weights of the flags data points to 0

        Args:
            model_arr (np.ndarray):
                Shape (n_dir, n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing 
                model visibilities.
            flags_arr (np.ndarray):
                Shape (n_tim, n_fre, n_ant, n_ant) array containing  flags
        """
        PerIntervalGains.precompute_attributes(self, model_arr, flags_arr,
                                               noise)

        self.weights_shape = [
            self.n_mod, self.n_tim, self.n_fre, self.n_ant, self.n_ant, 1
        ]

        self.weights = np.ones(self.weights_shape, dtype=self.dtype)
        self.weights[:, flags_arr != 0] = 0
        self._init_flags = flags_arr

        unflagged = flags_arr == 0

        self.num_init_unflaged_eqs = np.sum(unflagged)
        self.v = 2.  #t-distribution number of degrees of freedom
Exemple #2
0
    def precompute_attributes(self, data_arr, model_arr, flags_arr, noise):
        """
        """
        PerIntervalGains.precompute_attributes(self, data_arr, model_arr,
                                               flags_arr, noise)

        if self._estimate_pzd:
            marr = model_arr[..., (0, 1), (1, 0)][:, 0].sum(0)
            darr = data_arr[..., (0, 1), (1, 0)][0]
            mask = (flags_arr[..., np.newaxis] != 0) | (marr == 0)
            dm = darr * (np.conj(marr) / abs(marr))
            dabs = np.abs(darr)
            dm[mask] = 0
            dabs[mask] = 0
            # collapse time/freq axis into intervals and sum antenna axes
            dm_sum = self.interval_sum(dm).sum(axis=(2, 3))
            dabs_sum = self.interval_sum(dabs).sum(axis=(2, 3))
            # sum off-diagonal terms
            dm_sum = dm_sum[..., 0] + np.conj(dm_sum[..., 1])
            dabs_sum = dabs_sum[..., 0] + np.conj(dabs_sum[..., 1])
            pzd = np.angle(dm_sum / dabs_sum)
            pzd[dabs_sum == 0] = 0

            print("{}: PZD estimate {}".format(self.chunk_label, pzd),
                  file=log(2))
            self.gains[:, :, :, :, 1, 1] = np.exp(-1j * pzd)[np.newaxis, :, :,
                                                             np.newaxis]
Exemple #3
0
    def precompute_attributes(self, data_arr, model_arr, flags_arr, noise):
        """
        Precompute (J\ :sup:`H`\J)\ :sup:`-1`, which does not vary with iteration.

        Args:
            model_arr (np.ndarray):
                Shape (n_dir, n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing 
                model visibilities.
        """
        PerIntervalGains.precompute_attributes(self, data_arr, model_arr, flags_arr, noise)

        self.jhjinv = np.zeros_like(self.gains)

        self.kernel_solve.compute_jhj(model_arr, self.jhjinv, self.t_int, self.f_int)

        self.kernel_solve.compute_jhjinv(self.jhjinv, self.jhjinv, self.gflags, self.eps, FL.ILLCOND)

        self.jhjinv = self.jhjinv.real