correlated_fields.py 3.2 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2018 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.

19
from __future__ import absolute_import, division, print_function
Philipp Arras's avatar
Philipp Arras committed
20

21
from ..compat import *
Philipp Arras's avatar
Philipp Arras committed
22
from ..domain_tuple import DomainTuple
Martin Reinecke's avatar
Martin Reinecke committed
23 24
from ..multi_field import MultiField
from ..multi_domain import MultiDomain
Martin Reinecke's avatar
Martin Reinecke committed
25
from ..operators.domain_distributor import DomainDistributor
Martin Reinecke's avatar
Martin Reinecke committed
26
from ..operators.harmonic_operators import HarmonicTransformOperator
Martin Reinecke's avatar
cleanup  
Martin Reinecke committed
27
from ..operators.distributors import PowerDistributor
Martin Reinecke's avatar
Martin Reinecke committed
28
from ..operators.operator import Operator
Martin Reinecke's avatar
Martin Reinecke committed
29
from ..operators.simple_linear_operators import FieldAdapter
Martin Reinecke's avatar
Martin Reinecke committed
30

Martin Reinecke's avatar
Martin Reinecke committed
31

Martin Reinecke's avatar
Martin Reinecke committed
32
def CorrelatedField(s_space, amplitude_model):
33
    '''
Martin Reinecke's avatar
Martin Reinecke committed
34
    Function for construction of correlated fields
35 36 37

    Parameters
    ----------
Martin Reinecke's avatar
Martin Reinecke committed
38
    s_space : Field domain
39 40 41

    amplitude_model : model for correlation structure
    '''
Martin Reinecke's avatar
Martin Reinecke committed
42 43 44 45 46 47 48 49
    h_space = s_space.get_default_codomain()
    ht = HarmonicTransformOperator(h_space, s_space)
    p_space = amplitude_model.target[0]
    power_distributor = PowerDistributor(h_space, p_space)
    A = power_distributor(amplitude_model)
    domain = MultiDomain.union(
        (amplitude_model.domain, MultiDomain.make({"xi": h_space})))
    return ht(A*FieldAdapter(domain, "xi"))
50 51


52 53 54 55 56 57 58 59 60 61
# def make_mf_correlated_field(s_space_spatial, s_space_energy,
#                              amplitude_model_spatial, amplitude_model_energy):
#     '''
#     Method for construction of correlated multi-frequency fields
#     '''
#     h_space_spatial = s_space_spatial.get_default_codomain()
#     h_space_energy = s_space_energy.get_default_codomain()
#     h_space = DomainTuple.make((h_space_spatial, h_space_energy))
#     ht1 = HarmonicTransformOperator(h_space, space=0)
#     ht2 = HarmonicTransformOperator(ht1.target, space=1)
Martin Reinecke's avatar
Martin Reinecke committed
62
#     ht = ht2(ht1)
63
#
Martin Reinecke's avatar
Martin Reinecke committed
64 65
#     p_space_spatial = amplitude_model_spatial.target[0]
#     p_space_energy = amplitude_model_energy.target[0]
66 67 68
#
#     pd_spatial = PowerDistributor(h_space, p_space_spatial, 0)
#     pd_energy = PowerDistributor(pd_spatial.domain, p_space_energy, 1)
Martin Reinecke's avatar
Martin Reinecke committed
69
#     pd = pd_spatial(pd_energy)
70 71 72 73 74 75 76 77 78
#
#     dom_distr_spatial = DomainDistributor(pd.domain, 0)
#     dom_distr_energy = DomainDistributor(pd.domain, 1)
#
#     a_spatial = dom_distr_spatial(amplitude_model_spatial)
#     a_energy = dom_distr_energy(amplitude_model_energy)
#     a = a_spatial*a_energy
#     A = pd(a)
#
Martin Reinecke's avatar
Martin Reinecke committed
79 80 81 82
#     domain = MultiDomain.union(
#         (amplitude_model_spatial.domain, amplitude_model_energy.domain,
#          MultiDomain.make({"xi": h_space})))
#     return exp(ht(A*FieldAdapter(domain, "xi")))