sugar.py 841 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
# -*- coding: utf-8 -*-

from nifty import PowerSpace,\
                  Field,\
                  DiagonalOperator,\
                  FFTOperator

__all__ = ['create_power_operator']


11 12
def create_power_operator(domain, power_spectrum, dtype=None,
                          distribution_strategy='not'):
13 14 15 16
    if not domain.harmonic:
        fft = FFTOperator(domain)
        domain = fft.target[0]

17
    power_domain = PowerSpace(domain,
18
                              dtype=dtype,
19
                              distribution_strategy=distribution_strategy)
20 21 22 23 24

    fp = Field(power_domain,
               val=power_spectrum,
               distribution_strategy=distribution_strategy)

Theo Steininger's avatar
Theo Steininger committed
25
    f = fp.power_synthesize(mean=1, std=0, real_signal=False)
26

27
    power_operator = DiagonalOperator(domain, diagonal=f, bare=True)
28 29

    return power_operator