From 25abccd9c727ea764e6c4e3b36a187a6b4286a10 Mon Sep 17 00:00:00 2001 From: theos <theo.steininger@ultimanet.de> Date: Wed, 12 Oct 2016 02:18:39 +0200 Subject: [PATCH] Added create_power_operator in sugar.py --- nifty/sugar.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 nifty/sugar.py diff --git a/nifty/sugar.py b/nifty/sugar.py new file mode 100644 index 000000000..8bba990bf --- /dev/null +++ b/nifty/sugar.py @@ -0,0 +1,26 @@ +# -*- 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] + + power_domain = PowerSpace(domain) + + fp = Field(power_domain, + val=power_spectrum, + distribution_strategy=distribution_strategy) + + f = fp.power_synthesize(mean=1, std=0) + + power_operator = DiagonalOperator(domain, diagonal=f) + + return power_operator -- GitLab