def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs,
                 chunk_label, options):
        """
        Initialises a diagonal phase-only gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """
        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts,
                                  chunk_fs, chunk_label, options,
                                  self.get_kernel(options))

        self.phases = self.cykernel.allocate_gain_array(self.gain_shape,
                                                        dtype=self.ftype,
                                                        zeros=True)
        self.gains = np.empty_like(self.phases, dtype=self.dtype)
        self.gains[:] = np.eye(self.n_cor)
        self.old_gains = self.gains.copy()
 def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs,
              chunk_label, options):
     """
     Initialises a 2x2 complex gain machine.
     
     Args:
         label (str):
             Label identifying the Jones term.
         data_arr (np.ndarray): 
             Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
             visibilities. 
         ndir (int):
             Number of directions.
         nmod (nmod):
             Number of models.
         chunk_ts (np.ndarray):
             Times for the data being processed.
         chunk_fs (np.ndarray):
             Frequencies for the data being processsed.
         options (dict): 
             Dictionary of options. 
     """
     PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts,
                               chunk_fs, chunk_label, options,
                               self.get_kernel(options))
Beispiel #3
0
    def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs, chunk_label, options):
        """
        Initialises a diagonal phase-only gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """
        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod,
                                  chunk_ts, chunk_fs, chunk_label, options)

        # kernel used in solver is diag-diag in diag mode, else uses full kernel version
        if options.get('diag-data') or options.get('diag-only'):
            self.kernel_solve = cubical.kernels.import_kernel('diag_phase_only')
        else:
            self.kernel_solve = cubical.kernels.import_kernel('phase_only')

        self.phases = self.kernel.allocate_gain_array(self.gain_shape, dtype=self.ftype, zeros=True)
        self.gains = np.empty_like(self.phases, dtype=self.dtype)
        self.gains[:] = np.eye(self.n_cor) 
        self.old_gains = self.gains.copy()
Beispiel #4
0
    def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs,
                 chunk_label, options):
        """
        Initialises a 2x2 complex gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """
        # note that this sets up self.kernel
        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts,
                                  chunk_fs, chunk_label, options)

        # try guesstimating the PZD
        self._estimate_pzd = options["estimate-pzd"]
        self._offdiag_only = options["offdiag-only"]
    def __init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs,
                 chunk_label, options):
        """
        Initialises a weighted complex 2x2 gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """

        # clumsy but necessary: can't import at top level (OMP must not be touched before worker processes
        # are forked off), so we import it only in here

        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts,
                                  chunk_fs, chunk_label, options,
                                  self.get_kernel(options))

        self.residuals = np.empty_like(data_arr)

        self.save_weights = options.get("robust-save-weights", False)

        self.label = label

        self.cov_type = options.get(
            "robust-cov", "hybrid"
        )  #adding an option to compute residuals covariance or just assume 1 as in Robust-t paper

        self.npol = options.get(
            "robust-npol", 2
        )  #testing if the number of polarizations really have huge effects

        self.v_int = options.get("robust-int", 5)
    def __init__(self, label, data_arr, ndir, nmod,
                 chunk_ts, chunk_fs, chunk_label, options):

        """
        Initialises a weighted complex 2x2 gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """

        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs, chunk_label, options)

        self.kernel_robust = cubical.kernels.import_kernel("full_W_complex")

        self.residuals = np.empty_like(data_arr)

        self.save_weights = options.get("robust-save-weights", False)
        
        self.label = label

        self.cov_type = options.get("robust-cov", "compute") #adding an option to compute residuals covariance or just assume 1 as in Robust-t paper

        self.npol = options.get("robust-npol", 2.) #testing if the number of polarizations really have huge effects

        self.v_int = options.get("robust-int", 1)

        self.cov_scale = options.get("robust-scale", True) # scale the covariance by n_corr*2
Beispiel #7
0
    def __init__(self, label, model_arr, ndir, nmod, chunk_ts, chunk_fs,
                 chunk_label, options):
        # clumsy but necessary: can't import at top level (OMP must not be touched before worker processes
        # are forked off), so we import it only in here
        import cubical.kernels.cyfull_W_complex
        global cyfull
        cyfull = cubical.kernels.cyfull_W_complex

        PerIntervalGains.__init__(self, label, model_arr, ndir, nmod, chunk_ts,
                                  chunk_fs, chunk_label, options)

        self.gains = np.empty(self.gain_shape, dtype=self.dtype)

        self.gains[:] = np.eye(self.n_cor)

        self.old_gains = self.gains.copy()

        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.v = 2.
    def __init__(self, label, data_arr, ndir, nmod,
                 chunk_ts, chunk_fs, chunk_label, options):

        """
        Initialises a weighted complex 2x2 gain machine.
        
        Args:
            label (str):
                Label identifying the Jones term.
            data_arr (np.ndarray): 
                Shape (n_mod, n_tim, n_fre, n_ant, n_ant, n_cor, n_cor) array containing observed 
                visibilities. 
            ndir (int):
                Number of directions.
            nmod (nmod):
                Number of models.
            chunk_ts (np.ndarray):
                Times for the data being processed.
            chunk_fs (np.ndarray):
                Frequencies for the data being processsed.
            options (dict): 
                Dictionary of options. 
        """

        PerIntervalGains.__init__(self, label, data_arr, ndir, nmod, chunk_ts, chunk_fs, chunk_label, options)

        if self.is_diagonal:
            self.kernel_robust = cubical.kernels.import_kernel("diag_robust")
        else:
            self.kernel_robust = cubical.kernels.import_kernel("full_W_complex")

        self.residuals = np.empty_like(data_arr)

        self.save_weights = options.get("robust-save-weights", False)
        
        self.label = label

        self.cov_type = options.get("robust-cov", "compute") # adding an option to compute residuals covariance or just assume 1 as in Robust-t paper

        self.npol = options.get("robust-npol", 2.) # testing if the number of polarizations really have huge effects

        self.v_int = options.get("robust-int", 5)

        self.cov_scale = options.get("robust-scale", 0) # scale down the covariance by this factor

        self.cov_thresh = options.get("robust-cov-thresh",  1)

        self.sigma_thresh = options.get("robust-sigma-thresh", 3)

        self.robust_flag_weights = options.get("robust-flag-weights", True)

        self.fixed_v = False

        self.not_all_flagged = True

        self._flag = True

        self.any_new = 0

        self.is_robust = True # to identify this machine as the robust solver

        self._estimate_pzd = options["estimate-pzd"]

        # this will be set to PZD and exp(-i*PZD) once the PZD estimate is done
        self._pzd = 0
        self._exp_pzd = 1