-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Fairmode statistic to aeroval output #613
Conversation
Merge remote-tracking branch 'origin/main-dev' into fairmode
Fairmode MQI
Codecov Report
@@ Coverage Diff @@
## main-dev #613 +/- ##
============================================
+ Coverage 76.96% 76.99% +0.02%
============================================
Files 97 98 +1
Lines 17503 17546 +43
============================================
+ Hits 13471 13509 +38
- Misses 4032 4037 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some small things to clean up
from math import sqrt | ||
from typing import Tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused imports?
|
||
|
||
def _get_RMSU(mean: float, std: float, species: str) -> Tuple[float, float, float, float]: | ||
species_values = dict( | ||
concno2=dict( | ||
UrRV=0.24, | ||
RV=200, | ||
alpha=0.2, | ||
), | ||
vmro3=dict( | ||
UrRV=0.18, | ||
RV=120, | ||
alpha=0.79, | ||
), | ||
concpm10=dict( | ||
UrRV=0.28, | ||
RV=50, | ||
alpha=0.13, | ||
), | ||
concpm25=dict( | ||
UrRV=0.28, | ||
RV=25, | ||
alpha=0.3, | ||
), | ||
) | ||
|
||
if species not in species_values.keys(): | ||
raise KeyError(f"Species {species} not in list {species_values.keys()}") | ||
|
||
UrRV = species_values[species]["UrRV"] | ||
RV = species_values[species]["RV"] | ||
alpha = species_values[species]["alpha"] | ||
|
||
in_sqrt = (1 - alpha ** 2) * (mean ** 2 + std ** 2) + alpha ** 2 * RV ** 2 | ||
|
||
return UrRV * sqrt(in_sqrt), UrRV, RV, alpha | ||
|
||
|
||
def _get_fairmode_sign(mod_std: float, obs_std: float, R: float) -> float: | ||
if obs_std * sqrt(2 * (1 - R)) == 0: | ||
return 1 | ||
a = abs(mod_std - obs_std) / (obs_std * sqrt(2 * (1 - R))) | ||
return 1 if a >= 1 else -1 | ||
|
||
|
||
def _get_crms(mod_std: float, obs_std: float, R: float) -> float: | ||
return sqrt(mod_std ** 2 + obs_std ** 2 - 2 * mod_std * obs_std * R) | ||
|
||
|
||
def _process_fairmode(obs_var, stats): | ||
species_list = ["concno2", "vmro3", "concpm10", "concpm25"] | ||
|
||
fairmode_stats = dict() | ||
|
||
if obs_var not in species_list: | ||
return fairmode_stats | ||
|
||
mean = stats["refdata_mean"] | ||
obs_std = stats["refdata_std"] | ||
mod_std = stats["data_std"] | ||
R = stats["R"] | ||
bias = stats["mb"] | ||
rms = stats["rms"] | ||
|
||
crms = _get_crms(mod_std, obs_std, R) # sqrt(rms ** 2 - bias ** 2) | ||
sign = _get_fairmode_sign(mod_std, obs_std, R) | ||
rmsu, UrRV, RV, alpha = _get_RMSU(mean, obs_std, obs_var) | ||
|
||
fairmode_stats["RMSU"] = rmsu | ||
fairmode_stats["sign"] = sign | ||
fairmode_stats["crms"] = crms | ||
fairmode_stats["bias"] = bias | ||
fairmode_stats["rms"] = rms | ||
fairmode_stats["alpha"] = alpha | ||
fairmode_stats["UrRV"] = UrRV | ||
fairmode_stats["RV"] = RV | ||
|
||
return fairmode_stats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated code, see fairmode_stats.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready to merge
close #601