Name | cyeva JSON |
Version |
0.2.3
JSON |
| download |
home_page | None |
Summary | A package to evaluate weather forecast correction |
upload_time | 2024-10-26 04:34:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | <3.13,>=3.10 |
license | Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [2023] [Beijing ColorfulClouds Technology Co.,Ltd.] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
keywords |
atmospheric-science
mathmatics
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<h1 align="center" style="margin:1em;">
<a href="./docs/source/_static/logo.png">
<img src="./docs/source/_static/logo.png"
alt="cyeva"></a>
</h1>
[![Pytest](https://github.com/caiyunapp/cyeva/actions/workflows/test.yml/badge.svg)](https://github.com/caiyunapp/cyeva/actions/workflows/test.yml)
[![Pypi publish](https://github.com/caiyunapp/cyeva/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/caiyunapp/cyeva/actions/workflows/pypi-publish.yml)
[![Anaconda.org](https://anaconda.org/conda-forge/cyeva/badges/version.svg)](https://anaconda.org/conda-forge/cyeva)
[![Downloads](https://anaconda.org/conda-forge/cyeva/badges/downloads.svg)](https://anaconda.org/conda-forge/cyeva)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/cyeva/badges/platforms.svg)](https://anaconda.org/conda-forge/cyeva)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/cyeva/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/cyeva)
[![Pypi](https://badge.fury.io/py/cyeva.svg)](https://badge.fury.io/py/cyeva)
[![Documentation Status](https://readthedocs.org/projects/cyeva/badge/?version=latest)](https://cyeva.readthedocs.io/zh_CN/latest/?badge=latest)
[![Download statistic](https://pepy.tech/badge/cyeva)](https://pepy.tech/project/cyeva)
[![codecov](https://codecov.io/gh/caiyunapp/cyeva/branch/main/graph/badge.svg?token=344FXDKAYD)](https://codecov.io/gh/caiyunapp/cyeva)
[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/caiyunapp/cyeva)
cyeva 是一个由彩云科技天气团队和社区贡献者共同开发的用于对气象要素确定性预报准确率进行快速评测的 Python 开源工具库。
cyeva 将致力于让气象要素确定性预报准确率的自动化评估变得简单直接,将集成常用的确定性预报准确率评估指标,且内部算法广泛使用了 NumPy 的向量运算实现,对于大数据量的计算也具有较高的计算效率。
## 安装
### 通过 pip 安装
```bash
$ pip install cyeva
```
**注意:由于本项目目前处于 beta 阶段,并非稳定版本,有可能在后续的发布版中出现不兼容性修改,因此在安装时建议指定版本号,例如 `pip install cyeva==0.2.3`**
### 通过源码安装
需要安装 [uv](http://github.com/astral-sh/uv),然后在[版本页面](https://github.com/caiyunapp/cyeva/releases)选择想要安装的版本,解压,进入项目目录然后执行:
```bash
make sync
```
## 使用
cyeva 为气温、风和降水编写了专门的对象用于处理对应要素的相关指标。
### 气温
对于气温这种连续性变量,我们通常会比较关心它的 RMSE 、 MAE 等指标。在 cyeva 中我们可以参照以下的例子来计算此类指标:
```python
import numpy as np
from cyeva import TemperatureComparison
np.random.seed(0) # 指定随机种子以保证得到的结果都是一致的
obs = np.sin(np.arange(100)) * 20 + np.random.random(100) * 5 * np.random.choice([1, -1]) # sin数组叠加随机数组模拟真实气温
fcst = obs + np.random.random(100) * 5 * np.random.choice([1, -1]) # 限制预报在观测的正负5°C以内,这样的样例出来的效果更好一些
temp = TemperatureComparison(obs, fcst, unit='degC')
print('accuracy ration within 1 degC:', temp.calc_diff_accuracy_ratio(limit=1)) # 1度准确率(偏差在1°C以内)
print('accuracy ration within 2 degC:', temp.calc_diff_accuracy_ratio(limit=2)) # 2度准确率(偏差在2°C以内)
print('rss:', temp.calc_rss()) # 剩余平方和
print('rmse:', temp.calc_rmse()) # 均方根误差
print('mae:', temp.calc_mae()) # 平均绝对误差
print('chi square:', temp.calc_chi_square()) # 卡方(χ2)
```
### 降水
降水的一个特点是它不具有连续性,因此在对其进行准确性评估的时候,除了通用的指标以外,通常会引入一些其他的指标(例如 TS 评分)。此外,降水有明显的分级特点,还需要按照不同级别的做相应的区别,在 cyeva 中我们可以参照以下的例子来计算用于评估降水的指标:
```python
import numpy as np
from cyeva import PrecipitationComparison
np.random.seed(0) # 指定随机种子以保证得到的结果都是一致的
obs = np.random.random(int(100)) * 50
fcst = np.random.random(int(100)) * 50
precip = PrecipitationComparison(obs, fcst, unit='mm')
print('rss:', precip.calc_rss()) # 剩余平方和
print('rmse:', precip.calc_rmse()) # 均方根误差
print('mae:', precip.calc_mae()) # 平均绝对误差
print('chi square:', precip.calc_chi_square()) # 卡方(χ2)
print('accuracy ratio:', precip.calc_accuracy_ratio()) # 准确率(0级)
print('binary accuracy ratio:', precip.calc_binary_accuracy_ratio()) # 准确率(二分/晴雨)
print('false alarm ratio:', precip.calc_false_alarm_ratio()) # 空报率
print('miss ratio:', precip.calc_miss_ratio()) # 漏报率
print('accuracy ratio:', precip.calc_accuracy_ratio(kind='3h', lev='3')) # 准确率(3小时间隔3级/大雨)
for inv in ['1h', '3h', '12h', '24h']: # 不同间隔下的准确率
for lev in range(7):
lev_str = str(lev)
levp_str = f'+{lev_str}'
print(f'accuracy ratio({inv}|{lev_str}):', precip.calc_accuracy_ratio(kind=inv, lev=lev_str))
if lev > 0:
print(f'accuracy ratio({inv}|{levp_str}):', precip.calc_accuracy_ratio(kind=inv, lev=levp_str))
print('ts:', precip.calc_ts()) # TS评分(默认为1h晴雨TS)
for inv in ['1h', '3h', '12h', '24h']: # 不同间隔下的分级TS评分
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('ets:', precip.calc_ets()) # ETS评分(默认为1h晴雨ETS)
for inv in ['1h', '3h', '12h', '24h']: # 不同间隔下的分级ETS评分
for lev in range(7):
lev_str = str(lev)
levp_str = f'+{lev_str}'
print(f'ets({inv}|{lev_str}):', precip.calc_ets(kind=inv, lev=lev_str))
if lev > 0:
print(f'ets({inv}|{levp_str}):', precip.calc_ets(kind=inv, lev=levp_str))
print('bias:', precip.calc_bias_score()) # bias评分(默认为1h晴雨bias)
for inv in ['1h', '3h', '12h', '24h']: # 不同间隔下的分级bias评分
for lev in range(7):
lev_str = str(lev)
levp_str = f'+{lev_str}'
print(f'bias({inv}|{lev_str}):', precip.calc_bias_score(kind=inv, lev=lev_str))
if lev > 0:
print(f'bias({inv}|{levp_str}):', precip.calc_bias_score(kind=inv, lev=levp_str))
```
### 风
对于风这种矢量要素,我们需要同时提供速度和方向信息,因此在实例化对象的时候传入的数据数组会和气温、降水不一样,同时也有一些专门针对于风评估的指标,例如风级偏强率偏弱率等,在 cyeva 中我们可以参照以下的例子来计算用于评估风的指标:
```python
import numpy as np
from cyeva import WindComparison
np.random.seed(0)
obs_spd = np.random.random(100) * 10
obs_dir = np.random.random(100) * 360
fct_spd = np.random.random(100) * 10
fct_dir = np.random.random(100) * 360
wind = WindComparison(obs_spd, fct_spd, obs_dir, fct_dir)
print('difference accuracy ratio within 1 m/s:', wind.calc_diff_accuracy_ratio(limit=1)) # 1m/s准确率(风速偏差在1m/s以内)
print('difference accuracy ratio within 2 m/s:', wind.calc_diff_accuracy_ratio(limit=2)) # 2m/s准确率(风速偏差在2m/s以内)
print('wind speed rss:', wind.calc_rss()) # 剩余平方和(默认风速)
print('wind direction rss:', wind.calc_rss(kind='direction')) # 剩余平方和(指定风向)
print('wind speed rmse:', wind.calc_rmse()) # 均方根误差(默认风速)
print('wind direction rmse:', wind.calc_rmse(kind='direction')) # 均方根误差(指定风向)
print('wind speed mae:', wind.calc_mae()) # 平均绝对误差(默认风速)
print('wind direction mae:', wind.calc_mae(kind='direction')) # 平均绝对误差(指定风向)
print('wind speed chi square:', wind.calc_chi_square()) # 卡方(χ2)
print('wind direction chi square:', wind.calc_chi_square(kind='direction')) # 卡方(χ2)(指定风向)
print('wind direction score:', wind.calc_dir_score()) # 风向评分
print('wind speed score:', wind.calc_speed_score()) # 风速评分
print('wind scale accuracy ratio:', wind.calc_wind_scale_accuracy_ratio()) # 风级准确率
print('wind speed accuracy ratio within 2m/s:', wind.calc_speed_accuracy_ratio()) # 风速准确率(默认2m/s偏差以内)
print('wind speed accuracy radio within 3m/s:', wind.calc_speed_accuracy_ratio(limit=3)) # 风速准确率(指定3m/s偏差以内)
print('wind scale stronger ratio:', wind.calc_wind_scale_stronger_ratio()) # 风级偏强率
print('wind scale weaker ratio:', wind.calc_wind_scale_weaker_ratio()) # 风级偏弱率
```
## 算法解释
对于本项目所实现的各类测评算法及其解释、公式等信息,可以参考 [cyeva 说明文档](https://cyeva.readthedocs.io/zh_CN/latest/index.html) 的 [算法指标](https://cyeva.readthedocs.io/zh_CN/latest/content/indicator.html) 部分。
Raw data
{
"_id": null,
"home_page": null,
"name": "cyeva",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.10",
"maintainer_email": "caiyunapp <oss@caiyunapp.com>, ringsaturn <ringsaturn.me@gmail.com>",
"keywords": "atmospheric-science, mathmatics",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0a/83/ffb92ab66485b65276e103e2be62a69e261679ae63de9948a2cb7c175823/cyeva-0.2.3.tar.gz",
"platform": null,
"description": "<h1 align=\"center\" style=\"margin:1em;\">\n <a href=\"./docs/source/_static/logo.png\">\n <img src=\"./docs/source/_static/logo.png\"\n alt=\"cyeva\"></a>\n</h1>\n\n[![Pytest](https://github.com/caiyunapp/cyeva/actions/workflows/test.yml/badge.svg)](https://github.com/caiyunapp/cyeva/actions/workflows/test.yml)\n[![Pypi publish](https://github.com/caiyunapp/cyeva/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/caiyunapp/cyeva/actions/workflows/pypi-publish.yml)\n[![Anaconda.org](https://anaconda.org/conda-forge/cyeva/badges/version.svg)](https://anaconda.org/conda-forge/cyeva)\n[![Downloads](https://anaconda.org/conda-forge/cyeva/badges/downloads.svg)](https://anaconda.org/conda-forge/cyeva)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/cyeva/badges/platforms.svg)](https://anaconda.org/conda-forge/cyeva)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/cyeva/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/cyeva)\n[![Pypi](https://badge.fury.io/py/cyeva.svg)](https://badge.fury.io/py/cyeva)\n[![Documentation Status](https://readthedocs.org/projects/cyeva/badge/?version=latest)](https://cyeva.readthedocs.io/zh_CN/latest/?badge=latest)\n[![Download statistic](https://pepy.tech/badge/cyeva)](https://pepy.tech/project/cyeva)\n[![codecov](https://codecov.io/gh/caiyunapp/cyeva/branch/main/graph/badge.svg?token=344FXDKAYD)](https://codecov.io/gh/caiyunapp/cyeva)\n[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/caiyunapp/cyeva)\n\ncyeva \u662f\u4e00\u4e2a\u7531\u5f69\u4e91\u79d1\u6280\u5929\u6c14\u56e2\u961f\u548c\u793e\u533a\u8d21\u732e\u8005\u5171\u540c\u5f00\u53d1\u7684\u7528\u4e8e\u5bf9\u6c14\u8c61\u8981\u7d20\u786e\u5b9a\u6027\u9884\u62a5\u51c6\u786e\u7387\u8fdb\u884c\u5feb\u901f\u8bc4\u6d4b\u7684 Python \u5f00\u6e90\u5de5\u5177\u5e93\u3002\n\ncyeva \u5c06\u81f4\u529b\u4e8e\u8ba9\u6c14\u8c61\u8981\u7d20\u786e\u5b9a\u6027\u9884\u62a5\u51c6\u786e\u7387\u7684\u81ea\u52a8\u5316\u8bc4\u4f30\u53d8\u5f97\u7b80\u5355\u76f4\u63a5\uff0c\u5c06\u96c6\u6210\u5e38\u7528\u7684\u786e\u5b9a\u6027\u9884\u62a5\u51c6\u786e\u7387\u8bc4\u4f30\u6307\u6807\uff0c\u4e14\u5185\u90e8\u7b97\u6cd5\u5e7f\u6cdb\u4f7f\u7528\u4e86 NumPy \u7684\u5411\u91cf\u8fd0\u7b97\u5b9e\u73b0\uff0c\u5bf9\u4e8e\u5927\u6570\u636e\u91cf\u7684\u8ba1\u7b97\u4e5f\u5177\u6709\u8f83\u9ad8\u7684\u8ba1\u7b97\u6548\u7387\u3002\n\n## \u5b89\u88c5\n\n### \u901a\u8fc7 pip \u5b89\u88c5\n\n```bash\n$ pip install cyeva\n```\n\n**\u6ce8\u610f\uff1a\u7531\u4e8e\u672c\u9879\u76ee\u76ee\u524d\u5904\u4e8e beta \u9636\u6bb5\uff0c\u5e76\u975e\u7a33\u5b9a\u7248\u672c\uff0c\u6709\u53ef\u80fd\u5728\u540e\u7eed\u7684\u53d1\u5e03\u7248\u4e2d\u51fa\u73b0\u4e0d\u517c\u5bb9\u6027\u4fee\u6539\uff0c\u56e0\u6b64\u5728\u5b89\u88c5\u65f6\u5efa\u8bae\u6307\u5b9a\u7248\u672c\u53f7\uff0c\u4f8b\u5982 `pip install cyeva==0.2.3`**\n\n### \u901a\u8fc7\u6e90\u7801\u5b89\u88c5\n\n\u9700\u8981\u5b89\u88c5 [uv](http://github.com/astral-sh/uv)\uff0c\u7136\u540e\u5728[\u7248\u672c\u9875\u9762](https://github.com/caiyunapp/cyeva/releases)\u9009\u62e9\u60f3\u8981\u5b89\u88c5\u7684\u7248\u672c\uff0c\u89e3\u538b\uff0c\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u7136\u540e\u6267\u884c\uff1a\n\n```bash\nmake sync\n```\n\n## \u4f7f\u7528\n\ncyeva \u4e3a\u6c14\u6e29\u3001\u98ce\u548c\u964d\u6c34\u7f16\u5199\u4e86\u4e13\u95e8\u7684\u5bf9\u8c61\u7528\u4e8e\u5904\u7406\u5bf9\u5e94\u8981\u7d20\u7684\u76f8\u5173\u6307\u6807\u3002\n\n### \u6c14\u6e29\n\n\u5bf9\u4e8e\u6c14\u6e29\u8fd9\u79cd\u8fde\u7eed\u6027\u53d8\u91cf\uff0c\u6211\u4eec\u901a\u5e38\u4f1a\u6bd4\u8f83\u5173\u5fc3\u5b83\u7684 RMSE \u3001 MAE \u7b49\u6307\u6807\u3002\u5728 cyeva \u4e2d\u6211\u4eec\u53ef\u4ee5\u53c2\u7167\u4ee5\u4e0b\u7684\u4f8b\u5b50\u6765\u8ba1\u7b97\u6b64\u7c7b\u6307\u6807\uff1a\n\n```python\nimport numpy as np\nfrom cyeva import TemperatureComparison\n\nnp.random.seed(0) # \u6307\u5b9a\u968f\u673a\u79cd\u5b50\u4ee5\u4fdd\u8bc1\u5f97\u5230\u7684\u7ed3\u679c\u90fd\u662f\u4e00\u81f4\u7684\n\nobs = np.sin(np.arange(100)) * 20 + np.random.random(100) * 5 * np.random.choice([1, -1]) # sin\u6570\u7ec4\u53e0\u52a0\u968f\u673a\u6570\u7ec4\u6a21\u62df\u771f\u5b9e\u6c14\u6e29\nfcst = obs + np.random.random(100) * 5 * np.random.choice([1, -1]) # \u9650\u5236\u9884\u62a5\u5728\u89c2\u6d4b\u7684\u6b63\u8d1f5\u00b0C\u4ee5\u5185\uff0c\u8fd9\u6837\u7684\u6837\u4f8b\u51fa\u6765\u7684\u6548\u679c\u66f4\u597d\u4e00\u4e9b\n\ntemp = TemperatureComparison(obs, fcst, unit='degC')\n\nprint('accuracy ration within 1 degC:', temp.calc_diff_accuracy_ratio(limit=1)) # 1\u5ea6\u51c6\u786e\u7387\uff08\u504f\u5dee\u57281\u00b0C\u4ee5\u5185\uff09\nprint('accuracy ration within 2 degC:', temp.calc_diff_accuracy_ratio(limit=2)) # 2\u5ea6\u51c6\u786e\u7387\uff08\u504f\u5dee\u57282\u00b0C\u4ee5\u5185\uff09\nprint('rss:', temp.calc_rss()) # \u5269\u4f59\u5e73\u65b9\u548c\nprint('rmse:', temp.calc_rmse()) # \u5747\u65b9\u6839\u8bef\u5dee\nprint('mae:', temp.calc_mae()) # \u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\nprint('chi square:', temp.calc_chi_square()) # \u5361\u65b9(\u03c72)\n```\n\n### \u964d\u6c34\n\n\u964d\u6c34\u7684\u4e00\u4e2a\u7279\u70b9\u662f\u5b83\u4e0d\u5177\u6709\u8fde\u7eed\u6027\uff0c\u56e0\u6b64\u5728\u5bf9\u5176\u8fdb\u884c\u51c6\u786e\u6027\u8bc4\u4f30\u7684\u65f6\u5019\uff0c\u9664\u4e86\u901a\u7528\u7684\u6307\u6807\u4ee5\u5916\uff0c\u901a\u5e38\u4f1a\u5f15\u5165\u4e00\u4e9b\u5176\u4ed6\u7684\u6307\u6807\uff08\u4f8b\u5982 TS \u8bc4\u5206\uff09\u3002\u6b64\u5916\uff0c\u964d\u6c34\u6709\u660e\u663e\u7684\u5206\u7ea7\u7279\u70b9\uff0c\u8fd8\u9700\u8981\u6309\u7167\u4e0d\u540c\u7ea7\u522b\u7684\u505a\u76f8\u5e94\u7684\u533a\u522b\uff0c\u5728 cyeva \u4e2d\u6211\u4eec\u53ef\u4ee5\u53c2\u7167\u4ee5\u4e0b\u7684\u4f8b\u5b50\u6765\u8ba1\u7b97\u7528\u4e8e\u8bc4\u4f30\u964d\u6c34\u7684\u6307\u6807\uff1a\n\n```python\nimport numpy as np\nfrom cyeva import PrecipitationComparison\n\nnp.random.seed(0) # \u6307\u5b9a\u968f\u673a\u79cd\u5b50\u4ee5\u4fdd\u8bc1\u5f97\u5230\u7684\u7ed3\u679c\u90fd\u662f\u4e00\u81f4\u7684\n\nobs = np.random.random(int(100)) * 50\nfcst = np.random.random(int(100)) * 50\n\nprecip = PrecipitationComparison(obs, fcst, unit='mm')\n\nprint('rss:', precip.calc_rss()) # \u5269\u4f59\u5e73\u65b9\u548c\nprint('rmse:', precip.calc_rmse()) # \u5747\u65b9\u6839\u8bef\u5dee\nprint('mae:', precip.calc_mae()) # \u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\nprint('chi square:', precip.calc_chi_square()) # \u5361\u65b9(\u03c72)\nprint('accuracy ratio:', precip.calc_accuracy_ratio()) # \u51c6\u786e\u7387(0\u7ea7)\nprint('binary accuracy ratio:', precip.calc_binary_accuracy_ratio()) # \u51c6\u786e\u7387(\u4e8c\u5206/\u6674\u96e8)\nprint('false alarm ratio:', precip.calc_false_alarm_ratio()) # \u7a7a\u62a5\u7387\nprint('miss ratio:', precip.calc_miss_ratio()) # \u6f0f\u62a5\u7387\n\nprint('accuracy ratio:', precip.calc_accuracy_ratio(kind='3h', lev='3')) # \u51c6\u786e\u7387(3\u5c0f\u65f6\u95f4\u96943\u7ea7/\u5927\u96e8)\nfor inv in ['1h', '3h', '12h', '24h']: # \u4e0d\u540c\u95f4\u9694\u4e0b\u7684\u51c6\u786e\u7387\n for lev in range(7):\n lev_str = str(lev)\n levp_str = f'+{lev_str}'\n print(f'accuracy ratio({inv}|{lev_str}):', precip.calc_accuracy_ratio(kind=inv, lev=lev_str))\n if lev > 0:\n print(f'accuracy ratio({inv}|{levp_str}):', precip.calc_accuracy_ratio(kind=inv, lev=levp_str))\n\nprint('ts:', precip.calc_ts()) # TS\u8bc4\u5206\uff08\u9ed8\u8ba4\u4e3a1h\u6674\u96e8TS\uff09\nfor inv in ['1h', '3h', '12h', '24h']: # \u4e0d\u540c\u95f4\u9694\u4e0b\u7684\u5206\u7ea7TS\u8bc4\u5206\n for lev in range(7):\n lev_str = str(lev)\n levp_str = f'+{lev_str}'\n print(f'ts({inv}|{lev_str}):', precip.calc_ts(kind=inv, lev=lev_str))\n if lev > 0:\n print(f'ts({inv}|{levp_str}):', precip.calc_ts(kind=inv, lev=levp_str))\n\nprint('ets:', precip.calc_ets()) # ETS\u8bc4\u5206\uff08\u9ed8\u8ba4\u4e3a1h\u6674\u96e8ETS\uff09\nfor inv in ['1h', '3h', '12h', '24h']: # \u4e0d\u540c\u95f4\u9694\u4e0b\u7684\u5206\u7ea7ETS\u8bc4\u5206\n for lev in range(7):\n lev_str = str(lev)\n levp_str = f'+{lev_str}'\n print(f'ets({inv}|{lev_str}):', precip.calc_ets(kind=inv, lev=lev_str))\n if lev > 0:\n print(f'ets({inv}|{levp_str}):', precip.calc_ets(kind=inv, lev=levp_str))\n\nprint('bias:', precip.calc_bias_score()) # bias\u8bc4\u5206\uff08\u9ed8\u8ba4\u4e3a1h\u6674\u96e8bias\uff09\nfor inv in ['1h', '3h', '12h', '24h']: # \u4e0d\u540c\u95f4\u9694\u4e0b\u7684\u5206\u7ea7bias\u8bc4\u5206\n for lev in range(7):\n lev_str = str(lev)\n levp_str = f'+{lev_str}'\n print(f'bias({inv}|{lev_str}):', precip.calc_bias_score(kind=inv, lev=lev_str))\n if lev > 0:\n print(f'bias({inv}|{levp_str}):', precip.calc_bias_score(kind=inv, lev=levp_str))\n```\n\n### \u98ce\n\n\u5bf9\u4e8e\u98ce\u8fd9\u79cd\u77e2\u91cf\u8981\u7d20\uff0c\u6211\u4eec\u9700\u8981\u540c\u65f6\u63d0\u4f9b\u901f\u5ea6\u548c\u65b9\u5411\u4fe1\u606f\uff0c\u56e0\u6b64\u5728\u5b9e\u4f8b\u5316\u5bf9\u8c61\u7684\u65f6\u5019\u4f20\u5165\u7684\u6570\u636e\u6570\u7ec4\u4f1a\u548c\u6c14\u6e29\u3001\u964d\u6c34\u4e0d\u4e00\u6837\uff0c\u540c\u65f6\u4e5f\u6709\u4e00\u4e9b\u4e13\u95e8\u9488\u5bf9\u4e8e\u98ce\u8bc4\u4f30\u7684\u6307\u6807\uff0c\u4f8b\u5982\u98ce\u7ea7\u504f\u5f3a\u7387\u504f\u5f31\u7387\u7b49\uff0c\u5728 cyeva \u4e2d\u6211\u4eec\u53ef\u4ee5\u53c2\u7167\u4ee5\u4e0b\u7684\u4f8b\u5b50\u6765\u8ba1\u7b97\u7528\u4e8e\u8bc4\u4f30\u98ce\u7684\u6307\u6807\uff1a\n\n```python\nimport numpy as np\nfrom cyeva import WindComparison\n\nnp.random.seed(0)\n\nobs_spd = np.random.random(100) * 10\nobs_dir = np.random.random(100) * 360\nfct_spd = np.random.random(100) * 10\nfct_dir = np.random.random(100) * 360\n\nwind = WindComparison(obs_spd, fct_spd, obs_dir, fct_dir)\n\nprint('difference accuracy ratio within 1 m/s:', wind.calc_diff_accuracy_ratio(limit=1)) # 1m/s\u51c6\u786e\u7387\uff08\u98ce\u901f\u504f\u5dee\u57281m/s\u4ee5\u5185\uff09\nprint('difference accuracy ratio within 2 m/s:', wind.calc_diff_accuracy_ratio(limit=2)) # 2m/s\u51c6\u786e\u7387\uff08\u98ce\u901f\u504f\u5dee\u57282m/s\u4ee5\u5185\uff09\nprint('wind speed rss:', wind.calc_rss()) # \u5269\u4f59\u5e73\u65b9\u548c\uff08\u9ed8\u8ba4\u98ce\u901f\uff09\nprint('wind direction rss:', wind.calc_rss(kind='direction')) # \u5269\u4f59\u5e73\u65b9\u548c\uff08\u6307\u5b9a\u98ce\u5411\uff09\nprint('wind speed rmse:', wind.calc_rmse()) # \u5747\u65b9\u6839\u8bef\u5dee\uff08\u9ed8\u8ba4\u98ce\u901f\uff09\nprint('wind direction rmse:', wind.calc_rmse(kind='direction')) # \u5747\u65b9\u6839\u8bef\u5dee\uff08\u6307\u5b9a\u98ce\u5411\uff09\nprint('wind speed mae:', wind.calc_mae()) # \u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\uff08\u9ed8\u8ba4\u98ce\u901f\uff09\nprint('wind direction mae:', wind.calc_mae(kind='direction')) # \u5e73\u5747\u7edd\u5bf9\u8bef\u5dee\uff08\u6307\u5b9a\u98ce\u5411\uff09\nprint('wind speed chi square:', wind.calc_chi_square()) # \u5361\u65b9(\u03c72)\nprint('wind direction chi square:', wind.calc_chi_square(kind='direction')) # \u5361\u65b9(\u03c72)\uff08\u6307\u5b9a\u98ce\u5411\uff09\nprint('wind direction score:', wind.calc_dir_score()) # \u98ce\u5411\u8bc4\u5206\nprint('wind speed score:', wind.calc_speed_score()) # \u98ce\u901f\u8bc4\u5206\nprint('wind scale accuracy ratio:', wind.calc_wind_scale_accuracy_ratio()) # \u98ce\u7ea7\u51c6\u786e\u7387\nprint('wind speed accuracy ratio within 2m/s:', wind.calc_speed_accuracy_ratio()) # \u98ce\u901f\u51c6\u786e\u7387(\u9ed8\u8ba42m/s\u504f\u5dee\u4ee5\u5185)\nprint('wind speed accuracy radio within 3m/s:', wind.calc_speed_accuracy_ratio(limit=3)) # \u98ce\u901f\u51c6\u786e\u7387(\u6307\u5b9a3m/s\u504f\u5dee\u4ee5\u5185)\nprint('wind scale stronger ratio:', wind.calc_wind_scale_stronger_ratio()) # \u98ce\u7ea7\u504f\u5f3a\u7387\nprint('wind scale weaker ratio:', wind.calc_wind_scale_weaker_ratio()) # \u98ce\u7ea7\u504f\u5f31\u7387\n```\n\n## \u7b97\u6cd5\u89e3\u91ca\n\n\u5bf9\u4e8e\u672c\u9879\u76ee\u6240\u5b9e\u73b0\u7684\u5404\u7c7b\u6d4b\u8bc4\u7b97\u6cd5\u53ca\u5176\u89e3\u91ca\u3001\u516c\u5f0f\u7b49\u4fe1\u606f\uff0c\u53ef\u4ee5\u53c2\u8003 [cyeva \u8bf4\u660e\u6587\u6863](https://cyeva.readthedocs.io/zh_CN/latest/index.html) \u7684 [\u7b97\u6cd5\u6307\u6807](https://cyeva.readthedocs.io/zh_CN/latest/content/indicator.html) \u90e8\u5206\u3002\n",
"bugtrack_url": null,
"license": "Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. \"License\" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. \"Licensor\" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. \"Legal Entity\" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. \"You\" (or \"Your\") shall mean an individual or Legal Entity exercising permissions granted by this License. \"Source\" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. \"Object\" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. \"Work\" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). \"Derivative Works\" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. \"Contribution\" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, \"submitted\" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as \"Not a Contribution.\" \"Contributor\" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a \"NOTICE\" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets \"[]\" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same \"printed page\" as the copyright notice for easier identification within third-party archives. Copyright [2023] [Beijing ColorfulClouds Technology Co.,Ltd.] Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
"summary": "A package to evaluate weather forecast correction",
"version": "0.2.3",
"project_urls": {
"Documentation": "https://caiyunapp.github.io/cyeva",
"Issues": "https://github.com/caiyunapp/cyeva/issues",
"Source Code": "https://github.com/caiyunapp/cyeva"
},
"split_keywords": [
"atmospheric-science",
" mathmatics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ad3d192e031f446eff169812e53b7a34acd2aced4b9a1fc2b8b059a256a6bdfa",
"md5": "0846845569e9b235194e5157f379c91b",
"sha256": "8db24090e91eb01a8405ea3fb26e378ac1c9da20260db6a63303eaf13599e20d"
},
"downloads": -1,
"filename": "cyeva-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0846845569e9b235194e5157f379c91b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.10",
"size": 32403,
"upload_time": "2024-10-26T04:34:56",
"upload_time_iso_8601": "2024-10-26T04:34:56.589431Z",
"url": "https://files.pythonhosted.org/packages/ad/3d/192e031f446eff169812e53b7a34acd2aced4b9a1fc2b8b059a256a6bdfa/cyeva-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0a83ffb92ab66485b65276e103e2be62a69e261679ae63de9948a2cb7c175823",
"md5": "aaab3bba336c2240457c976b646da759",
"sha256": "72dafe74090dbe9eb4b964ce81a080e36a93f4b066f71693d605af1c0edc57ec"
},
"downloads": -1,
"filename": "cyeva-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "aaab3bba336c2240457c976b646da759",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.10",
"size": 115385,
"upload_time": "2024-10-26T04:34:57",
"upload_time_iso_8601": "2024-10-26T04:34:57.944925Z",
"url": "https://files.pythonhosted.org/packages/0a/83/ffb92ab66485b65276e103e2be62a69e261679ae63de9948a2cb7c175823/cyeva-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-26 04:34:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "caiyunapp",
"github_project": "cyeva",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cyeva"
}