Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsData
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
MetObsData
Commits
55e8b73a
Commit
55e8b73a
authored
15 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
half way there
parent
0650fd88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
metobs/data/filter.py
+30
-0
30 additions, 0 deletions
metobs/data/filter.py
with
30 additions
and
0 deletions
metobs/data/filter.py
0 → 100644
+
30
−
0
View file @
55e8b73a
"""
Array filtering functions
"""
from
numpy
import
ndarray
,
array
,
diff
from
numpy.ma
import
MaskedArray
,
masked_array
__docformat__
=
'
Epytext
'
__author__
=
'
David Hoese
'
__version__
=
'
$Revision: 1.0 $
'
def
filter_arr
(
arr
,
threshold
,
fill_value
=
None
):
"""
Filter array arr of values that have a difference from the trend of
threshold. If fill_value is None(default) then a numpy.ma.masked_array will
be returned with the filtered values being masked.
@param arr: array to be filtered
@type arr: array or list
@param threshold: allowable change between values
@type threshold: int or float
@param fill_value: Value to replace the filtered values with (ex. NaN)
@type fill_value: anything
"""
if
type
.
arr
!=
ndarray
or
type
.
arr
!=
MaskedArray
:
if
fill_value
!=
None
:
arr
=
array
(
arr
)
if
fill_value
==
None
:
arr
=
masked_array
(
arr
)
diff_arr
=
diff
(
arr
,
n
=
1
)
if
fill_value
==
None
:
arr
=
masked_where
(
diff_arr
>=
threshold
,
arr
)
return
arr
\ No newline at end of file
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