meteva

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


目标距离检验

<p>[TOC]</p> <pre><code class="language-python">%matplotlib inline %load_ext autoreload %autoreload 2 import meteva.base as meb import meteva.method as mem import meteva.perspact as mps import numpy as np import pandas as pd import datetime import meteva</code></pre> <pre><code class="language-python">ob_array = np.zeros((10, 12)) fo_array = np.zeros((10, 12)) ob_array[3:5, 2:7] = 1 fo_array[2:4, 6:9] = 1 name_list_dict={&amp;quot;member&amp;quot;:[&amp;quot;OBS&amp;quot;,&amp;quot;FST&amp;quot;],&amp;quot;y&amp;quot;:np.arange(10),&amp;quot;x&amp;quot;:np.arange(12)} meb.mesh(np.array([ob_array,fo_array]),name_list_dict = name_list_dict,ncol = 2)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=1c046eefbff5443d0350b665cdb81ba7&amp;amp;file=file.png" alt="" /></p> <h2>Mean Error Distance</h2> <p>计算观测目标和预报目标的平均距离</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>Mean_Error_Distance(X, Y):</strong>&lt;/font&gt;</p> <table> <thead> <tr> <th style="text-align: left;">参数</th> <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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> </tbody> </table> <p>&lt;font face=&quot;黑体&quot; color=green size=4&gt;<strong>返回结果内容说明</strong>&lt;/font&gt; </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=green size=3&gt;medMiss&lt;/font&gt;</strong></td> <td style="text-align: left;">观测目标格点到预报目标的距离的平均</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=green size=3&gt;medFalseAlarm&lt;/font&gt;</strong></td> <td style="text-align: left;">预报目标格点到观测目标的距离的平均</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.Mean_Error_Distance(ob_array,fo_array) print(res)</code></pre> <pre><code>{'medMiss': 2.1935664825658927, 'medFalseAlarm': 1.2750469233121475}</code></pre> <h2>Mean Square Error Distance</h2> <p>计算观测目标和预报目标的平均距离</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>Mean_Square_Error_Distance(X, Y):</strong>&lt;/font&gt;</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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> </tbody> </table> <p>&lt;font face=&quot;黑体&quot; color=green size=4&gt;<strong>返回结果内容说明</strong>&lt;/font&gt; </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=green size=3&gt;medMiss&lt;/font&gt;</strong></td> <td style="text-align: left;">(观测目标格点到预报目标的距离^2)的平均</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=green size=3&gt;medFalseAlarm&lt;/font&gt;</strong></td> <td style="text-align: left;">(预报目标格点到观测目标的距离^2)的平均</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.Mean_Square_Error_Distance(ob_array,fo_array) print(res)</code></pre> <pre><code>{'msdMiss': 6.5, 'msdFalseAlarm': 2.166666666666667}</code></pre> <h2>Minimum Separation Between Boundaries</h2> <p>计算观测目标和预报目标的平均距离</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>Minimum_Separation_Between_Boundaries(X, Y):</strong>&lt;/font&gt; </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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</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;">观测目标格点到预报目标的距离的最小值</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.Minimum_Separation_Between_Boundaries(ob_array,fo_array) print(res)</code></pre> <pre><code>0.0</code></pre> <h2>Pratt’s Figure of Merit</h2> <p>计算观测目标和预报目标的平均距离</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>Pratts_Figure_of_Merit(X, Y):</strong>&lt;/font&gt;</p> <table> <thead> <tr> <th style="text-align: left;">参数</th> <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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</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;">(1/(观测目标格点到预报目标距离^2+1))的均值</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.Pratts_Figure_of_Merit(ob_array,fo_array) print(res)</code></pre> <pre><code>0.6813769076926971</code></pre> <h2>partial Hausdorff Measure</h2> <p>步骤1. 采用部分1所述方法,计算所有观测目标上所有点到预报目标的距离 disArray_ob_to_fo,<br /> 步骤2. 采用部分1所述方法,计算所有预报目标上所有点到观测目标的距离 disArray_fo_to_ob,<br /> 步骤3. 取disArray_ob_to_fo 第k大值 和 disArray_fo_to_ob第k大值中的最大值</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>partial_Hausdorff_Measure(X, Y,k=4):</strong>&lt;/font&gt;</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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;k&lt;/font&gt;</strong></td> <td style="text-align: left;">在计算Hausdorff距离是排除前k个距离最大值</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;">排除异常值的Hausdorff 距离</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.partial_Hausdorff_Measure(ob_array,fo_array) print(res)</code></pre> <pre><code>2.23606797749979</code></pre> <h2>modified Hausdorff Measure</h2> <p>步骤1. 确定一个能够覆盖观测和预报目标的最小矩形网格,记其网格数为N<br /> 步骤2. 采用部分1所述方法,计算所有格点到观测目标(面)的距离disArray_to_ob, 长度为N的1维矩阵<br /> 步骤3. 采用部分1所述方法,计算所有格点到预报目标(面)的距离disArray_to_fo, 长度为N的1维矩阵<br /> 步骤4. 计算每个格点的两种距离的差的绝对值 |disArray_to_ob - disArray_to_fo|,长度为N的1维矩阵<br /> 步骤5. 取步骤4所得序列的第k大值;</p> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>modified_Hausdorff_Measure(X, Y,k):</strong>&lt;/font&gt;</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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;k&lt;/font&gt;</strong></td> <td style="text-align: left;">在计算Hausdorff距离是排除前k个距离最大值</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;">距离</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">res = mem.space.modified_Hausdorff_Measure(ob_array,fo_array,k = 10) print(res)</code></pre> <pre><code>3.605551275463989</code></pre> <h2>Hausdorff metri</h2> <p>&lt;font face=&quot;黑体&quot; color=Blue size=3&gt;<strong>location_performance(X, Y, which_stats=None, alpha=0.1, k=4, a=None):</strong>&lt;/font&gt;</p> <table> <thead> <tr> <th style="text-align: left;">参数</th> <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;X&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>&lt;font face=&quot;黑体&quot; color=Blue size=5&gt;Y&lt;/font&gt;</strong></td> <td style="text-align: left;">二维矩阵</td> </tr> <tr> <td style="text-align: left;"><strong>which_stats</strong></td> <td style="text-align: left;">which_methos 表示需要计算的统计量,类型为list,list可选元素及计算值的含义为以下</td> </tr> <tr> <td style="text-align: left;"><em>qdmapdiff</em></td> <td style="text-align: left;">距离矩阵的quantile或者ranking值 The quantile of the difference in distance maps</td> </tr> <tr> <td style="text-align: left;"><em>med</em></td> <td style="text-align: left;">平均距离误差 The mean error distance</td> </tr> <tr> <td style="text-align: left;"><em>msd</em></td> <td style="text-align: left;">距离标准差 The mean square error distance</td> </tr> <tr> <td style="text-align: left;"><em>fom</em></td> <td style="text-align: left;">Pratt's figure of merit 详细公式参考 Pratt, W. K. (1977) Digital Image Processing. John Wiley and Sons, New York. Abdou, I. E. and Pratt, W. K. (1979) Quantitative design and evaluation of enhancement/thresholding edge detectors. Proc. IEEE, 67, 753–763.</td> </tr> <tr> <td style="text-align: left;"><em>minsep</em></td> <td style="text-align: left;">Minimum separation distance between boundaries 在矩阵中发生事件的位置,另一矩阵的最小距离</td> </tr> <tr> <td style="text-align: left;"><strong>alpha</strong></td> <td style="text-align: left;">数值,Pratt's figure of merit (FOM) 计算时使用的比例常数,仅对fom生效</td> </tr> <tr> <td style="text-align: left;"><strong>k</strong></td> <td style="text-align: left;">数值,用于计算距离矩阵的ranking或quantile,小于1大于0时则为quantile,否则为ranking,此时需要大于1且为整数且小于矩阵元素个数</td> </tr> <tr> <td style="text-align: left;"><strong>a</strong></td> <td style="text-align: left;">没有使用,用于适配locmeasures2d的调用</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">x = np.zeros((10, 12)) y = np.zeros((10, 12)) x[3:5, 2:7] = 1 y[2:4, 6:9] = 1 res = mem.space.location_performance(x,y) print(res) </code></pre> <pre><code>{'qdmapdiff': 4.0, 'medMiss': 2.1935664825658927, 'medFalseAlarm': 1.2750469233121475, 'msdMiss': 6.5, 'msdFalseAlarm': 2.166666666666667, 'ph': 2.23606797749979, 'fom': 0.6813769076926971, 'minsep': 0.0}</code></pre> <pre><code class="language-python"></code></pre>

页面列表

ITEM_HTML