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</code></pre> <p>一分为二的预测说:“是的,将会发生一个事件”,或者“否,该事件不会发生”。雨雾预报是是/否预报的常见示例。对于某些应用,可以指定阈值以分隔“是”和“否”,例如,风速大于50节。</p> <p>为了验证这种类型的预测,我们从列联表开始,该表显示“是”和“否”的预测和出现的频率(样本数)。预测(是或否)和观测值(是或否)的四种组合称为联合分布:</p> <pre><code> 命中-事件预测发生,并且确实发生了 漏报-事件预测未发生,但确实发生了 空报-发生事件预测,但未发生 正确的否定-事件预测不会发生,也不会发生</code></pre> <p>列联表的左下方给出了观测和预测的发生与未发生的总数,称为边际分布。<br /> <img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/33b4a2a6fd990436347b7d5379aa41a2?showdoc=.jpg" alt="" /><br /> 以下结合随机生成的测试数据,说明基于上述列联表计算的各种检验指标 </p> <pre><code class="language-python">ob = np.random.randn(10) fo2 = np.random.randn(2,10) fo1 = fo2[0,:] grade_list = [0.1,0.2,0.3,0.4,0.5]</code></pre> <pre><code class="language-python">ob</code></pre> <pre><code>array([-1.27434069, -0.09994792, -0.50700672, 1.14833988, 0.53031702, -1.25456782, 1.1937814 , -1.25392939, -1.46744966, 1.23203096])</code></pre> <pre><code class="language-python">fo2</code></pre> <pre><code>array([[ 0.10361068, 1.06847241, 0.0528819 , -0.24524423, -1.06866355, -0.5109932 , 0.54290017, -1.96892194, -1.26995501, 1.42088367], [-2.51175741, 1.36499562, -0.83989473, 0.942584 , 0.84199622, 1.04916377, -2.33702295, -0.8259776 , 0.33666246, -1.05469368]])</code></pre> <h1>命中、空报、漏报、正确否定</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc(ob, fo, grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">返回结果为一维或多维数组,最后一维长度为4,其内容依次为命中、空报、漏报、正确否定的样本数。 如果fo和ob的shape一致(即只有一种预报),返回2维数组,shape = (等级数,4); 如果fo比ob高出一维,len(grade_list) &gt;1时,则返回3维数组,shape = (预报成员数,等级数,4)。</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">hfmc_array0 = mem.hfmc(ob,fo1) #单个预报,默认单个等级时 hfmc_array0.shape</code></pre> <pre><code>(1, 4)</code></pre> <pre><code class="language-python">hfmc_array0 = hfmc_array0.reshape(1,1,4) hfmc_array0.shape</code></pre> <pre><code>(1, 1, 4)</code></pre> <pre><code class="language-python">hfmc_array1 = mem.hfmc(ob,fo1,grade_list) #单个预报,指定多个等级 hfmc_array1.shape</code></pre> <pre><code>(5, 4)</code></pre> <pre><code class="language-python">hfmc_array2 = mem.hfmc(ob,fo2) #多个预报,默认单个等级 hfmc_array2.shape</code></pre> <pre><code>(2, 1, 4)</code></pre> <pre><code class="language-python">hfmc_array3 = mem.hfmc(ob,fo2,grade_list) #多个预报,指定多个等级 hfmc_array3.shape</code></pre> <pre><code>(2, 5, 4)</code></pre> <pre><code class="language-python">print(ob) print(fo1) hfmc_array0 = mem.hfmc(ob,fo1) #阈值为 1e-30, compair = &amp;quot;&amp;gt;=&amp;quot; hfmc_array0</code></pre> <pre><code>[-1.27434069 -0.09994792 -0.50700672 1.14833988 0.53031702 -1.25456782 1.1937814 -1.25392939 -1.46744966 1.23203096] [ 0.10361068 1.06847241 0.0528819 -0.24524423 -1.06866355 -0.5109932 0.54290017 -1.96892194 -1.26995501 1.42088367] array([[2., 3., 2., 3.]])</code></pre> <pre><code class="language-python">hfmc_array0 = mem.hfmc(ob,fo1,compare = &amp;quot;&amp;lt;&amp;quot;) #阈值为 1e-30, compair = &amp;quot;&amp;lt;&amp;quot; hfmc_array0 # 由于判断事件发生的标准正好和上面的示例反过来了,因此命中,空报,漏报,正确无的样本数也正好是上面例子的倒转。 </code></pre> <pre><code>array([[3., 2., 3., 2.]])</code></pre> <p>在上述示例中,hfmc返回结果是一个数组,最后一维长度为4,倒数第2维长度为2,和grade_list对应。返回结果hfmc_array将在后续示例中被应用。</p> <h1>观测和预报发生率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob_fo_hr(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算观测和预报的发生率,happen rate: Observed(or Forecast) yes/Total </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">返回2维数组,shape = (1+预报成员数,等级数),其中result[0,:]是各等级观测的发生率,result[1:,:]是各等级预报场的发生率</td> </tr> </tbody> </table> <h1>观测和预报发生率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob_fo_hr_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算 happen rate: happen rate: Observed(or Forecast) yes/Total </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">数组,它比hfmc_array少了最后一维。但第一维长度等于预报成员数+1,其中result[0,:]是各等级观测的发生率,result[1:,:]是各等级预报场的发生率</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.ob_fo_hr(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>array([[0.4], [0.5]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([[0.4, 0.4, 0.4, 0.4, 0.4], [0.4, 0.3, 0.3, 0.3, 0.3]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr(ob,fo1,grade_list,compare = &amp;quot;&amp;lt;=&amp;quot;) #compair反转后,发生率约等于1-上例结果 </code></pre> <pre><code>array([[0.6, 0.6, 0.6, 0.6, 0.6], [0.6, 0.7, 0.7, 0.7, 0.7]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.4], [0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.4, 0.4, 0.4, 0.4, 0.4], [0.4, 0.3, 0.3, 0.3, 0.3], [0.5, 0.5, 0.5, 0.4, 0.4]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>array([[0.6], [0.5]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr_hfmc(hfmc_array1) #单个,指定多个等级</code></pre> <pre><code>array([[0.4, 0.4, 0.4, 0.4, 0.4], [0.4, 0.3, 0.3, 0.3, 0.3]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.4], [0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.ob_fo_hr_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.4, 0.4, 0.4, 0.4, 0.4], [0.4, 0.3, 0.3, 0.3, 0.3], [0.5, 0.5, 0.5, 0.4, 0.4]])</code></pre> <h1>观测和预报发生频次</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob_fo_hc(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">返回2维数组,shape = (1+预报成员数,等级数),其中result[0,:]是各等级观测的发生率,result[1:,:]是各等级预报场的发生样本数</td> </tr> </tbody> </table> <h1>观测和预报发生频次(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob_fo_hc_hfmc(hfmc_array)&lt;/font&gt;</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">数组,它比hfmc_array少了最后一维。但第一维长度等于预报成员数+1,其中result[0,:]是各等级观测的发生率,result[1:,:]是各等级预报场的发生样本数</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.ob_fo_hc(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>array([[4.], [5.]])</code></pre> <pre><code class="language-python">mem.ob_fo_hc_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[4., 4., 4., 4., 4.], [4., 3., 3., 3., 3.], [5., 5., 5., 4., 4.]])</code></pre> <h1>准确率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pc(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算accuracy: (Hits+ Correct negatives)/Total,反映被正确预报的样本占比</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>准确率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pc_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算 accuracy: (Hits+ Correct negatives)/Total,反映被正确预报的样本占比</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.pc(ob,fo1) #单个预报,默认单个等级,对要素值大于0的事件的预报准确率</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pc(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) # 对要素值小于等于0的事件的预报准确率</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pc(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pc(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.6, 0.7, 0.7, 0.7, 0.7])</code></pre> <pre><code class="language-python">mem.pc(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.6, 0.7, 0.7, 0.7, 0.7], [0.5, 0.5, 0.5, 0.6, 0.6]])</code></pre> <pre><code class="language-python">mem.pc_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pc_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.6, 0.7, 0.7, 0.7, 0.7])</code></pre> <pre><code class="language-python">mem.pc_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pc_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.6, 0.7, 0.7, 0.7, 0.7], [0.5, 0.5, 0.5, 0.6, 0.6]])</code></pre> <h1>命中率(召回率)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pod(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 又称基于原始数据计算hit rate: Hits/(Hits + Misses),反映观测的正样本中多少被预报 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等,则级返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>命中率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pod_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算hit rate:Hits/(Hits + Misses),反映观测的正样本中多少被预报 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.pod(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pod(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pod(ob,fo1,grade_list) #单个预报,指定单个等级</code></pre> <pre><code>array([0.5, 0.5, 0.5, 0.5, 0.5])</code></pre> <pre><code class="language-python">mem.pod(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5, 0.5, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5, 0.5]])</code></pre> <pre><code class="language-python">mem.pod_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pod_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5, 0.5, 0.5, 0.5, 0.5])</code></pre> <pre><code class="language-python">mem.pod_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pod_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5, 0.5, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5, 0.5]])</code></pre> <h1>成功率(精确率)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;sr(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算Success ratio : Hits/(Hits + False alarms),反映预报的正样本中实际发生的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>成功率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt; sr_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算Success ratio : Hits/(Hits + False alarms),反映预报的正样本中实际发生的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.sr(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.4</code></pre> <pre><code class="language-python">mem.sr(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.4], [0.4]])</code></pre> <pre><code class="language-python">mem.sr(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5 , 0.66666667, 0.66666667, 0.66666667, 0.66666667])</code></pre> <pre><code class="language-python">mem.sr(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.66666667, 0.66666667, 0.66666667, 0.66666667], [0.4 , 0.4 , 0.4 , 0.5 , 0.5 ]])</code></pre> <pre><code class="language-python">mem.sr_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.6</code></pre> <pre><code class="language-python">mem.sr_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5 , 0.66666667, 0.66666667, 0.66666667, 0.66666667])</code></pre> <pre><code class="language-python">mem.sr_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.4], [0.4]])</code></pre> <pre><code class="language-python">mem.sr_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.66666667, 0.66666667, 0.66666667, 0.66666667], [0.4 , 0.4 , 0.4 , 0.5 , 0.5 ]])</code></pre> <h1>报空率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pofd(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算Probability of false detection: False alarms/(False alarms + Correct negatives),反映观测负样本被预报为正样本的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为0</td> </tr> </tbody> </table> <h1>报空率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pofd_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算Probability of false detection: False alarms/(False alarms + Correct negatives),反映观测负样本被预报为正样本的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为0</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.pofd(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pofd(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pofd(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.33333333, 0.16666667, 0.16666667, 0.16666667, 0.16666667])</code></pre> <pre><code class="language-python">mem.pofd(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.33333333, 0.16666667, 0.16666667, 0.16666667, 0.16666667], [0.5 , 0.5 , 0.5 , 0.33333333, 0.33333333]])</code></pre> <pre><code class="language-python">mem.pofd_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.pofd_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.33333333, 0.16666667, 0.16666667, 0.16666667, 0.16666667])</code></pre> <pre><code class="language-python">mem.pofd_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.pofd_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.33333333, 0.16666667, 0.16666667, 0.16666667, 0.16666667], [0.5 , 0.5 , 0.5 , 0.33333333, 0.33333333]])</code></pre> <pre><code class="language-python">mem.far(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.6</code></pre> <pre><code class="language-python">mem.far(ob,fo2) #单个预报,指定多个等级</code></pre> <pre><code>array([[0.6], [0.6]])</code></pre> <pre><code class="language-python">mem.far(ob,fo1,grade_list) #多个预报,默认单个等级</code></pre> <pre><code>array([0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.far(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0.6 , 0.6 , 0.6 , 0.5 , 0.5 ]])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.4</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.6], [0.6]])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0.6 , 0.6 , 0.6 , 0.5 , 0.5 ]])</code></pre> <h1>空报率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;far(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算False alarm ratio: False alarms/(Hit + False alarms),反映预报的正样本中实际未发生的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为0</td> </tr> </tbody> </table> <h1>空报率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt; far_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算False alarm ratio: False alarms/(Hit + False alarms),反映预报的正样本中实际未发生的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.far(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.6</code></pre> <pre><code class="language-python">mem.far(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) #单个预报,默认单个等级,,其中当要素值小于等于0时记为事件发生 </code></pre> <pre><code>0.4</code></pre> <pre><code class="language-python">mem.far(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.6], [0.6]])</code></pre> <pre><code class="language-python">mem.far(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.far(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0.6 , 0.6 , 0.6 , 0.5 , 0.5 ]])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.4</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.6], [0.6]])</code></pre> <pre><code class="language-python">mem.far_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0.6 , 0.6 , 0.6 , 0.5 , 0.5 ]])</code></pre> <h1>漏报率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;mr(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算Miss ratio: Misses/(Hit + Misses),反映观测正样本被预报为负样本的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素为0到1的实数,完美预报对应值为0</td> </tr> </tbody> </table> <h1>漏报率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;mr_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算Miss ratio: Misses/(Hit + Misses),反映观测正样本被预报为负样本的比例 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。其中每个元素为0到1的实数,完美预报对应值为0</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.mr(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.mr(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) #单个预报,默认单个等级,,其中当要素值小于等于0时记为事件发生 </code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.mr(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.mr(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5, 0.5, 0.5, 0.5, 0.5])</code></pre> <pre><code class="language-python">mem.mr(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5, 0.5, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5, 0.5]])</code></pre> <pre><code class="language-python">mem.mr_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.5</code></pre> <pre><code class="language-python">mem.mr_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.5, 0.5, 0.5, 0.5, 0.5])</code></pre> <pre><code class="language-python">mem.mr_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.5], [0.5]])</code></pre> <pre><code class="language-python">mem.mr_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5, 0.5, 0.5, 0.5, 0.5], [0.5, 0.5, 0.5, 0.5, 0.5]])</code></pre> <h1>偏差</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算bias:(Hit + False alarms)/(Hit + Misses),反映预报的正样本数 和 观测的正样本数的比值 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。其中每个元素值为0到正无穷的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>偏差(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算bias:(Hit + False alarms)/(Hit + Misses),反映预报的正样本数 和 观测的正样本数的比值 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。 其中每个元素值为0到正无穷的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.bias(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>1.25</code></pre> <pre><code class="language-python">mem.bias(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) #单个预报,默认单个等级,,其中当要素值小于等于0时记为事件发生 </code></pre> <pre><code>0.8333333333333334</code></pre> <pre><code class="language-python">mem.bias(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[1.25], [1.25]])</code></pre> <pre><code class="language-python">mem.bias(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([1. , 0.75, 0.75, 0.75, 0.75])</code></pre> <pre><code class="language-python">mem.bias(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[1. , 0.75, 0.75, 0.75, 0.75], [1.25, 1.25, 1.25, 1. , 1. ]])</code></pre> <pre><code class="language-python">mem.bias_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.8333333333333334</code></pre> <pre><code class="language-python">mem.bias_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([1. , 0.75, 0.75, 0.75, 0.75])</code></pre> <pre><code class="language-python">mem.bias_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[1.25], [1.25]])</code></pre> <pre><code class="language-python">mem.bias_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[1. , 0.75, 0.75, 0.75, 0.75], [1.25, 1.25, 1.25, 1. , 1. ]])</code></pre> <h1>偏差幅度</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias_extend_linear(bias_array)&lt;/font&gt;</strong><br /> 计算bias偏离1的幅度,采用 (bias - 1)的绝对值表示 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias_array&lt;/font&gt;</strong></td> <td style="text-align: left;">任意维numpy数组,其中每个元素是bias值</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">numpy数组,shape和bias_array一致,0到正无穷,最优值为0</td> </tr> </tbody> </table> <h1>偏差幅度(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias_extend_log(bias_array)&lt;/font&gt;</strong><br /> 计算bias偏离1的幅度,采用 log(bias)的绝对值表示 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;bias_array&lt;/font&gt;</strong></td> <td style="text-align: left;">任意维numpy数组,其中每个元素是bias值</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">numpy数组,shape和bias_array一致,0到正无穷,最优值为0</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">bias_array1 = mem.bias(ob,fo1,grade_list) mem.bias_extend_linear(bias_array1)</code></pre> <pre><code>array([0. , 0.25, 0.25, 0.25, 0.25])</code></pre> <pre><code class="language-python">bias_array2 = mem.bias(ob,fo2,grade_list) mem.bias_extend_linear(bias_array2)</code></pre> <pre><code>array([[0. , 0.25, 0.25, 0.25, 0.25], [0.25, 0.25, 0.25, 0. , 0. ]])</code></pre> <pre><code class="language-python">mem.bias_extend_log(bias_array1)</code></pre> <pre><code>array([0. , 0.28768207, 0.28768207, 0.28768207, 0.28768207])</code></pre> <pre><code class="language-python">mem.bias_extend_log(bias_array2)</code></pre> <pre><code>array([[0. , 0.28768207, 0.28768207, 0.28768207, 0.28768207], [0.22314355, 0.22314355, 0.22314355, 0. , 0. ]])</code></pre> <h1>TS评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ts(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算ts: Hit /(Hit + Misses+ False alarms),反映预测的正样本与观察到的正样本对应的程度如何 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>TS评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ts_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算ts: Hit /(Hit + Misses+ False alarms),反映预测的正样本与观察到的正样本对应的程度如何 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.ts(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.2857142857142857</code></pre> <pre><code class="language-python">mem.ts(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) #单个预报,默认单个等级,其中当要素值小于等于0时记为事件发生 </code></pre> <pre><code>0.375</code></pre> <pre><code class="language-python">mem.ts(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.28571429], [0.28571429]])</code></pre> <pre><code class="language-python">mem.ts(ob,fo1,grade_list) #单个预报,指定多个等级 </code></pre> <pre><code>array([0.33333333, 0.4 , 0.4 , 0.4 , 0.4 ])</code></pre> <pre><code class="language-python">mem.ts(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.33333333, 0.4 , 0.4 , 0.4 , 0.4 ], [0.28571429, 0.28571429, 0.28571429, 0.33333333, 0.33333333]])</code></pre> <pre><code class="language-python">mem.ts_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.375</code></pre> <pre><code class="language-python">mem.ts_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.33333333, 0.4 , 0.4 , 0.4 , 0.4 ])</code></pre> <pre><code class="language-python">mem.ts_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.28571429], [0.28571429]])</code></pre> <pre><code class="language-python">mem.ts_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.33333333, 0.4 , 0.4 , 0.4 , 0.4 ], [0.28571429, 0.28571429, 0.28571429, 0.33333333, 0.33333333]])</code></pre> <h1>DTS评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;dts(ob, fo,grade_list=[1e-30])&lt;/font&gt;</strong><br /> 基于原始数据计算dts: 0.5<em>Hit /(Hit + Misses+ False_alarms)+0.5</em>correct_negatives/(correct_negatives + Misses+ False_alarms),这是对Ts评分的一种改进,能够更全面的反映二分类预报的准确性,也可以减小对空报的过多鼓励。 刘凑华, 林建, 代刊, 曹勇, 韦青. 2022. 一种适用于评估降水预报服务能力的评分方法. 暴雨灾害, 41(6): 712-719. doi: 10.12406/byzh.2021-203</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>DTS评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;dts_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算dts </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.dts(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.3055555555555555</code></pre> <pre><code class="language-python">mem.dts(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.30555556], [0.33035714]])</code></pre> <pre><code class="language-python">mem.dts(ob,fo1,grade_list) #单个预报,指定多个等级 </code></pre> <pre><code>array([0.30555556, 0.30555556, 0.2 , 0.25 , 0.25 ])</code></pre> <pre><code class="language-python">mem.dts(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.30555556, 0.30555556, 0.2 , 0.25 , 0.25 ], [0.33035714, 0.33035714, 0.23809524, 0.30555556, 0.2 ]])</code></pre> <pre><code class="language-python">mem.dts_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.3055555555555555</code></pre> <pre><code class="language-python">mem.dts_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.30555556, 0.30555556, 0.2 , 0.25 , 0.25 ])</code></pre> <pre><code class="language-python">mem.dts_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.30555556], [0.33035714]])</code></pre> <pre><code class="language-python">mem.dts_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.30555556, 0.30555556, 0.2 , 0.25 , 0.25 ], [0.33035714, 0.33035714, 0.23809524, 0.30555556, 0.2 ]])</code></pre> <h1>ETS评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ets(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算ets: (Hit-Hit_random) /(Hit + Misses+ False alarms - Hit_random),反映预测的正样本与观察到的正样本对应的程度如何, 其中扣除了随机预报产生的命中数量,Hit_random = Forecast yes × Observed yes / Total </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为-1/3到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>ETS评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ets_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算ets: (Hit-Hit_random) /(Hit + Misses+ False alarms - Hit_random),反映预测的正样本与观察到的正样本对应的程度如何, 其中扣除了随机预报产生的命中数量,Hit_random = Forecast yes × Observed yes / Total </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为-1/3到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.ets(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.ets(ob,fo1,compare = &amp;quot;&amp;lt;=&amp;quot;) #单个预报,默认单个等级,其中当要素值小于等于0时记为事件发生 </code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.ets(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.ets(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.09090909, 0.21052632, 0.21052632, 0.21052632, 0.21052632])</code></pre> <pre><code class="language-python">mem.ets(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.09090909, 0.21052632, 0.21052632, 0.21052632, 0.21052632], [0. , 0. , 0. , 0.09090909, 0.09090909]])</code></pre> <pre><code class="language-python">mem.ets_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.ets_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.09090909, 0.21052632, 0.21052632, 0.21052632, 0.21052632])</code></pre> <pre><code class="language-python">mem.ets_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.ets_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.09090909, 0.21052632, 0.21052632, 0.21052632, 0.21052632], [0. , 0. , 0. , 0.09090909, 0.09090909]])</code></pre> <h1>HK评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hk_yesorno(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> Hanssen and Kuipers discriminant,统计准确率相对于随机预报的技巧.HK评分通常用于<a href="https://www.showdoc.cc/meteva?page_id=3975612394328262">多分类预报评分</a>中,但二分类预报本身也是一种多分类预报,因此HK评分同样可以应用于二分类预报。该函数计算结果的物理含义和<a href="https://www.showdoc.cc/meteva?page_id=3975612394328262">多分类预报评分</a>中的hk(ob,fo,grade_list = None)是一样的,但grade_list的意义是不一样的,在hk函数中grade_list是将实数域划分为多个区间,而hk_yesorno中的grade_list是相对于每次只将实数域划分为两个区间,然后再套上一层循环。</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare 为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为-1到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>HK评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hk_yesorno_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算hk评分 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为-1到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.hk_yesorno(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.hk_yesorno(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.hk_yesorno(ob,fo1,grade_list) #单个预报,指定多个等级</code></pre> <pre><code>array([0.16666667, 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.hk_yesorno(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.16666667, 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0. , 0. , 0. , 0.16666667, 0.16666667]])</code></pre> <pre><code class="language-python">mem.hk_yesorno_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.hk_yesorno_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.16666667, 0.33333333, 0.33333333, 0.33333333, 0.33333333])</code></pre> <pre><code class="language-python">mem.hk_yesorno_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.hk_yesorno_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.16666667, 0.33333333, 0.33333333, 0.33333333, 0.33333333], [0. , 0. , 0. , 0.16666667, 0.16666667]])</code></pre> <h1>HSS评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hss_yesorno(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> Heidke skill score,统计准确率相对于随机预报的技巧. HSS评分通常用于<a href="https://www.showdoc.cc/meteva?page_id=3975612394328262">多分类预报评分</a>中,但二分类预报本身也是一种多分类预报,因此HSS评分同样可以应用于二分类预报。该函数计算结果的物理含义和<a href="https://www.showdoc.cc/meteva?page_id=3975612394328262">多分类预报评分</a>中的hs(ob,fo,grade_list = None)是一样的,但grade_list的意义是不一样的,在hss函数中grade_list是将实数域划分为多个区间,而hss_yesorno中的grade_list是相对于每次只将实数域划分为两个区间,然后再套上一层循环。</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为-1到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>HSS评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hss_yesorno_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算hk评分 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为-1到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.hss_yesorno(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.hss_yesorno(ob,fo2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.hss_yesorno(ob,fo1,grade_list) #单个预报,指定多个等级 </code></pre> <pre><code>array([0.16666667, 0.34782609, 0.34782609, 0.34782609, 0.34782609])</code></pre> <pre><code class="language-python">mem.hss_yesorno(ob,fo2,grade_list) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.16666667, 0.34782609, 0.34782609, 0.34782609, 0.34782609], [0. , 0. , 0. , 0.16666667, 0.16666667]])</code></pre> <pre><code class="language-python">mem.hss_yesorno_hfmc(hfmc_array0) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.hss_yesorno_hfmc(hfmc_array1) #单个预报,指定多个等级</code></pre> <pre><code>array([0.16666667, 0.34782609, 0.34782609, 0.34782609, 0.34782609])</code></pre> <pre><code class="language-python">mem.hss_yesorno_hfmc(hfmc_array2) #多个预报,默认单个等级</code></pre> <pre><code>array([[0.], [0.]])</code></pre> <pre><code class="language-python">mem.hss_yesorno_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.16666667, 0.34782609, 0.34782609, 0.34782609, 0.34782609], [0. , 0. , 0. , 0.16666667, 0.16666667]])</code></pre> <h1>odds_ratio</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;odds_ratio(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算odds_ratio: (Hit × Correct negatives) /(Mis ×False alarms) </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为0到无穷大的实数,值越大,技巧越高</td> </tr> </tbody> </table> <h1>odds_ratio(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;odds_ratio_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算odds_ratio评分 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为0到无穷大的实数,值越大,技巧越高</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.odds_ratio(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.9999999983333333</code></pre> <pre><code class="language-python">mem.odds_ratio_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[2. , 4.99999998, 4.99999998, 4.99999998, 4.99999998], [1. , 1. , 1. , 2. , 2. ]])</code></pre> <h1>ORSS评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;orss(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;)&lt;/font&gt;</strong><br /> 基于原始数据计算orss: (Hit × Correct negatives - Mis ×False alarms)/(Hit × Correct negatives - Mis ×False alarms) </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为-1到1的实数,完美值为1</td> </tr> </tbody> </table> <h1>ORSS(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;orss_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算orss评分 </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为-1到1的实数,完美值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.orss(ob,fo1) #单个预报,默认单个等级</code></pre> <pre><code>0.0</code></pre> <pre><code class="language-python">mem.orss_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.33333333, 0.66666667, 0.66666667, 0.66666667, 0.66666667], [0. , 0. , 0. , 0.33333333, 0.33333333]])</code></pre> <h1>Fscore评分</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fscore(ob, fo,grade_list=[1e-30],compare = &quot;&gt;=&quot;,belta=1)&lt;/font&gt;</strong><br /> 基于原始数据计算fscore=(1+belta^2) <em> (pod </em> sr)/(belta^2 <em> sr + pod) = (1+belta^2) </em> hit/((1+belta^2) <em> hit + belta^2 </em> Mis + False alarms) </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;"><strong>grade_list</strong></td> <td style="text-align: left;">该参数用于对连续变量做多种等级阈值的二分类检验,其中包含多个事件是否记录为发生的判断阈值,记其中一个阈值为g,则判断为事件发生的条件是要素值 &gt;= g。该参数缺省时列表中只包含一个取值为1e-30的阈值,由于气象要素精度通常比该缺省值大,因此它相当于将 &gt;0 作为事件发生的判据</td> </tr> <tr> <td style="text-align: left;"><strong>compare</strong></td> <td style="text-align: left;">比较方法,可选项包括&quot;&gt;=&quot;,&quot;&gt;&quot;,&quot;&lt;=&quot;,&quot;&lt;&quot;, 是要素原始值和阈值对比的方法,默认方法为&quot;&gt;=&quot;,即原始值大于等于阈值记为1,否则记为0,当compare为&quot;&lt;=&quot;时,原始值小于等于阈值的站点记为1, 这在基于能见度标记大雾事件、低温事件或降温事件等场景中可以用到</td> </tr> <tr> <td style="text-align: left;"><strong>belta</strong></td> <td style="text-align: left;">当belta=1时,称为F1-score,这时,精确率sr和召回率pod都很重要,权重相同。当有些情况下,我们认为精确率sr更重要些,那就调整β的值小于1,如果我们认为召回率pod更重要些,那就调整β的值大于1</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报)当仅有一个等级,则返回结果为实数,当有多个等级,则返回1维数组,shape = (等级数);如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,等级数)。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>Fscore评分(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fscore_hfmc(hfmc_array,belta=1)&lt;/font&gt;</strong><br /> 基于中间结果计算fscore </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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;"><strong>belta</strong></td> <td style="text-align: left;">当belta=1时,称为F1-score,这时,精确率sr和召回率pod都很重要,权重相同。当有些情况下,我们认为精确率sr更重要些,那就调整β的值小于1,如果我们认为召回率pod更重要些,那就调整β的值大于1</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.fscore(ob,fo1,belta = 2) #单个预报,默认单个等级</code></pre> <pre><code>0.47619047619047616</code></pre> <pre><code class="language-python">mem.fscore_hfmc(hfmc_array3) #多个预报,指定多个等级</code></pre> <pre><code>array([[0.5 , 0.57142857, 0.57142857, 0.57142857, 0.57142857], [0.44444444, 0.44444444, 0.44444444, 0.5 , 0.5 ]])</code></pre> <p>晴雨预报也是二分类预报,但由于降水观测存在T量概念,在业务检验中对T量降水样本的处理和普通的二分类预报有所不同。具体的检验列联表可以用下图表示:<br /> <img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/22bf30d1ab2befc3ca8065b32528191c" alt="" /> 据此,晴雨预报的准确率计算公式也和普通的二分类检验的准确率有所差别,在本函数库中有针对性的增加概率晴雨准确率的计算模块,它包括直接计算函数和中间统计量计算函数。</p> <h1>晴雨预报的命中、空报、漏报、正确否定</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_of_sun_rain((ob, fo)&lt;/font&gt;</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报),返回结果为一维数组;如果fo比ob高出一维,则返回2维数组,shape = (预报成员数,4)。最内层维度长度为4的一维numpy数组,其中最内层维度内容依次为根据晴雨(雪)检验评定表计算出的命中、空报、漏报、正确否定的样本数</td> </tr> </tbody> </table> <h1>晴雨准确率</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pc_of_sun_rain(ob, fo)&lt;/font&gt;</strong><br /> 基于原始数据计算accuracy: (Hits+ Correct negatives)/Total,反映被正确预报的样本占比</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;ob&lt;/font&gt;</strong></td> <td style="text-align: left;">实况数据, 任意维numpy数组</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;fo&lt;/font&gt;</strong></td> <td style="text-align: left;">fo比Ob.shape多一维或者保持一致,fo.shape低维与ob.shape保持一致</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">如果fo和ob的shape一致(即只有一种预报),返回结果为实数;如果fo比ob高出一维,则返回1维数组,长度等于预报成员数。其中每个元素为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <h1>晴雨准确率(并行)</h1> <p><strong>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;pc_of_sun_rain_hfmc(hfmc_array)&lt;/font&gt;</strong><br /> 基于中间结果计算 accuracy: (Hits+ Correct negatives)/Total,反映被正确预报的样本占比</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>&lt;font face=&quot;黑体&quot; color=blue size = 5&gt;hfmc_array&lt;/font&gt;</strong></td> <td style="text-align: left;">包含检验中间结果的多维数组,其中最后一维长度为4,分别记录了命中、空报、漏报、正确否定的样本数,它通常是hfmc函数的计算结果,或者计算结果的累加</td> </tr> <tr> <td style="text-align: left;">&lt;font face=&quot;黑体&quot; color=blue size=5&gt;return&lt;/font&gt;</td> <td style="text-align: left;">整数或数组,它比hfmc_array少了最后一维。每个元素值为0到1的实数,完美预报对应值为1</td> </tr> </tbody> </table> <p><strong>调用示例:</strong> </p> <pre><code class="language-python">mem.pc_of_sun_rain(ob,fo1) #单个预报</code></pre> <pre><code>0.6</code></pre> <pre><code class="language-python">mem.pc_of_sun_rain(ob,fo2) #多个预报</code></pre> <pre><code>array([0.6, 0.5])</code></pre> <pre><code class="language-python">hfmc_sr = mem.hfmc_of_sun_rain(ob,fo1) mem.pc_of_sun_rain_hfmc(hfmc_sr) #单个预报</code></pre> <pre><code>0.6</code></pre> <pre><code class="language-python">hfmc_sr = mem.hfmc_of_sun_rain(ob,fo2) #多个预报 mem.pc_of_sun_rain_hfmc(hfmc_sr)</code></pre> <pre><code>array([0.6, 0.5])</code></pre> <p>在以上示例中,观测和预报的数据规模较小,可以直接调用评分函数计算相应评分,然而有些情况下待检验的数据太大不能整体存入一个numpy数组中,或者不方便整体存入一个numpy数组中,就不能调用上面的方式调用评分函数, 此时可以采用本函数库中中间结果统计函数来实现分块计算或并行计算的方式来实现计算。其检验步骤如下:<br /> <strong><em>步骤1:根据需要将分块数据逐一输入到中间结果计算函数</em></strong><br /> <strong><em>步骤2:将中间结果进行累加或合并</em></strong><br /> <strong><em>步骤3:根据累加或合并的中间结果计算检验指标</em></strong><br /> 通常上述计算中步骤1是最耗费计算资源,为了提高效率步骤1也可以采用<strong>并行</strong>的方式执行。此外,步骤1执行的结果也可<strong>输出到文件</strong>中,在后续的检验可以从中读入部分中间结果执行后续步骤,从而可以实现各种方式的分组检验,大大提高检验计算效率。 同时,在预报检验经常需要进行分组检验,获得不同类别预报的评分指标并进行对比。此时可以应用上述基于中间结果的检验函数对多维中间统计量的整体计算能力来简化代码的复杂度。<br /> <strong>示例如下:</strong></p> <pre><code class="language-python">day_count = 100 model_count = 3 grade_list = [0.1,0.2,0.3,0.4,0.5] ob_ = np.random.randn(day_count,1000) fo_ = np.random.randn(model_count,day_count,1000) hfmc_array = np.zeros((model_count,len(grade_list),4)) hfmc_sumrain = np.zeros((model_count,4)) for i in range(day_count): ob1_ = ob_[i,:] fo1_ = fo_[:,i,:] hfmc_array += mem.hfmc(ob1_,fo1_,grade_list) #计算1部分中间结果并累加到总体的中间结果中 hfmc_sumrain += mem.hfmc_of_sun_rain(ob1_,fo1_) #为晴雨预报准确率统计中间结果,并累加</code></pre> <pre><code class="language-python">mem.pc_of_sun_rain_hfmc(hfmc_sumrain) #3个预报</code></pre> <pre><code>array([0.52306, 0.5207 , 0.52016])</code></pre> <pre><code class="language-python">mem.pc_hfmc(hfmc_array) #3个预报,5个等级</code></pre> <pre><code>array([[0.50544, 0.5152 , 0.52949, 0.54993, 0.57525], [0.50266, 0.51171, 0.52705, 0.54857, 0.57311], [0.50195, 0.51176, 0.52769, 0.54836, 0.57367]])</code></pre> <pre><code class="language-python">mem.ts_hfmc(hfmc_array) #3个预报,5个等级</code></pre> <pre><code>array([[0.30094562, 0.26939538, 0.23858303, 0.21050046, 0.18547567], [0.29808764, 0.26526528, 0.23548809, 0.20797586, 0.18157592], [0.29821471, 0.26624587, 0.2374225 , 0.20909218, 0.18322892]])</code></pre> <pre><code class="language-python">mem.bias_hfmc(hfmc_array) #3个预报,5个等级</code></pre> <pre><code>array([[1.0004347 , 1.0019489 , 1.00217124, 1.00630906, 1.00854506], [0.99908714, 0.99850267, 0.99939833, 1.00177351, 1.00243681], [1.00249951, 1.00251931, 1.00489183, 1.00738479, 1.0066606 ]])</code></pre> <p>以上只是展示了分类检验的维度为1的情况,实际上上述思路可以扩展至任意高维的情况。熟练使用中间统计量计算和合并方法,基于中间统计量整体计算分类问题下的检验指标数组,是提高代码编写效果的关键。上述检验函数的内部也都采用了numpy的整体计算方式实现,在计算效率上进行了最大程度的优化。</p>

页面列表

ITEM_HTML