Commit d4d18b1c authored by M Selig's avatar M Selig
Browse files

Merge pull request #8 from mselig/develop

version update to 0.7.0
parents 87d151ee 6ef6ce0c
......@@ -17,4 +17,5 @@ demos/*
!demos/demo_faraday_map.npy
!demos/demo_excaliwir.py
!demos/demo_wf1.py
!demos/demo_wf2.py
\ No newline at end of file
!demos/demo_wf2.py
!demos/demo_wf3.py
\ No newline at end of file
......@@ -64,6 +64,8 @@ apply to fields.
* ``response_operator`` - exemplary responses that include a convolution,
masking and projection
* ``propagator_operator`` - information propagator in Wiener filter theory
* ``explicit_operator`` - linear operators with an explicit matrix
representation
* (and more)
* (and more)
......@@ -97,7 +99,7 @@ Requirements
Download
........
The latest release is tagged **v0.6.0** and is available as a source package
The latest release is tagged **v0.7.0** and is available as a source package
at `<https://github.com/mselig/nifty/tags>`_. The current version can be
obtained by cloning the repository::
......@@ -140,5 +142,7 @@ The NIFTY package is licensed under the
`GPLv3 <http://www.gnu.org/licenses/gpl.html>`_ and is distributed *without any
warranty*.
----
**NIFTY** project homepage: `<http://www.mpa-garching.mpg.de/ift/nifty/>`_
......@@ -24,6 +24,7 @@ from nifty_core import *
from nifty_cmaps import *
from nifty_power import *
from nifty_tools import *
from nifty_explicit import *
......
## NIFTY (Numerical Information Field Theory) has been developed at the
## Max-Planck-Institute for Astrophysics.
##
## Copyright (C) 2013 Max-Planck-Society
##
## Author: Marco Selig
## Project homepage: <http://www.mpa-garching.mpg.de/ift/nifty/>
##
## 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/>.
"""
.. __ ____ __
.. /__/ / _/ / /_
.. __ ___ __ / /_ / _/ __ __
.. / _ | / / / _/ / / / / / /
.. / / / / / / / / / /_ / /_/ /
.. /__/ /__/ /__/ /__/ \___/ \___ / demo
.. /______/
NIFTY demo applying a Wiener filter using explicit matrices.
"""
from __future__ import division
from nifty import * # version 0.7.0
from nifty.nifty_explicit import *
# some signal space; e.g., a one-dimensional regular grid
x_space = rg_space(128) # define signal space
k_space = x_space.get_codomain() # get conjugate space
# some power spectrum
power = (lambda k: 42 / (k + 1) ** 3)
S = power_operator(k_space, spec=power) # define signal covariance
s = S.get_random_field(domain=x_space) # generate signal
s -= s.val.mean()
R = response_operator(x_space, sigma=0.0, mask=1.0, assign=None) # define response
d_space = R.target # get data space
# some noise variance
delta = 1000 * (np.arange(1, x_space.dim() + 1) / x_space.dim()) ** 5
N = diagonal_operator(d_space, diag=delta, bare=True) # define noise covariance
n = N.get_random_field(domain=d_space) # generate noise
d = R(s) + n # compute data
j = R.adjoint_times(N.inverse_times(d)) # define information source
class M_operator(operator):
def _multiply(self, x):
N, R = self.para
return R.adjoint_times(N.inverse_times(R.times(x)))
C = explicify(S, newdomain=x_space, newtarget=x_space) # explicify S
M = M_operator(x_space, sym=True, uni=False, imp=True, para=(N, R))
M = explicify(M) # explicify M
D = (C.inverse() + M).inverse() # define information propagator
m = D(j) # reconstruct map
vminmax = {"vmin":1.5 * s.val.min(), "vmax":1.5 * s.val.max()}
s.plot(title="signal", **vminmax) # plot signal
d_ = field(x_space, val=d.val, target=k_space)
d_.plot(title="data", **vminmax) # plot data
m.plot(title="reconstructed map", error=D.diag(bare=True), **vminmax) # plot map
D.plot(title="information propagator", bare=True) # plot information propagator
......@@ -486,7 +486,7 @@ class _about(object): ## nifty support class for global settings
"""
## version
self._version = "0.6.0"
self._version = "0.7.0"
## switches and notifications
self._errors = notification(default=True,ccode=notification._code)
......@@ -774,7 +774,7 @@ class random(object):
"""
size = np.prod(shape,axis=0,dtype=np.int,out=None)
if(datatype in [np.complex64,np.complex128]):
if(issubclass(datatype,np.complexfloating)):
x = np.array([1+0j,0+1j,-1+0j,0-1j],dtype=datatype)[np.random.randint(4,high=None,size=size)]
else:
x = 2*np.random.randint(2,high=None,size=size)-1
......@@ -816,7 +816,7 @@ class random(object):
"""
size = np.prod(shape,axis=0,dtype=np.int,out=None)
if(datatype in [np.complex64,np.complex128]):
if(issubclass(datatype,np.complexfloating)):
x = np.empty(size,dtype=datatype,order='C')
x.real = np.random.normal(loc=0,scale=np.sqrt(0.5),size=size)
x.imag = np.random.normal(loc=0,scale=np.sqrt(0.5),size=size)
......@@ -893,7 +893,7 @@ class random(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.random>"
return "<nifty_core.random>"
##-----------------------------------------------------------------------------
......@@ -1693,10 +1693,10 @@ class space(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.space>"
return "<nifty_core.space>"
def __str__(self):
return "nifty.space instance\n- para = "+str(self.para)+"\n- datatype = numpy."+str(np.result_type(self.datatype))
return "nifty_core.space instance\n- para = "+str(self.para)+"\n- datatype = numpy."+str(np.result_type(self.datatype))
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......@@ -1941,7 +1941,7 @@ class point_space(space):
Number of degrees of freedom of the space.
"""
## dof ~ dim
if(self.datatype in [np.complex64,np.complex128]):
if(issubclass(self.datatype,np.complexfloating)):
return 2*self.para[0]
else:
return self.para[0]
......@@ -2142,10 +2142,10 @@ class point_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.point_space>"
return "<nifty_core.point_space>"
def __str__(self):
return "nifty.point_space instance\n- num = "+str(self.para[0])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
return "nifty_core.point_space instance\n- num = "+str(self.para[0])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
##-----------------------------------------------------------------------------
......@@ -3279,12 +3279,18 @@ class rg_space(space):
elif(naxes==2):
if(np.iscomplexobj(x)):
about.infos.cprint("INFO: absolute values, real and imaginary part plotted.")
about.infos.cprint("INFO: absolute values and phases are plotted.")
if(title):
title += " "
self.get_plot(np.absolute(x),title=title+"(absolute)",vmin=vmin,vmax=vmax,power=False,unit=unit,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
self.get_plot(np.real(x),title=title+"(real part)",vmin=vmin,vmax=vmax,power=False,unit=unit,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
self.get_plot(np.imag(x),title=title+"(imaginary part)",vmin=vmin,vmax=vmax,power=False,unit=unit,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
# self.get_plot(np.real(x),title=title+"(real part)",vmin=vmin,vmax=vmax,power=False,unit=unit,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
# self.get_plot(np.imag(x),title=title+"(imaginary part)",vmin=vmin,vmax=vmax,power=False,unit=unit,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
if(unit):
unit = "rad"
if(cmap is None):
cmap = pl.cm.hsv_r
self.get_plot(np.angle(x,deg=False),title=title+"(phase)",vmin=-3.1416,vmax=3.1416,power=False,unit=unit,norm=None,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs) ## values in [-pi,pi]
return None ## leave method
else:
if(vmin is None):
vmin = np.min(x,axis=None,out=None)
......@@ -3334,14 +3340,14 @@ class rg_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.rg_space>"
return "<nifty_core.rg_space>"
def __str__(self):
naxes = (np.size(self.para)-1)//2
num = self.para[:naxes][::-1].tolist()
zerocenter = self.para[-naxes:][::-1].astype(np.bool).tolist()
dist = self.vol[::-1].tolist()
return "nifty.rg_space instance\n- num = "+str(num)+"\n- naxes = "+str(naxes)+"\n- hermitian = "+str(bool(self.para[naxes]<2))+"\n- purelyreal = "+str(bool(not self.para[naxes]))+"\n- zerocenter = "+str(zerocenter)+"\n- dist = "+str(dist)+"\n- fourier = "+str(self.fourier)
return "nifty_core.rg_space instance\n- num = "+str(num)+"\n- naxes = "+str(naxes)+"\n- hermitian = "+str(bool(self.para[naxes]<2))+"\n- purelyreal = "+str(bool(not self.para[naxes]))+"\n- zerocenter = "+str(zerocenter)+"\n- dist = "+str(dist)+"\n- fourier = "+str(self.fourier)
##-----------------------------------------------------------------------------
......@@ -4122,9 +4128,9 @@ class lm_space(space):
ax0.legend()
ax0.set_xlim(xaxes[1],xaxes[-1])
ax0.set_xlabel(r"$l$")
ax0.set_xlabel(r"$\ell$")
ax0.set_ylim(vmin,vmax)
ax0.set_ylabel(r"$l(2l+1) C_l$")
ax0.set_ylabel(r"$\ell(2\ell+1) C_\ell$")
ax0.set_title(title)
else:
......@@ -4133,8 +4139,12 @@ class lm_space(space):
if(title):
title += " "
self.get_plot(np.absolute(x),title=title+"(absolute)",vmin=vmin,vmax=vmax,power=False,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
self.get_plot(np.real(x),title=title+"(real part)",vmin=vmin,vmax=vmax,power=False,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
self.get_plot(np.imag(x),title=title+"(imaginary part)",vmin=vmin,vmax=vmax,power=False,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
# self.get_plot(np.real(x),title=title+"(real part)",vmin=vmin,vmax=vmax,power=False,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
# self.get_plot(np.imag(x),title=title+"(imaginary part)",vmin=vmin,vmax=vmax,power=False,norm=norm,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs)
if(cmap is None):
cmap = pl.cm.hsv_r
self.get_plot(np.angle(x,deg=False),title=title+"(phase)",vmin=-3.1416,vmax=3.1416,power=False,norm=None,cmap=cmap,cbar=cbar,other=None,legend=False,**kwargs) ## values in [-pi,pi]
return None ## leave method
else:
if(vmin is None):
vmin = np.min(x,axis=None,out=None)
......@@ -4165,7 +4175,7 @@ class lm_space(space):
sub = ax0.pcolormesh(xaxes,yaxes,np.ma.masked_where(np.isnan(xmesh),xmesh),cmap=cmap,norm=n_,vmin=vmin,vmax=vmax,clim=(vmin,vmax))
ax0.set_xlim(xaxes[0],xaxes[-1])
ax0.set_xticks([0],minor=False)
ax0.set_xlabel(r"$l$")
ax0.set_xlabel(r"$\ell$")
ax0.set_ylim(yaxes[0],yaxes[-1])
ax0.set_yticks([0],minor=False)
ax0.set_ylabel(r"$m$")
......@@ -4191,10 +4201,10 @@ class lm_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.lm_space>"
return "<nifty_core.lm_space>"
def __str__(self):
return "nifty.lm_space instance\n- lmax = "+str(self.para[0])+"\n- mmax = "+str(self.para[1])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
return "nifty_core.lm_space instance\n- lmax = "+str(self.para[0])+"\n- mmax = "+str(self.para[1])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
##-----------------------------------------------------------------------------
......@@ -4862,10 +4872,10 @@ class gl_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.gl_space>"
return "<nifty_core.gl_space>"
def __str__(self):
return "nifty.gl_space instance\n- nlat = "+str(self.para[0])+"\n- nlon = "+str(self.para[1])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
return "nifty_core.gl_space instance\n- nlat = "+str(self.para[0])+"\n- nlon = "+str(self.para[1])+"\n- datatype = numpy."+str(np.result_type(self.datatype))
##-----------------------------------------------------------------------------
......@@ -5460,10 +5470,10 @@ class hp_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.hp_space>"
return "<nifty_core.hp_space>"
def __str__(self):
return "nifty.hp_space instance\n- nside = "+str(self.para[0])
return "nifty_core.hp_space instance\n- nside = "+str(self.para[0])
##-----------------------------------------------------------------------------
......@@ -6150,10 +6160,10 @@ class nested_space(space):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.nested_space>"
return "<nifty_core.nested_space>"
def __str__(self):
return "nifty.nested_space instance\n- nest = "+str(self.nest)
return "nifty_core.nested_space instance\n- nest = "+str(self.nest)
##-----------------------------------------------------------------------------
......@@ -6375,7 +6385,10 @@ class field(object):
New field values either as a constant or an arbitrary array.
"""
self.val = self.domain.enforce_values(newval,extend=True)
if(newval is None):
self.val = np.zeros(self.dim(split=True),dtype=self.domain.datatype,order='C')
else:
self.val = self.domain.enforce_values(newval,extend=True)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......@@ -6840,12 +6853,12 @@ class field(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.field>"
return "<nifty_core.field>"
def __str__(self):
minmax = [np.min(self.val,axis=None,out=None),np.max(self.val,axis=None,out=None)]
medmean = [np.median(self.val,axis=None,out=None,overwrite_input=False),np.mean(self.val,axis=None,dtype=self.domain.datatype,out=None)]
return "nifty.field instance\n- domain = "+repr(self.domain)+"\n- val = [...]"+"\n - min.,max. = "+str(minmax)+"\n - med.,mean = "+str(medmean)+"\n- target = "+repr(self.target)
return "nifty_core.field instance\n- domain = "+repr(self.domain)+"\n- val = [...]"+"\n - min.,max. = "+str(minmax)+"\n - med.,mean = "+str(medmean)+"\n- target = "+repr(self.target)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......@@ -7517,6 +7530,7 @@ def exp(x):
array([ 2.20264658e+04, 2.68811714e+43])
>>> exp(field(point_space(2), val=[10, 100])).val
array([ 2.20264658e+04, 2.68811714e+43])
"""
if(isinstance(x,field)):
return field(x.domain,val=np.exp(x.val),target=x.target)
......@@ -7698,17 +7712,17 @@ class operator(object):
self.sym = bool(sym)
self.uni = bool(uni)
if(self.domain.discrete):
self.imp = True
else:
self.imp = bool(imp)
if(target is None)or(self.sym)or(self.uni):
target = self.domain
if(not isinstance(target,space)):
elif(not isinstance(target,space)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
self.target = target
if(self.domain.discrete)and(self.target.discrete):
self.imp = True
else:
self.imp = bool(imp)
if(para is not None):
self.para = para
......@@ -7731,7 +7745,7 @@ class operator(object):
Returns
-------
nrow : int
ncol : int
number of columns (equal to the dimension of the domain)
"""
return self.domain.dim(split=False)
......@@ -7919,7 +7933,6 @@ class operator(object):
## evaluate
return self._debriefing(x,x_,self.domain,True)
def adjoint_inverse_times(self,x,**kwargs):
"""
Applies the inverse adjoint operator to a given object.
......@@ -8026,7 +8039,7 @@ class operator(object):
"""
if(domain is None):
domain = self.domain
return trace_probing(self,function=self.times,domain=domain,target=target,random=random,ncpu=ncpu,nrun=nrun,nper=nper,var=var,**kwargs)(loop=loop)
return trace_probing(self,function=self.times,domain=domain,target=target,random=random,ncpu=(ncpu,1)[bool(loop)],nrun=nrun,nper=nper,var=var,**kwargs)(loop=loop)
def inverse_tr(self,domain=None,target=None,random="pm1",ncpu=2,nrun=8,nper=1,var=False,loop=False,**kwargs):
"""
......@@ -8072,7 +8085,7 @@ class operator(object):
"""
if(domain is None):
domain = self.target
return trace_probing(self,function=self.inverse_times,domain=domain,target=target,random=random,ncpu=ncpu,nrun=nrun,nper=nper,var=var,**kwargs)(loop=loop)
return trace_probing(self,function=self.inverse_times,domain=domain,target=target,random=random,ncpu=(ncpu,1)[bool(loop)],nrun=nrun,nper=nper,var=var,**kwargs)(loop=loop)
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......@@ -8143,7 +8156,7 @@ class operator(object):
"""
if(domain is None):
domain = self.domain
diag = diagonal_probing(self,function=self.times,domain=domain,target=target,random=random,ncpu=ncpu,nrun=nrun,nper=nper,var=var,save=save,path=path,prefix=prefix,**kwargs)(loop=loop)
diag = diagonal_probing(self,function=self.times,domain=domain,target=target,random=random,ncpu=(ncpu,1)[bool(loop)],nrun=nrun,nper=nper,var=var,save=save,path=path,prefix=prefix,**kwargs)(loop=loop)
if(diag is None):
# about.warnings.cprint("WARNING: forwarding 'NoneType'.")
return None
......@@ -8223,7 +8236,7 @@ class operator(object):
"""
if(domain is None):
domain = self.target
diag = diagonal_probing(self,function=self.inverse_times,domain=domain,target=target,random=random,ncpu=ncpu,nrun=nrun,nper=nper,var=var,save=save,path=path,prefix=prefix,**kwargs)(loop=loop)
diag = diagonal_probing(self,function=self.inverse_times,domain=domain,target=target,random=random,ncpu=(ncpu,1)[bool(loop)],nrun=nrun,nper=nper,var=var,save=save,path=path,prefix=prefix,**kwargs)(loop=loop)
if(diag is None):
# about.warnings.cprint("WARNING: forwarding 'NoneType'.")
return None
......@@ -8528,7 +8541,7 @@ class operator(object):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.operator>"
return "<nifty_core.operator>"
##=============================================================================
......@@ -8574,6 +8587,10 @@ class diagonal_operator(operator):
bare entries that allow for correct interpretation of the matrix
entries; e.g., as variance in case of an covariance operator.
The inverse applications of the diagonal operator feature a ``pseudo``
flag indicating if zero divison shall be ignored and return zero
instead of causing an error.
Attributes
----------
domain : space
......@@ -8707,25 +8724,41 @@ class diagonal_operator(operator):
x_.val = x.val*np.conjugate(self.val) ## bypasses self.domain.enforce_values
return x_
def _inverse_multiply(self,x,**kwargs): ## > applies the inverse operator to a given field
def _inverse_multiply(self,x,pseudo=False,**kwargs): ## > applies the inverse operator to a given field
if(np.any(self.val==0)):
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
if(pseudo):
x_ = field(self.domain,val=None,target=x.target)
x_.val = x.val*np.where(self.val==0,0,1/self.val) ## bypasses self.domain.enforce_values
return x_
else:
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
else:
x_ = field(self.domain,val=None,target=x.target)
x_.val = x.val/self.val ## bypasses self.domain.enforce_values
return x_
def _adjoint_inverse_multiply(self,x,**kwargs): ## > applies the inverse adjoint operator to a given field
def _adjoint_inverse_multiply(self,x,pseudo=False,**kwargs): ## > applies the inverse adjoint operator to a given field
if(np.any(self.val==0)):
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
if(pseudo):
x_ = field(self.domain,val=None,target=x.target)
x_.val = x.val*np.where(self.val==0,0,1/np.conjugate(self.val)) ## bypasses self.domain.enforce_values
return x_
else:
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
else:
x_ = field(self.target,val=None,target=x.target)
x_.val = x.val/np.conjugate(self.val) ## bypasses self.domain.enforce_values
return x_
def _inverse_adjoint_multiply(self,x,**kwargs): ## > applies the adjoint inverse operator to a given field
def _inverse_adjoint_multiply(self,x,pseudo=False,**kwargs): ## > applies the adjoint inverse operator to a given field
if(np.any(self.val==0)):
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
if(pseudo):
x_ = field(self.domain,val=None,target=x.target)
x_.val = x.val*np.where(self.val==0,0,np.conjugate(1/self.val)) ## bypasses self.domain.enforce_values
return x_
else:
raise AttributeError(about._errors.cstring("ERROR: singular operator."))
else:
x_ = field(self.target,val=None,target=x.target)
x_.val = x.val*np.conjugate(1/self.val) ## bypasses self.domain.enforce_values
......@@ -9024,6 +9057,43 @@ class diagonal_operator(operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def det(self):
"""
Computes the determinant of the matrix.
Returns
-------
det : float
The determinant
"""
if(self.uni): ## identity
return 1
elif(self.domain.dim(split=False)<self.domain.dof()): ## hidden degrees of freedom
return np.exp(self.domain.calc_dot(np.ones(self.domain.dim(split=True),dtype=self.domain.datatype,order='C'),np.log(self.val)))
else:
return np.prod(self.val,axis=None,dtype=None,out=None)
def inverse_det(self):
"""
Computes the determinant of the inverse operator.
Returns
-------
det : float
The determinant
"""
if(self.uni): ## identity
return 1
det = self.det()
if(det<>0):
return 1/det
else:
raise ValueError(about._errors.cstring("ERROR: singular operator."))
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def get_random_field(self,domain=None,target=None,**kwargs):
"""
Generates a Gaussian random field with variance equal to the
......@@ -9063,7 +9133,7 @@ class diagonal_operator(operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.diagonal_operator>"
return "<nifty_core.diagonal_operator>"
##-----------------------------------------------------------------------------
......@@ -9481,7 +9551,7 @@ class power_operator(diagonal_operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.power_operator>"
return "<nifty_core.power_operator>"
##-----------------------------------------------------------------------------
......@@ -9528,6 +9598,12 @@ class projection_operator(operator):
Lower limit of the uniform distribution if ``random == "uni"``
(default: 0).
Notes
-----
The application of the projection operator features a ``band`` keyword
specifying a single projection band (see examples) and a ``bandsup``
keyword specifying which projection bands to sum up.
Examples
--------
>>> space = point_space(3)
......@@ -9820,7 +9896,7 @@ class projection_operator(operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.projection_operator>"
return "<nifty_core.projection_operator>"
##-----------------------------------------------------------------------------
......@@ -10080,7 +10156,7 @@ class vecvec_operator(operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def __repr__(self):
return "<nifty.vecvec_operator>"
return "<nifty_core.vecvec_operator>"
##-----------------------------------------------------------------------------
......@@ -10276,36 +10352,24 @@ class response_operator(operator):
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def _multiply(self,x,**kwargs): ## > applies the operator to a given field
# ## weight ## TODO: remove in future version
# if(self.domain.discrete)and(self.den):
# x_ = self.domain.calc_weight(x.val,power=1)
# elif(not self.domain.discrete)and(not self.den):
# x_ = self.domain.calc_weight(x.val,power=-1)
# else:
# x_ = x.val
# ## smooth
# x_ = self.domain.calc_smooth(x_.val,sigma=self.sigma)
## smooth
x_ = self.domain.calc_smooth(x.val,sigma=self.sigma)
## mask
x_ = self.mask*x_
x_ *= self.mask
## assign
return x_[self.assign.tolist()]
#return x_[self.assign.tolist()]