sugar.py 749 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# -*- coding: utf-8 -*-

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

__all__ = ['create_power_operator']


def create_power_operator(domain, power_spectrum, distribution_strategy='not'):
    if not domain.harmonic:
        fft = FFTOperator(domain)
        domain = fft.target[0]

16
17
    power_domain = PowerSpace(domain,
                              distribution_strategy=distribution_strategy)
18
19
20
21
22

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

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

    power_operator = DiagonalOperator(domain, diagonal=f)

    return power_operator