Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
25376437
Commit
25376437
authored
Feb 23, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more docs
parent
db0bba33
Changes
1
Hide whitespace changes
Inline
Sidebyside
Showing
1 changed file
with
121 additions
and
0 deletions
+121
0
nifty4/field.py
nifty4/field.py
+121
0
No files found.
nifty4/field.py
View file @
25376437
...
...
@@ 558,9 +558,40 @@ class Field(object):
return
Field
(
domain
=
return_domain
,
val
=
data
,
copy
=
False
)
def
sum
(
self
,
spaces
=
None
):
"""Sums up over the subdomains given by `spaces`.
Parameters

spaces : None, int or tuple of int (default: None)
The summation is only carried out over the subdomains in this
tuple. If None, it is carried out over all subdomains.
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
)
def
integrate
(
self
,
spaces
=
None
):
"""Integrates over the subdomains 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 subdomains in this
tuple. If None, it is carried out over all subdomains.
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
)
if
swgt
is
not
None
:
res
=
self
.
sum
(
spaces
)
...
...
@@ 570,6 +601,20 @@ class Field(object):
return
tmp
.
sum
(
spaces
)
def
prod
(
self
,
spaces
=
None
):
"""Computes the product over the subdomains given by `spaces`.
Parameters

spaces : None, int or tuple of int (default: None)
The operation is only carried out over the subdomains in this
tuple. If None, it is carried out over all subdomains.
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
)
def
all
(
self
,
spaces
=
None
):
...
...
@@ 579,12 +624,57 @@ class Field(object):
return
self
.
_contraction_helper
(
'any'
,
spaces
)
def
min
(
self
,
spaces
=
None
):
"""Determines the minimum over the subdomains given by `spaces`.
Parameters

spaces : None, int or tuple of int (default: None)
The operation is only carried out over the subdomains in this
tuple. If None, it is carried out over all subdomains.
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
)
def
max
(
self
,
spaces
=
None
):
"""Determines the maximum over the subdomains given by `spaces`.
Parameters

spaces : None, int or tuple of int (default: None)
The operation is only carried out over the subdomains in this
tuple. If None, it is carried out over all subdomains.
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
)
def
mean
(
self
,
spaces
=
None
):
"""Determines the mean over the subdomains 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 subdomains in this
tuple. If None, it is carried out over all subdomains.
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
:
return
self
.
_contraction_helper
(
'mean'
,
spaces
)
# MR FIXME: not very efficient
...
...
@@ 592,6 +682,20 @@ class Field(object):
return
tmp
.
sum
(
spaces
)
*
(
1.
/
tmp
.
total_volume
(
spaces
))
def
var
(
self
,
spaces
=
None
):
"""Determines the variance over the subdomains given by `spaces`.
Parameters

spaces : None, int or tuple of int (default: None)
The operation is only carried out over the subdomains in this
tuple. If None, it is carried out over all subdomains.
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
:
return
self
.
_contraction_helper
(
'var'
,
spaces
)
# MR FIXME: not very efficient or accurate
...
...
@@ 605,6 +709,23 @@ class Field(object):
return
sq
.
mean
(
spaces
)

m1
def
std
(
self
,
spaces
=
None
):
"""Determines the standard deviation over the subdomains 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 subdomains in this
tuple. If None, it is carried out over all subdomains.
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
:
return
self
.
_contraction_helper
(
'std'
,
spaces
)
return
sqrt
(
self
.
var
(
spaces
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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