Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
esde
toar-public
toarstats
Commits
b44c5acf
Commit
b44c5acf
authored
Oct 26, 2021
by
Niklas Selke
Browse files
Refactored the 'check_statistics' function in 'input_checks.py'.
parent
671ca3ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
toarstats/input_checks.py
View file @
b44c5acf
...
...
@@ -28,34 +28,32 @@ def check_sampling(sampling_in):
return
sampling_out
def
check_statistics
(
input_argument
):
def
check_statistics
(
statistics_in
):
"""Check the given statistics argument.
:param
input_argument: the given
argument
:param
statistics_in: the given statistics
argument
:return: The processed argument or None if there was a
problem with
the inpu
t
:return: The processed
statistics
argument or None if there was a
problem while processing the given statistics argumen
t
"""
if
not
isinstance
(
input_argument
,
(
list
,
str
)):
if
not
isinstance
(
statistics_in
,
(
list
,
str
)):
return
None
statistics
=
[]
if
isinstance
(
input_argument
,
str
):
stat
=
input_argument
.
strip
()
statistics_in_list
=
(
[
statistics_in
]
if
isinstance
(
statistics_in
,
str
)
else
statistics_in
)
statistics_out
=
[]
for
stat
in
statistics_in_list
:
if
not
isinstance
(
stat
,
str
):
continue
stat
=
stat
.
strip
()
func
=
getattr
(
stats
,
stat
,
getattr
(
ozone_metrics
,
stat
,
None
))
if
func
is
not
None
:
statistics
.
append
(
func
)
else
:
for
stat
in
input_argument
:
if
not
isinstance
(
stat
,
str
):
continue
stat
=
stat
.
strip
()
func
=
getattr
(
stats
,
stat
,
getattr
(
ozone_metrics
,
stat
,
None
))
if
func
is
not
None
and
func
not
in
statistics
:
statistics
.
append
(
func
)
if
(
not
statistics
or
(
stats
.
diurnal_cycle
in
statistics
and
len
(
statistics
)
>
1
)):
if
func
is
not
None
and
func
not
in
statistics_out
:
statistics_out
.
append
(
func
)
if
not
statistics_out
:
return
None
if
stats
.
diurnal_cycle
in
statistics_out
and
len
(
statistics_out
)
>
1
:
return
None
return
statistics
return
statistics
_out
def
check_data
(
input_argument
,
alt_input_idx
,
alt_input_vals
):
...
...
Write
Preview
Supports
Markdown
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