Skip to main content

A package to evaluate of forecast

Project description

cyeva

cyeva 是一个由彩云科技天气团队开发的用于对气象要素确定性预报准确率进行快速评测的 Python 开源工具库。

cyeva 将致力于让气象要素确定性预报准确率的自动化评估变得简单直接,将集成常用的确定性预报准确率评估指标,且内部算法广泛使用了 numpy 的向量运算实现,对于大数据量的计算也具有较高的计算效率。

安装

通过pip安装

$ pip install cyeva

通过源码安装

首先在版本页面选择想要安装的版本,解压,进入项目目录然后执行:

$ python setup.py install

使用

降水

import numpy as np
from cyeva import PrecipitationComparison

np.random.seed(0)

obs = np.random.random(int(1E6)) * 50
fcst = np.random.random(int(1E6)) * 50

precip = PrecipitationComparison(obs, fcst)

print(precip.calc_ts())                     # TS评分
for inv in ['1h', '3h', '24h']:
    for lev in range(7):
        print(f'ts-{inv}-{lev}:', precip.calc_ts(kind=inv, lev=str(lev)))
    
print(precip.calc_ets())                    # ETS评分
for inv in ['1h', '3h', '24h']:
    for lev in range(7):
        print(f'ets-{inv}-{lev}:', precip.calc_ets(kind=inv, lev=str(lev)))

print(precip.calc_bias_score())             # bias评分
for inv in ['1h', '3h', '24h']:
    for lev in range(7):
        print(f'bias-{inv}-{lev}:', precip.calc_bias(kind=inv, lev=str(lev)))

print(precip.calc_accuracy_ratio(kind='3h', lev='3'))         # 准确率(3小时间隔3级/大雨)
for inv in ['1h', '3h', '24h']:
    for lev in range(7):
        lev_str = str(lev)
        levp_str = f'+{lev_str}'
        print(f'ts-{inv}- {lev_str}:', precip.calc_ts(kind=inv, lev=lev_str))
        if lev > 0:
            print(f'ts-{inv}- {levp_str}:', precip.calc_ts(kind=inv, lev=levp_str))

print(precip.calc_rss())                    # 剩余平方和
print(precip.calc_rmse())                   # 均方根误差

print(precip.calc_mae())                    # 平均绝对误差
print(precip.calc_chi_square())             # 卡方(χ2)
print(precip.calc_accuracy_ratio())         # 准确率(0级)
print(precip.calc_accuracy_ratio(kind='1h', lev='1'))         # 准确率(1小时间隔1级/小雨)
print(precip.calc_accuracy_ratio(kind='3h', lev='1'))         # 准确率(3小时间隔1级/小雨)
print(precip.calc_accuracy_ratio(kind='3h', lev='3'))         # 准确率(3小时间隔3级/大雨)
for inv in ['1h', '3h', '24h']:
    for lev in range(7):
        print(f'{inv}-{lev}:', precip.calc_ts(kind=inv, lev=str(lev)))
print(precip.calc_accuracy_ratio(kind='3h', lev='+3'))        # 准确率(3小时间隔累计3级/大雨)
print(precip.calc_binary_accuracy_ratio())  # 准确率(二分/晴雨)
print(precip.calc_false_alarm_ratio())      # 空报率
print(precip.calc_miss_ratio())             # 漏报率

气温

import numpy as np
from cyeva import TemperatureComparison

np.random.seed(0)

obs = np.random.random(int(1E7)) * 50
fcst = np.random.random(int(1E7)) * 50

temp = TemperatureComparison(obs, fcst, unit='degC')

print(temp.calc_diff_accuracy_ratio(limit=1))       # 1度准确率(偏差在1°C以内)
print(temp.calc_diff_accuracy_ratio(limit=2))       # 2度准确率(偏差在2°C以内)
print(temp.calc_rss())                              # 剩余平方和
print(temp.calc_rmse())                             # 均方根误差
print(temp.calc_mae())                              # 平均绝对误差
print(temp.calc_chi_square())                       # 卡方(χ2)
print(temp.gather_all_factors())                    # 全部要素

import numpy as np
from cyeva import WindComparison

np.random.seed(0)

obs_spd = np.random.random(int(1E7)) * 10
obs_dir = np.random.random(int(1E7)) * 360
fct_spd = np.random.random(int(1E7)) * 10
fct_dir = np.random.random(int(1E7)) * 360

wind = WindComparison(obs_spd, fct_spd, obs_dir, fct_dir)

print(wind.calc_diff_accuracy_ratio(limit=1))       # 1度准确率(偏差在1°C以内)
print(wind.calc_diff_accuracy_ratio(limit=2))       # 2度准确率(偏差在2°C以内)
print(wind.calc_rss())                              # 剩余平方和(默认风速)
print(wind.calc_rss(kind='direction'))              # 剩余平方和(指定风向)
print(wind.calc_rmse())                             # 均方根误差(默认风速)
print(wind.calc_rmse(kind='direction'))             # 均方根误差(指定风向)
print(wind.calc_mae())                              # 平均绝对误差(默认风速)
print(wind.calc_mae(kind='direction'))              # 平均绝对误差(指定风向)
print(wind.calc_chi_square())                       # 卡方(χ2)
print(wind.calc_chi_square(kind='direction'))       # 卡方(χ2)(指定风向)
print(wind.calc_dir_score())                        # 风向评分
print(wind.calc_speed_score())                      # 风速评分
print(wind.calc_wind_scale_accuracy_ratio())        # 风级准确率
print(wind.calc_speed_accuracy_ratio())             # 风速准确率(默认2m/s偏差以内)
print(wind.calc_speed_accuracy_ratio(limit=3))      # 风速准确率(指定3m/s偏差以内)
print(wind.calc_wind_scale_stronger_ratio())        # 风级偏强率
print(wind.calc_wind_scale_weaker_ratio())          # 风级偏弱率

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cyeva-0.1.0b0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cyeva-0.1.0b0-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

File details

Details for the file cyeva-0.1.0b0.tar.gz.

File metadata

  • Download URL: cyeva-0.1.0b0.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cyeva-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 b812590eb23f44b7736b3fc574d7ef646ee9b2df8817508f971b66b2c22a5731
MD5 6fbc9e0280443664efbfb9f80c707fee
BLAKE2b-256 60748d5ab9827193c8d99dfa50d6ce23f92f8c58e2108040ae2f00822ee28b41

See more details on using hashes here.

File details

Details for the file cyeva-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: cyeva-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 41.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for cyeva-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 7694c2d4d185d1d54dedf4cb49f90b55aea89e7b8e8ee6e39a414d1d425189ce
MD5 bf19f1e02bd559027327edbe9b5bdcc0
BLAKE2b-256 5af935ba3fccb8def787be8984b16c02fe6c648e0f19527955ff726b36b911c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page