Commit 2580647e authored by Reimar Leike's avatar Reimar Leike

added documentation to create_power_operator and...

added documentation to create_power_operator and Field::synthesize/analyze_power clarifuiying when a square root is used for the Power spectrum. Also fixed some typos. See Issue #128
parent fa229f6c
Pipeline #12776 failed with stage
in 4 minutes and 5 seconds
...@@ -218,7 +218,7 @@ class Field(Loggable, Versionable, object): ...@@ -218,7 +218,7 @@ class Field(Loggable, Versionable, object):
See Also See Also
-------- --------
power_synthesise power_synthesize
""" """
...@@ -270,12 +270,13 @@ class Field(Loggable, Versionable, object): ...@@ -270,12 +270,13 @@ class Field(Loggable, Versionable, object):
def power_analyze(self, spaces=None, logarithmic=False, nbin=None, def power_analyze(self, spaces=None, logarithmic=False, nbin=None,
binbounds=None, decompose_power=True): binbounds=None, decompose_power=True):
""" Computes the powerspectrum for a subspace of the Field. """ Computes the square root power spectrum for a subspace of the Field.
Creates a PowerSpace for the space addressed by `spaces` with the given Creates a PowerSpace for the space addressed by `spaces` with the given
binning and computes the power spectrum as a Field over this binning and computes the power spectrum as a Field over this
PowerSpace. This can only be done if the subspace to be analyzed is a PowerSpace. This can only be done if the subspace to be analyzed is a
harmonic space. harmonic space. The resulting field has the same units as the initial
field, corresponding to the square root of the power spectrum.
Parameters Parameters
---------- ----------
...@@ -456,14 +457,16 @@ class Field(Loggable, Versionable, object): ...@@ -456,14 +457,16 @@ class Field(Loggable, Versionable, object):
def power_synthesize(self, spaces=None, real_power=True, real_signal=True, def power_synthesize(self, spaces=None, real_power=True, real_signal=True,
mean=None, std=None): mean=None, std=None):
""" Converts a power spectrum into a random field realization. """Yields a sampled field with this field squared as its power spectrum.
This method draws a Gaussian random field in the harmic partner domain This method draws a Gaussian random field in the harmonic partner domain
of a PowerSpace. of this fields domains, using this field as power spectrum.
Notes Notes
----- -----
For this the spaces specified by `spaces` must be a PowerSpaces. For this the spaces specified by `spaces` must be a PowerSpace.
This expects this field to be the square root of a power spectrum, i.e.
to have the unit of the field to be sampled.
Parameters Parameters
---------- ----------
...@@ -484,7 +487,6 @@ class Field(Loggable, Versionable, object): ...@@ -484,7 +487,6 @@ class Field(Loggable, Versionable, object):
std : float *optional* std : float *optional*
The standard deviation of the Gaussian noise field which is used The standard deviation of the Gaussian noise field which is used
for the Field synthetization (default : None). for the Field synthetization (default : None).
{default : None}
if std==None : std will be set to 1 if std==None : std will be set to 1
Returns Returns
...@@ -496,7 +498,9 @@ class Field(Loggable, Versionable, object): ...@@ -496,7 +498,9 @@ class Field(Loggable, Versionable, object):
See Also See Also
-------- --------
power_analyze power_analyze
Raises
------
ValueError : If domain is not a PowerSpace
""" """
# check if the `spaces` input is valid # check if the `spaces` input is valid
......
...@@ -26,6 +26,30 @@ __all__ = ['create_power_operator'] ...@@ -26,6 +26,30 @@ __all__ = ['create_power_operator']
def create_power_operator(domain, power_spectrum, dtype=None, def create_power_operator(domain, power_spectrum, dtype=None,
distribution_strategy='not'): distribution_strategy='not'):
"""Creates a diagonal operator with a certain power spectrum.
Constructs a diagonal operator that lives over the specified domain, or
its harmonic domain in case it is not harmonic.
Parameters
----------
domain : DomainObject
Domain over which the power operator shall live. If this is not a
harmonic domain, it will return an operator for its harmonic domain
instead.
power_spectrum : {array-like, method}
An array-like object, or a method that implements the square root
of a power spectrum as a function of k.
dtype : type, *optional*
dtype that the field holding the power spectrum shall use
{default : None}
if dtype == None: passes this on to constructor of Field
distribution_strategy : string, *optional*
Distributed strategy to be used by the underlying d2o objects.
{default : 'not'}
Returns
-------
DiagonalOperator : An operator that lives that implements the given power
spectrum.
"""
if not domain.harmonic: if not domain.harmonic:
fft = FFTOperator(domain) fft = FFTOperator(domain)
domain = fft.target[0] domain = fft.target[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment