Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toarstats
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-public
toarstats
Commits
37997e86
Commit
37997e86
authored
3 years ago
by
Niklas Selke
Browse files
Options
Downloads
Patches
Plain Diff
Created a new function to calculate the SOMO metrics.
parent
828739c2
No related branches found
No related tags found
1 merge request
!5
Modified the test for the 'value_count' statistic. Now all available sampling...
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
toarstats/ozone_metrics.py
+10
-46
10 additions, 46 deletions
toarstats/ozone_metrics.py
toarstats/stats_utils.py
+32
-0
32 additions, 0 deletions
toarstats/stats_utils.py
with
42 additions
and
46 deletions
toarstats/ozone_metrics.py
+
10
−
46
View file @
37997e86
...
...
@@ -42,8 +42,8 @@ import pandas as pd
from
toarstats.stats_utils
import
(
aot40stat
,
dma8_processor
,
get_elevation_angle
,
kth_highest
,
prepare_data
,
resample_with_date
,
s
tat
_processor
_1
,
threshold
_processor
,
w126stat
)
s
omo
_processor
,
stat
_processor
_1
,
threshold_processor
,
w126stat
)
def
max1h_values
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
):
...
...
@@ -301,17 +301,8 @@ def somo10(ser, ref, mtype, metadata, seasons, data_capture):
:return: A list of dictionaries containing the processed data
"""
tmp
=
dma8eu
(
ser
,
ref
,
"
daily
"
,
metadata
,
seasons
,
data_capture
)
if
mtype
==
"
daily
"
:
res
=
tmp
res
[
0
][
"
name
"
]
=
"
somo10
"
else
:
new_ser
=
tmp
[
0
][
"
ser
"
]
-
10.
new_ser
[
new_ser
<
0.
]
=
0.
new_ref
=
pd
.
Series
(
1.
,
tmp
[
0
][
"
ref
"
].
resample
(
"
D
"
).
asfreq
().
index
)
res
=
stat_processor_1
(
"
somo10
"
,
new_ser
,
new_ref
,
mtype
,
seasons
,
how
=
"
sum
"
,
minfrac
=
data_capture
)
return
res
return
somo_processor
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
,
10.
)
def
somo35
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
):
...
...
@@ -333,17 +324,8 @@ def somo35(ser, ref, mtype, metadata, seasons, data_capture):
:return: A list of dictionaries containing the processed data
"""
tmp
=
dma8eu
(
ser
,
ref
,
"
daily
"
,
metadata
,
seasons
,
data_capture
)
if
mtype
==
"
daily
"
:
res
=
tmp
res
[
0
][
"
name
"
]
=
"
somo35
"
else
:
new_ser
=
tmp
[
0
][
"
ser
"
]
-
35.
new_ser
[
new_ser
<
0.
]
=
0.
new_ref
=
pd
.
Series
(
1.
,
tmp
[
0
][
"
ref
"
].
resample
(
"
D
"
).
asfreq
().
index
)
res
=
stat_processor_1
(
"
somo35
"
,
new_ser
,
new_ref
,
mtype
,
seasons
,
how
=
"
sum
"
,
minfrac
=
data_capture
)
return
res
return
somo_processor
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
,
35.
)
def
somo10_strict
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
):
...
...
@@ -365,17 +347,8 @@ def somo10_strict(ser, ref, mtype, metadata, seasons, data_capture):
:return: A list of dictionaries containing the processed data
"""
tmp
=
dma8eu_strict
(
ser
,
ref
,
"
daily
"
,
metadata
,
seasons
,
data_capture
)
if
mtype
==
"
daily
"
:
res
=
tmp
res
[
0
][
"
name
"
]
=
"
somo10_strict
"
else
:
new_ser
=
tmp
[
0
][
"
ser
"
]
-
10.
new_ser
[
new_ser
<
0.
]
=
0.
new_ref
=
pd
.
Series
(
1.
,
tmp
[
0
][
"
ref
"
].
resample
(
"
D
"
).
asfreq
().
index
)
res
=
stat_processor_1
(
"
somo10_strict
"
,
new_ser
,
new_ref
,
mtype
,
seasons
,
how
=
"
sum
"
,
minfrac
=
data_capture
)
return
res
return
somo_processor
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
,
10.
,
strict
=
True
)
def
somo35_strict
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
):
...
...
@@ -397,17 +370,8 @@ def somo35_strict(ser, ref, mtype, metadata, seasons, data_capture):
:return: A list of dictionaries containing the processed data
"""
tmp
=
dma8eu_strict
(
ser
,
ref
,
"
daily
"
,
metadata
,
seasons
,
data_capture
)
if
mtype
==
"
daily
"
:
res
=
tmp
res
[
0
][
"
name
"
]
=
"
somo35_strict
"
else
:
new_ser
=
tmp
[
0
][
"
ser
"
]
-
35.
new_ser
[
new_ser
<
0.
]
=
0.
new_ref
=
pd
.
Series
(
1.
,
tmp
[
0
][
"
ref
"
].
resample
(
"
D
"
).
asfreq
().
index
)
res
=
stat_processor_1
(
"
somo35_strict
"
,
new_ser
,
new_ref
,
mtype
,
seasons
,
how
=
"
sum
"
,
minfrac
=
data_capture
)
return
res
return
somo_processor
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
,
35.
,
strict
=
True
)
def
w90
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
):
...
...
This diff is collapsed.
Click to expand it.
toarstats/stats_utils.py
+
32
−
0
View file @
37997e86
...
...
@@ -14,6 +14,7 @@ perc - calculate percentiles
prepare_data - prepare the result list
resample - resample the given series
resample_with_date - resample the given series
somo_processor - calculate the sum of excess of dma8
stat_processor_1 - calculate statistics
stat_processor_2 - calculate statistics
threshold_processor - evaluate counts above the given threshold
...
...
@@ -409,6 +410,37 @@ def resample_with_date(ser, ref, sampling, how, mincount=0, minfrac=None,
return
dfres
def
somo_processor
(
ser
,
ref
,
mtype
,
metadata
,
seasons
,
data_capture
,
threshold
,
strict
=
False
):
"""
Calculate the sum of excess of daily maximum 8-hour means.
:param ser: a series containing the values
:param ref: reference series
:param mtype: aggregation type
:param metadata: metadata needed for some statistics
:param seasons: season names
:param data_capture: a fractional coverage value
:param threshold: the cut-off value
:param strict: a boolean denoting whether to use the strict rules
when to save a running mean
:return: A list of dictionaries containing the processed data
"""
label
=
f
"
somo
{
int
(
threshold
)
}{
'
_strict
'
if
strict
else
''
}
"
tmp
=
dma8_processor
(
ser
,
ref
,
"
daily
"
,
metadata
,
seasons
,
data_capture
,
dname
=
"
EU
"
,
strict
=
strict
)
if
mtype
==
"
daily
"
:
res
=
tmp
res
[
0
][
"
name
"
]
=
label
else
:
new_ser
=
tmp
[
0
][
"
ser
"
]
-
threshold
new_ser
[
new_ser
<
0.
]
=
0.
new_ref
=
pd
.
Series
(
1.
,
tmp
[
0
][
"
ref
"
].
resample
(
"
D
"
).
asfreq
().
index
)
res
=
stat_processor_1
(
label
,
new_ser
,
new_ref
,
mtype
,
seasons
,
how
=
"
sum
"
,
minfrac
=
data_capture
)
return
res
def
stat_processor_1
(
label
,
ser
,
ref
,
mtype
,
seasons
,
func
=
resample
,
how
=
"
mean
"
,
mincount
=
0
,
minfrac
=
None
,
**
kwargs
):
"""
Calculate statistics.
...
...
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