Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teresa Weßels
empyre
Commits
5add0064
Commit
5add0064
authored
5 years ago
by
Jan Caron
Browse files
Options
Downloads
Patches
Plain Diff
Fixed Field.clip()
parent
b269505c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/empyre/fields/field.py
+3
-4
3 additions, 4 deletions
src/empyre/fields/field.py
with
3 additions
and
4 deletions
src/empyre/fields/field.py
+
3
−
4
View file @
5add0064
...
...
@@ -475,7 +475,7 @@ class Field(NDArrayOperatorsMixin):
raise
AssertionError
(
'
Can only handle 3D or 2D cases (see documentation for specifics)!
'
)
def
clip
(
self
,
vmin
=
None
,
vmax
=
None
,
sigma
=
None
,
mask
=
None
):
"""
Clip (limit) the values in an array. For vector fields, this will take the amplitude into account
"""
Clip (limit) the values in an array. For vector fields, this will take the amplitude into account
.
Parameters
----------
...
...
@@ -517,9 +517,8 @@ class Field(NDArrayOperatorsMixin):
if
vmax
is
None
:
vmax
=
np
.
nanmax
(
amp_masked
)
if
self
.
vector
:
# Vector fields need to scale components according to masked amplitude
mask_vec
=
np
.
logical_and
(
mask
,
amp
<=
vmax
)
# Only vmax is important!
data
=
amp
/
np
.
where
(
mask_vec
,
1
,
amp
)
# TODO: needs testing!
# TODO: Test np.clip(field) (also ufunc?? think not...) seems to work, but what about others?
mask_vec
=
(
amp
<=
vmax
)[...,
None
]
# Only vmax is important for vectors! mask_vec broadcast to components!
data
=
np
.
where
(
mask_vec
,
self
.
data
,
vmax
*
self
.
data
/
amp
[...,
None
])
# Scale outliers to vmax!
else
:
# For scalar fields, just delegate to the numpy function:
data
=
np
.
clip
(
self
.
data
,
vmin
,
vmax
)
return
Field
(
data
,
self
.
scale
,
self
.
vector
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment