meteva

提供气象产品检验相关python程序


表格型检验产品

<p>[TOC]</p> <pre><code class="language-python">%matplotlib inline %load_ext autoreload %autoreload 2 import meteva.method as mem import numpy as np import copy</code></pre> <pre><code>Bad key "text.kerning_factor" on line 4 in s:\ProgramData\Anaconda3\lib\site-packages\matplotlib\mpl-data\stylelib\_classic_test_patch.mplstyle. You probably need to get an updated matplotlibrc file from http://github.com/matplotlib/matplotlib/blob/master/matplotlibrc.template or from the matplotlib source distribution s:\ProgramData\Anaconda3\lib\site-packages\statsmodels\tools\_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead. import pandas.util.testing as tm</code></pre> <p><strong><em>通过随机函数生成测试数据,用于后续检验函数调用示例</em></strong></p> <pre><code class="language-python">ob_p = np.random.rand(1000) ob= np.zeros(ob_p.shape) ob[ob_p&gt;0.5] = 1 #设定有一部分观测被确定为正例(1),一部分被确定为负例(0) error1 = np.abs(np.random.randn(5,1000)) * 0.3 #在观测的基础上加上一个概率扰动构建概率预报 error0 = np.abs(np.random.randn(5,1000)) * 0.3 error1[error1&gt;1] = 1 error0[error0&gt;1] = 1 fo = np.zeros((5,1000)) + ob fo[fo==1] = 1 - error1[fo==1] #对于观测正例,概率预报在1左右 fo[fo==0] = error0[fo ==0] #对于观测负例,概率预报在0左右 fo_name_list = ["ECMWF","NCEP","T639","SCMOC","GRAPES","GRAPES_MESO","GRAPES-3KM","SHANGHAI","GUANGDONG"]</code></pre> <p>在概率预报的检验中,同样存在并行计算的需求,因此也需要统计各类检验指标或图形产品所需的中间结果。下面的函数可 为多个检验指标函数提供的输入。 </p> <h1>区分能力表</h1> <p><strong><font face="黑体" color=blue size = 5>hnh(Ob,Fo,grade_count = 10,member_list=None, save_path=None)</font></strong><br /> 统计预报概率为不同区间下观测样本事件发生和不发生的样本数。</p> <table> <thead> <tr> <th style="text-align: left;">参数</th> <th style="text-align: left;">说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size=5>ob</font></strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size=5>fo</font></strong></td> <td style="text-align: left;">预测数据, 任意维numpy数组,Fo.shape 比Ob.shape多一维或者保持一致,Fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_count</strong></td> <td style="text-align: left;">区分等级数 大于1的整数,它0 - 1 的概率预报区间划分为grade_count等分。缺省值为10</td> </tr> <tr> <td style="text-align: left;"><strong>member_list</strong></td> <td style="text-align: left;">预报成员的名称列表</td> </tr> <tr> <td style="text-align: left;"><strong>save_path</strong></td> <td style="text-align: left;">数据以excel格式输出到该路径,缺省时不输出</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size=5>return</font></strong></td> <td style="text-align: left;">当fo和ob的shape一致时返回grade_count × 2 的numpy数组,其中元素[i,0]和[i,1]分别为预报概率在第i个区间,观测发生和不发生的样本数。当fo比ob高出一维时,返回三维数组,其shape = (预报成员数) × grade_count × 2</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">hnh_array1 = mem.hnh(ob,fo[0,:],10,save_path = r"H:\test_data\output\method\probability\t1.xlsx")</code></pre> <pre><code>列联表已以excel表格形式保存至H:\test_data\output\method\probability\t1.xlsx</code></pre> <p>上述运行结果excel的截图形式如下:</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/ec479f19551308aac79255e7fef00928?showdoc=.jpg" alt="" /></p> <pre><code class="language-python">hnh_array2 = mem.hnh(ob,fo,10,member_list = fo_name_list,save_path = r"H:\test_data\output\method\probability\t2.xlsx")</code></pre> <pre><code>列联表已以excel表格形式保存至H:\test_data\output\method\probability\t2.xlsx</code></pre> <p>上述运行结果excel的截图形式如下,其中包含四个sheet: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/e1634dfc4e51656da9903b0b1b4424d5?showdoc=.jpg" alt="" /></p> <pre><code class="language-python"></code></pre>

页面列表

ITEM_HTML