def _integrate(data, masks, frequencies, time_axes, ctx): """ Integrate over time and frequency on the TOD plane. :param data: TOD :param masks: mask :param frequencies: frequency axis after integration :param time_axes: time axis after integration :param ctx: context :return: TOD, time axis, frequency axis after integration """ integration_time = ctx.params.integration_time integration_frequency = ctx.params.integration_frequency frequencies = smooth(np.atleast_2d(frequencies), integration_frequency, axis=1)[0] time_axes = smooth(np.atleast_2d(time_axes), integration_time, axis=1)[0] data = smooth(data, integration_time, axis=1) data = smooth(data, integration_frequency, axis=0) if masks is not None: # 'real' mask masks = masks masks = smooth(masks, integration_time, axis=1) masks = (smooth(masks, integration_frequency, axis=0) > 0) else: masks=get_empty_mask(data.shape) tod_vx = ma.array(data, mask=masks) tod_vy = ma.array(data, mask=masks) return tod_vx, tod_vy, frequencies, time_axes
def _integrate(data, masks, frequencies, time_axes, ctx): """ Integrate over time and frequency on the TOD plane. :param data: TOD :param masks: mask :param frequencies: frequency axis after integration :param time_axes: time axis after integration :param ctx: context :return: TOD, time axis, frequency axis after integration """ integration_time = ctx.params.integration_time integration_frequency = ctx.params.integration_frequency frequencies = smooth(np.atleast_2d(frequencies), integration_frequency, axis=1)[0] time_axes = smooth(np.atleast_2d(time_axes), integration_time, axis=1)[0] data = smooth(data, integration_time, axis=1) data = smooth(data, integration_frequency, axis=0) if masks is not None: # 'real' mask masks = masks masks = smooth(masks, integration_time, axis=1) masks = (smooth(masks, integration_frequency, axis=0) > 0) else: masks = get_empty_mask(data.shape) tod_vx = ma.array(data, mask=masks) tod_vy = ma.array(data, mask=masks) return tod_vx, tod_vy, frequencies, time_axes
def get_rfi_mask(tod, mask=None, chi_1=35000, eta_i=[0.5, 0.55, 0.62, 0.75, 1], normalize_standing_waves=True, suppress_dilation=False, plotting=True, sm_kwargs=None, di_kwargs=None): """ Computes a mask to cover the RFI in a data set. :param data: array containing the signal and RFI :param mask: the initial mask :param chi_1: First threshold :param eta_i: List of sensitivities :param normalize_standing_waves: whether to normalize standing waves :param suppress_dilation: if true, mask dilation is suppressed :param plotting: True if statistics plot should be displayed :param sm_kwargs: smoothing key words :param di_kwargs: dilation key words :return mask: the mask covering the identified RFI """ data = tod.data if mask is None: mask = get_empty_mask(data.shape) if sm_kwargs is None: sm_kwargs = get_sm_kwargs() if plotting: sum_threshold_utils.plot_moments(data) if normalize_standing_waves: data = normalize(data, mask) if plotting: sum_threshold_utils.plot_moments(data) p = 1.5 m = np.arange(1, MAX_PIXELS) M = 2**(m - 1) chi_i = chi_1 / p**np.log2(m) st_mask = mask for eta in eta_i: st_mask = _run_sumthreshold(data, st_mask, eta, M, chi_i, sm_kwargs, plotting) dilated_mask = st_mask if not suppress_dilation: if di_kwargs is None: di_kwargs = get_di_kwrags() dilated_mask = binary_mask_dilation(dilated_mask - mask, **di_kwargs) if plotting: sum_threshold_utils.plot_dilation(st_mask, mask, dilated_mask) return dilated_mask + mask