Esempio n. 1
0
 def __new__(cls, fft_filter=None, ncorrelations=None, nsamples=None):
     if fft_filter is None:
         return Operator.__new__(cls)
     filter_length = fft_filter.shape[-1]
     invntt = DiagonalOperator(fft_filter)
     fft = FftHalfComplexOperator(filter_length)
     padding = PadOperator(left=ncorrelations, right=filter_length - \
                           nsamples - ncorrelations)
     return padding.T * fft.T * invntt * fft * padding
Esempio n. 2
0
 def __new__(cls, fft_filter=None, ncorrelations=None, nsamples=None):
     if fft_filter is None:
         return Operator.__new__(cls)
     filter_length = fft_filter.shape[-1]
     invntt = DiagonalOperator(fft_filter)
     fft = FftHalfComplexOperator(filter_length)
     padding = PadOperator(left=ncorrelations, right=filter_length - \
                           nsamples - ncorrelations)
     return padding.T * fft.T * invntt * fft * padding
Esempio n. 3
0
    def __new__(cls, obs=None, method='uncorrelated', **keywords):
        if obs is None:
            return Operator.__new__(cls)
        nsamples = obs.get_nsamples()
        comm_tod = obs.instrument.comm
        method = method.lower()
        if method not in ('uncorrelated', 'uncorrelated python'):
            raise ValueError("Invalid method '{0}'.".format(method))

        filter = obs.get_filter_uncorrelated(**keywords)
        if filter.ndim == 2:
            filter = filter[np.newaxis, ...]
        nfilters = filter.shape[0]
        if nfilters != 1 and nfilters != len(nsamples):
            raise ValueError(
                "Incompatible number of filters '{0}'. Expected nu"
                "mber is '{1}'".format(nfilters, len(nsamples)))
        ncorrelations = filter.shape[-1] - 1
        filter_length = np.asarray(2**np.ceil(np.log2(np.array(nsamples) + \
                                   2 * ncorrelations)), int)
        fft_filters = []
        for i, n in enumerate(filter_length):
            i = min(i, nfilters - 1)
            fft_filter, status = tmf.fft_filter_uncorrelated(filter[i].T, n)
            if status != 0: raise RuntimeError()
            np.maximum(fft_filter, 0, fft_filter)
            fft_filters.append(fft_filter.T)

        norm = comm_tod.allreduce(max(np.max(f) for f in fft_filters),
                                  op=MPI.MAX)
        for f in fft_filters:
            np.divide(f, norm, f)

        if method == 'uncorrelated':
            cls = InvNttUncorrelatedOperator
        else:
            cls = InvNttUncorrelatedPythonOperator
        #XXX should generate BlockDiagonalOperator with no duplicates...
        return BlockDiagonalOperator([cls(f, ncorrelations, n) \
                   for f, n in zip(fft_filters, nsamples)], axisin=-1)
Esempio n. 4
0
    def __new__(cls, obs=None, method='uncorrelated', **keywords):
        if obs is None:
            return Operator.__new__(cls)
        nsamples = obs.get_nsamples()
        comm_tod = obs.instrument.comm
        method = method.lower()
        if method not in ('uncorrelated', 'uncorrelated python'):
            raise ValueError("Invalid method '{0}'.".format(method))

        filter = obs.get_filter_uncorrelated(**keywords)
        if filter.ndim == 2:
            filter = filter[np.newaxis,...]
        nfilters = filter.shape[0]
        if nfilters != 1 and nfilters != len(nsamples):
            raise ValueError("Incompatible number of filters '{0}'. Expected nu"
                             "mber is '{1}'".format(nfilters, len(nsamples)))
        ncorrelations = filter.shape[-1] - 1
        filter_length = np.asarray(2**np.ceil(np.log2(np.array(nsamples) + \
                                   2 * ncorrelations)), int)
        fft_filters = []
        for i, n in enumerate(filter_length):
            i = min(i, nfilters-1)
            fft_filter, status = tmf.fft_filter_uncorrelated(filter[i].T, n)
            if status != 0: raise RuntimeError()
            np.maximum(fft_filter, 0, fft_filter)
            fft_filters.append(fft_filter.T)
        
        norm = comm_tod.allreduce(max(np.max(f) for f in fft_filters),
                                  op=MPI.MAX)
        for f in fft_filters:
            np.divide(f, norm, f)
            
        if method == 'uncorrelated':
            cls = InvNttUncorrelatedOperator
        else:
            cls = InvNttUncorrelatedPythonOperator
        #XXX should generate BlockDiagonalOperator with no duplicates...
        return BlockDiagonalOperator([cls(f, ncorrelations, n) \
                   for f, n in zip(fft_filters, nsamples)], axisin=-1)