Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
25376437
Commit
25376437
authored
Feb 23, 2018
by
Martin Reinecke
Browse files
more docs
parent
db0bba33
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty4/field.py
View file @
25376437
...
@@ -558,9 +558,40 @@ class Field(object):
...
@@ -558,9 +558,40 @@ class Field(object):
return
Field
(
domain
=
return_domain
,
val
=
data
,
copy
=
False
)
return
Field
(
domain
=
return_domain
,
val
=
data
,
copy
=
False
)
def
sum
(
self
,
spaces
=
None
):
def
sum
(
self
,
spaces
=
None
):
"""Sums up over the sub-domains given by `spaces`.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The summation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the summation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
return
self
.
_contraction_helper
(
'sum'
,
spaces
)
return
self
.
_contraction_helper
(
'sum'
,
spaces
)
def
integrate
(
self
,
spaces
=
None
):
def
integrate
(
self
,
spaces
=
None
):
"""Integrates over the sub-domains given by `spaces`.
Integration is performed by summing over `self` multiplied by its
volume factors.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The summation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the integration. If it is carried out over the
entire domain, this is a scalar, otherwise a Field.
"""
swgt
=
self
.
scalar_weight
(
spaces
)
swgt
=
self
.
scalar_weight
(
spaces
)
if
swgt
is
not
None
:
if
swgt
is
not
None
:
res
=
self
.
sum
(
spaces
)
res
=
self
.
sum
(
spaces
)
...
@@ -570,6 +601,20 @@ class Field(object):
...
@@ -570,6 +601,20 @@ class Field(object):
return
tmp
.
sum
(
spaces
)
return
tmp
.
sum
(
spaces
)
def
prod
(
self
,
spaces
=
None
):
def
prod
(
self
,
spaces
=
None
):
"""Computes the product over the sub-domains given by `spaces`.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the product. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
return
self
.
_contraction_helper
(
'prod'
,
spaces
)
return
self
.
_contraction_helper
(
'prod'
,
spaces
)
def
all
(
self
,
spaces
=
None
):
def
all
(
self
,
spaces
=
None
):
...
@@ -579,12 +624,57 @@ class Field(object):
...
@@ -579,12 +624,57 @@ class Field(object):
return
self
.
_contraction_helper
(
'any'
,
spaces
)
return
self
.
_contraction_helper
(
'any'
,
spaces
)
def
min
(
self
,
spaces
=
None
):
def
min
(
self
,
spaces
=
None
):
"""Determines the minimum over the sub-domains given by `spaces`.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
return
self
.
_contraction_helper
(
'min'
,
spaces
)
return
self
.
_contraction_helper
(
'min'
,
spaces
)
def
max
(
self
,
spaces
=
None
):
def
max
(
self
,
spaces
=
None
):
"""Determines the maximum over the sub-domains given by `spaces`.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
return
self
.
_contraction_helper
(
'max'
,
spaces
)
return
self
.
_contraction_helper
(
'max'
,
spaces
)
def
mean
(
self
,
spaces
=
None
):
def
mean
(
self
,
spaces
=
None
):
"""Determines the mean over the sub-domains given by `spaces`.
``x.mean(spaces)`` is equivalent to
``x.integrate(spaces)/x.total_volume(spaces)``.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
return
self
.
_contraction_helper
(
'mean'
,
spaces
)
return
self
.
_contraction_helper
(
'mean'
,
spaces
)
# MR FIXME: not very efficient
# MR FIXME: not very efficient
...
@@ -592,6 +682,20 @@ class Field(object):
...
@@ -592,6 +682,20 @@ class Field(object):
return
tmp
.
sum
(
spaces
)
*
(
1.
/
tmp
.
total_volume
(
spaces
))
return
tmp
.
sum
(
spaces
)
*
(
1.
/
tmp
.
total_volume
(
spaces
))
def
var
(
self
,
spaces
=
None
):
def
var
(
self
,
spaces
=
None
):
"""Determines the variance over the sub-domains given by `spaces`.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
return
self
.
_contraction_helper
(
'var'
,
spaces
)
return
self
.
_contraction_helper
(
'var'
,
spaces
)
# MR FIXME: not very efficient or accurate
# MR FIXME: not very efficient or accurate
...
@@ -605,6 +709,23 @@ class Field(object):
...
@@ -605,6 +709,23 @@ class Field(object):
return
sq
.
mean
(
spaces
)
-
m1
return
sq
.
mean
(
spaces
)
-
m1
def
std
(
self
,
spaces
=
None
):
def
std
(
self
,
spaces
=
None
):
"""Determines the standard deviation over the sub-domains given by
`spaces`.
``x.std(spaces)`` is equivalent to ``sqrt(x.var(spaces))``.
Parameters
----------
spaces : None, int or tuple of int (default: None)
The operation is only carried out over the sub-domains in this
tuple. If None, it is carried out over all sub-domains.
Returns
-------
Field or scalar
The result of the operation. If it is carried out over the entire
domain, this is a scalar, otherwise a Field.
"""
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
if
self
.
scalar_weight
(
spaces
)
is
not
None
:
return
self
.
_contraction_helper
(
'std'
,
spaces
)
return
self
.
_contraction_helper
(
'std'
,
spaces
)
return
sqrt
(
self
.
var
(
spaces
))
return
sqrt
(
self
.
var
(
spaces
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment