meteva

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


运算

<p>[TOC]</p> <pre><code class="language-python">%matplotlib inline %load_ext autoreload %autoreload 2 import meteva.base as meb import pandas as pd import numpy as np import datetime import copy</code></pre> <pre><code class="language-python">#meb.station_国家站是程序库中内置的micaps3类文件的路径名 station = meb.read_station(meb.station_国家站) #读取micaps3类文件获取站点,print(meb.station_国家站) print(station)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2099-01-01 08:00:00 0 50136 122.52 52.97 0 1 0 2099-01-01 08:00:00 0 50137 122.37 53.47 0 2 0 2099-01-01 08:00:00 0 50246 124.72 52.35 0 3 0 2099-01-01 08:00:00 0 50247 123.57 52.03 0 4 0 2099-01-01 08:00:00 0 50349 124.40 51.67 0 ... ... ... ... ... ... ... ... 2406 0 2099-01-01 08:00:00 0 59945 109.70 18.65 0 2407 0 2099-01-01 08:00:00 0 59948 109.58 18.22 0 2408 0 2099-01-01 08:00:00 0 59951 110.33 18.80 0 2409 0 2099-01-01 08:00:00 0 59954 110.03 18.55 0 2410 0 2099-01-01 08:00:00 0 59981 112.33 16.83 0 [2411 rows x 7 columns]</code></pre> <pre><code class="language-python">filename = r"H:\test_data\input\meb\m3.txt" sta = meb.read_stadata_from_micaps3(filename) #在其他参数缺省的情况下,站点列表、时间和层次信息均根据文件内容设置,时效设置为0 print(sta)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2020-01-03 20:00:00 0 57671 112.37 28.85 1.3 1 0 2020-01-03 20:00:00 0 57845 109.78 26.17 5.4 2 0 2020-01-03 20:00:00 0 57466 111.75 30.46 0.1 3 0 2020-01-03 20:00:00 0 57842 109.72 26.88 0.8 4 0 2020-01-03 20:00:00 0 57584 113.09 29.38 1.3 .. ... ... ... ... ... ... ... 561 0 2020-01-03 20:00:00 0 57589 113.88 29.27 2.2 562 0 2020-01-03 20:00:00 0 57583 113.97 29.92 4.2 563 0 2020-01-03 20:00:00 0 55690 91.95 27.98 2.3 564 0 2020-01-03 20:00:00 0 55597 91.68 29.03 0.0 565 0 2020-01-03 20:00:00 0 56434 97.47 28.67 0.2 [566 rows x 7 columns]</code></pre> <h1>将站点数据赋值到统一站表上</h1> <p><font face="黑体" color=blue size = 5><strong>put_stadata_on_station(sta,station)</strong></font><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>sta</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>station</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a>,站点数据,其中id,lon,lat列被采用</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a>,站点数据,id,lon,lat和station中一致,且排列顺序一致。level,time,dtime则采用sta中相同id对应的值,数据列中如果某个id在sta中有对应行,则采用sta的数值,否则采用station中的数值。</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">sta1 = meb.comp.put_stadata_on_station(sta,station) print(sta1)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2020-01-03 20:00:00 0 50136 122.52 52.97 0.0 1 0 2020-01-03 20:00:00 0 50137 122.37 53.47 0.0 2 0 2020-01-03 20:00:00 0 50246 124.72 52.35 0.0 3 0 2020-01-03 20:00:00 0 50247 123.57 52.03 0.0 4 0 2020-01-03 20:00:00 0 50349 124.40 51.67 0.0 ... ... ... ... ... ... ... ... 2406 0 2020-01-03 20:00:00 0 59945 109.70 18.65 0.0 2407 0 2020-01-03 20:00:00 0 59948 109.58 18.22 0.0 2408 0 2020-01-03 20:00:00 0 59951 110.33 18.80 0.0 2409 0 2020-01-03 20:00:00 0 59954 110.03 18.55 0.0 2410 0 2020-01-03 20:00:00 0 59981 112.33 16.83 0.0 [2411 rows x 7 columns]</code></pre> <h1>站点数据相加</h1> <p><font face="黑体" color=blue size = 5><strong>add_on_level_time_dtime_id(sta1,sta2,how = &quot;left&quot;,default = None)</strong></font><br /> 将sta1,sta2基于level、time、dtime、id坐标对齐后再相加 </p> <h1>站点数据相减</h1> <p><font face="黑体" color=blue size = 5><strong>minus_on_level_time_dtime_id(sta1,sta2,how = &quot;left&quot;,default = None)</strong></font><br /> 将sta1,sta2基于level、time、dtime、id坐标对齐后再相减 </p> <h1>站点数据相乘</h1> <p><font face="黑体" color=blue size = 5><strong>mutiply_on_level_time_dtime_id(sta1,sta2,how = &quot;left&quot;,default = None)</strong></font><br /> 将sta1,sta2基于level、time、dtime、id坐标对齐后再相乘 </p> <h1>站点数据取较大值</h1> <p><font face="黑体" color=blue size = 5><strong>max_on_level_time_dtime_id(sta1,sta2,how = &quot;left&quot;,default = None)</strong></font><br /> 将sta1,sta2基于level、time、dtime、id坐标对齐后再取两者较大值 </p> <h1>站点数据取较小值</h1> <p><font face="黑体" color=blue size = 5><strong>min_on_level_time_dtime_id(sta1,sta2,how = &quot;left&quot;,default = None)</strong></font><br /> 将sta1,sta2基于level、time、dtime、id坐标对齐后再取两者较小值 </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>sta1</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>sta2</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>how</strong></td> <td style="text-align: left;">how = &quot;left&quot;时返回的数据表和sta1一致,how = &quot;right&quot;时返回的数据表和 sta2一致,how = &quot;inner&quot;时,返回结果是两个数据表的交集,how = &quot;outer&quot;时返回结果是两个数据表的并集</td> </tr> <tr> <td style="text-align: left;"><strong>default</strong></td> <td style="text-align: left;">当返回结果中的某些站点在sta1,sta2中缺失了,就讲缺失的部分先赋值成defalut后再运算</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a>,站点数据运行后的结果</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">filename = r"H:\test_data\input\meb\m1.txt" sta_temp = meb.read_stadata_from_micaps1_2_8(filename,meb.m1_element_column.温度) #读取温度观测 sta_temp = meb.sele_by_para(sta_temp,value=[-100,100]) #仅保留取值合理的站点 print(sta_temp)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2018-08-01 08:00:00 0 1009 89.49 3.99 27.9 2 0 2018-08-01 08:00:00 0 29645 86.22 55.25 8.1 3 0 2018-08-01 08:00:00 0 28593 74.63 56.10 15.1 5 0 2018-08-01 08:00:00 0 36022 80.33 52.02 9.5 6 0 2018-08-01 08:00:00 0 29209 77.22 57.81 11.0 ... ... ... ... ... ... ... ... 4072 0 2018-08-01 08:00:00 0 48679 103.67 1.63 24.4 4073 0 2018-08-01 08:00:00 0 16364 16.37 38.76 18.4 4074 0 2018-08-01 08:00:00 0 16415 14.87 38.58 24.1 4075 0 2018-08-01 08:00:00 0 16081 9.26 45.46 26.7 4076 0 2018-08-01 08:00:00 0 16314 16.66 40.68 22.9 [3961 rows x 7 columns]</code></pre> <pre><code class="language-python">filename = r"H:\test_data\input\meb\m1.txt" sta_dpt = meb.read_stadata_from_micaps1_2_8(filename,meb.m1_element_column.露点) #读取露点观测 sta_dpt = meb.sele_by_para(sta_dpt,value=[-100,100]) #仅保留取值合理的站点 print(sta_dpt)</code></pre> <pre><code> level time dtime id lon lat data0 2 0 2018-08-01 08:00:00 0 29645 86.22 55.25 8 3 0 2018-08-01 08:00:00 0 28593 74.63 56.10 13 5 0 2018-08-01 08:00:00 0 36022 80.33 52.02 7 6 0 2018-08-01 08:00:00 0 29209 77.22 57.81 9 7 0 2018-08-01 08:00:00 0 98132 121.85 20.80 27 ... ... ... ... ... ... ... ... 4072 0 2018-08-01 08:00:00 0 48679 103.67 1.63 24 4073 0 2018-08-01 08:00:00 0 16364 16.37 38.76 17 4074 0 2018-08-01 08:00:00 0 16415 14.87 38.58 23 4075 0 2018-08-01 08:00:00 0 16081 9.26 45.46 24 4076 0 2018-08-01 08:00:00 0 16314 16.66 40.68 17 [3905 rows x 7 columns]</code></pre> <pre><code class="language-python">sta_delta = meb.minus_on_level_time_dtime_id(sta_temp,sta_dpt) # 默认how = "left" print(sta_delta)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2018-08-01 08:00:00 0 1009 89.49 3.99 NaN 1 0 2018-08-01 08:00:00 0 29645 86.22 55.25 0.1 2 0 2018-08-01 08:00:00 0 28593 74.63 56.10 2.1 3 0 2018-08-01 08:00:00 0 36022 80.33 52.02 2.5 4 0 2018-08-01 08:00:00 0 29209 77.22 57.81 2.0 ... ... ... ... ... ... ... ... 3956 0 2018-08-01 08:00:00 0 48679 103.67 1.63 0.4 3957 0 2018-08-01 08:00:00 0 16364 16.37 38.76 1.4 3958 0 2018-08-01 08:00:00 0 16415 14.87 38.58 1.1 3959 0 2018-08-01 08:00:00 0 16081 9.26 45.46 2.7 3960 0 2018-08-01 08:00:00 0 16314 16.66 40.68 5.9 [3961 rows x 7 columns]</code></pre> <pre><code class="language-python">sta_delta = meb.minus_on_level_time_dtime_id(sta_temp,sta_dpt,default = 0) # 默认how = "left" print(sta_delta) # 设置sta_dpt缺省的站点的露点为0 </code></pre> <pre><code> level time dtime id lon lat data0 0 0 2018-08-01 08:00:00 0 1009 89.49 3.99 27.9 1 0 2018-08-01 08:00:00 0 29645 86.22 55.25 0.1 2 0 2018-08-01 08:00:00 0 28593 74.63 56.10 2.1 3 0 2018-08-01 08:00:00 0 36022 80.33 52.02 2.5 4 0 2018-08-01 08:00:00 0 29209 77.22 57.81 2.0 ... ... ... ... ... ... ... ... 3956 0 2018-08-01 08:00:00 0 48679 103.67 1.63 0.4 3957 0 2018-08-01 08:00:00 0 16364 16.37 38.76 1.4 3958 0 2018-08-01 08:00:00 0 16415 14.87 38.58 1.1 3959 0 2018-08-01 08:00:00 0 16081 9.26 45.46 2.7 3960 0 2018-08-01 08:00:00 0 16314 16.66 40.68 5.9 [3961 rows x 7 columns]</code></pre> <pre><code class="language-python">sta_delta = meb.minus_on_level_time_dtime_id(sta_temp,sta_dpt,how = "inner") #设置how = "inner", 当温度和露点观测都存在时才计算并保留到结果中 print(sta_delta) </code></pre> <pre><code> level time dtime id lon lat data0 0 0 2018-08-01 08:00:00 0 29645 86.22 55.25 0.1 1 0 2018-08-01 08:00:00 0 28593 74.63 56.10 2.1 2 0 2018-08-01 08:00:00 0 36022 80.33 52.02 2.5 3 0 2018-08-01 08:00:00 0 29209 77.22 57.81 2.0 4 0 2018-08-01 08:00:00 0 98132 121.85 20.80 1.7 ... ... ... ... ... ... ... ... 3898 0 2018-08-01 08:00:00 0 48679 103.67 1.63 0.4 3899 0 2018-08-01 08:00:00 0 16364 16.37 38.76 1.4 3900 0 2018-08-01 08:00:00 0 16415 14.87 38.58 1.1 3901 0 2018-08-01 08:00:00 0 16081 9.26 45.46 2.7 3902 0 2018-08-01 08:00:00 0 16314 16.66 40.68 5.9 [3903 rows x 7 columns]</code></pre> <h1>设置缺省值</h1> <p><font face="黑体" color=blue size = 5><strong>reset_value_as_IV(sta,value)</strong></font><br /> 使用该数据库时默认的缺失值是meteva.base.IV = 999999,如果需要将其其它值(例如9999)记为缺失值,可采用该函数进行转换。转换返回的结果中,缺失值会被替换为meteva.base.IV。原始输入的sta数据不会改变</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>sta</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>value</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a>,重置之前的无效值</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/meteva?page_id=3975600580125986">站点数据</a>,站点数据,缺省值更改成了meteva.base.IV</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">sta1 = meb.reset_value_as_IV(sta,1.3) print(sta1)</code></pre> <pre><code> level time dtime id lon lat data0 0 0 2020-01-03 20:00:00 0 57671 112.37 28.85 999999.0 1 0 2020-01-03 20:00:00 0 57845 109.78 26.17 5.4 2 0 2020-01-03 20:00:00 0 57466 111.75 30.46 0.1 3 0 2020-01-03 20:00:00 0 57842 109.72 26.88 0.8 4 0 2020-01-03 20:00:00 0 57584 113.09 29.38 999999.0 .. ... ... ... ... ... ... ... 561 0 2020-01-03 20:00:00 0 57589 113.88 29.27 2.2 562 0 2020-01-03 20:00:00 0 57583 113.97 29.92 4.2 563 0 2020-01-03 20:00:00 0 55690 91.95 27.98 2.3 564 0 2020-01-03 20:00:00 0 55597 91.68 29.03 0.0 565 0 2020-01-03 20:00:00 0 56434 97.47 28.67 0.2 [566 rows x 7 columns]</code></pre> <h1>网格数据平滑</h1> <p><font face="黑体" color=blue size = 5><strong>smooth(grd,smooth_times = 1,used_coords = [&quot;lon&quot;,&quot;lat&quot;])</strong></font><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>grd</font></strong></td> <td style="text-align: left;">网格数据</td> </tr> <tr> <td style="text-align: left;"><strong>smooth_times</strong></td> <td style="text-align: left;">九点平滑操作的次数,缺省值为1</td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">平滑操作使用的维度,缺省情况下平滑操作只在水平方向实现</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">网格数据,平滑后的网格数据</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">grid0 = meb.grid([100,104,1],[20,24,1],gtime=["2019013108"],dtime_list = [24],level_list = [0],member_list = ["GRAPES"]) x= np.arange(0.5,5,1) y= np.arange(0.5,5,1) _,yy = np.meshgrid(x,y) grd = meb.grid_data(grid0,yy) #根据网格信息和numpy数组生成网格数 print(grd)</code></pre> <pre><code>&lt;xarray.DataArray 'data0' (member: 1, level: 1, time: 1, dtime: 1, lat: 5, lon: 5)&gt; array([[[[[[0.5, 0.5, 0.5, 0.5, 0.5], [1.5, 1.5, 1.5, 1.5, 1.5], [2.5, 2.5, 2.5, 2.5, 2.5], [3.5, 3.5, 3.5, 3.5, 3.5], [4.5, 4.5, 4.5, 4.5, 4.5]]]]]]) Coordinates: * member (member) &lt;U6 'GRAPES' * level (level) int32 0 * time (time) datetime64[ns] 2019-01-31T08:00:00 * dtime (dtime) int32 24 * lat (lat) int32 20 21 22 23 24 * lon (lon) int32 100 101 102 103 104</code></pre> <pre><code class="language-python">grd_sm = meb.comp.smooth(grd,3) print(grd_sm)</code></pre> <pre><code>(5, 5) &lt;xarray.DataArray 'data0' (member: 1, level: 1, time: 1, dtime: 1, lat: 5, lon: 5)&gt; array([[[[[[1.09375 , 1.09375 , 1.09375 , 1.09375 , 1.09375 ], [1.640625, 1.640625, 1.640625, 1.640625, 1.640625], [2.5 , 2.5 , 2.5 , 2.5 , 2.5 ], [3.359375, 3.359375, 3.359375, 3.359375, 3.359375], [3.90625 , 3.90625 , 3.90625 , 3.90625 , 3.90625 ]]]]]]) Coordinates: * member (member) &lt;U6 'GRAPES' * level (level) int32 0 * time (time) datetime64[ns] 2019-01-31T08:00:00 * dtime (dtime) int32 24 * lat (lat) int32 20 21 22 23 24 * lon (lon) int32 100 101 102 103 104</code></pre> <pre><code class="language-python"></code></pre> <h1>网格数据滑动平均</h1> <p><font face="黑体" color=blue size = 5><strong>moving_ave(grd, half_window_size)</strong></font><br /> 求网格数据的水平方向的正方形窗口滑动平均场。 该函数是FSS检验的基础函数,它同样可以基于确定性预报的邻域法概论产品的制作当中。</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>grd</font></strong></td> <td style="text-align: left;">网格数据</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>half_window_size</font></strong></td> <td style="text-align: left;">半边窗口的网格数据,例如当half_window_size = 1,时,计算区域中部的一个网格点的平均用到 3×3个格点,当half_window_size = 2时 用到了5×5个格点求平均, 在区域的边缘,计算平均的格点数为窗口内实际格点数,每个位置会略有差异,但会正确保持平均值的含义</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">平滑后的网格数据</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">grd_ma = meb.moving_ave(grd,1) print(grd_ma)</code></pre> <pre><code>&lt;xarray.DataArray 'data0' (member: 1, level: 1, time: 1, dtime: 1, lat: 5, lon: 5)&gt; array([[[[[[1. , 1. , 1. , 1. , 1. ], [1.5, 1.5, 1.5, 1.5, 1.5], [2.5, 2.5, 2.5, 2.5, 2.5], [3.5, 3.5, 3.5, 3.5, 3.5], [4. , 4. , 4. , 4. , 4. ]]]]]]) Coordinates: * member (member) &lt;U6 'GRAPES' * level (level) int32 0 * time (time) datetime64[ns] 2019-01-31T08:00:00 * dtime (dtime) int32 24 * lat (lat) int32 20 21 22 23 24 * lon (lon) int32 100 101 102 103 104</code></pre> <pre><code class="language-python">rain24= meb.read_griddata_from_nc(r"H:\test_data\input\meb\EC_rain20070608.024.nc",data_name ="ECMWF" ) clevs,cmap = meb.tool.color_tools.clev_cmap_rain_24h() meb.tool.plot_tools.contourf_2d_grid(rain01,clevs=clevs,cmap = cmap,title = "模式24小时降水量预报")</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/6425f1992393cc65ec5d9f8364240327?showdoc=.jpg" alt="" /></p> <pre><code class="language-python">ssr = rain24.copy() ssr.values[ssr.values &lt;50] =0 ssr.values[ssr.values &gt;=50] =1 meb.tool.plot_tools.contourf_2d_grid(ssr,cmap ="binary",title = "模式暴雨确定性预报") print("平滑操作前纬向网格数:" + str(len(ssr["lon"]))) print("平滑操作前径向网格数:" + str(len(ssr["lat"])))</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/949745ec3102ebd65988262be91d6b69?showdoc=.jpg" alt="" /></p> <pre><code>平滑操作前纬向网格数:1441 平滑操作前径向网格数:721</code></pre> <pre><code class="language-python">p_ssr = meb.moving_ave(ssr,half_window_size=10) # 平滑操作不改变网格范围和网格距 meb.tool.plot_tools.contourf_2d_grid(p_ssr,cmap ="binary",title = "采用邻域法制作的暴雨概率预报") print("平滑操作后纬向网格数:" + str(len(p_ssr["lon"]))) print("平滑操作后径向网格数:" + str(len(p_ssr["lat"])))</code></pre> <pre><code>平滑操作后纬向网格数:1441 平滑操作后径向网格数:721</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/f542de15513853329504dafb43a13707?showdoc=.jpg" alt="" /></p> <h1>网格数据滑动最大值</h1> <p><font face="黑体" color=blue size = 5><strong>moving_max(grd, half_window_size)</strong></font><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>grd</font></strong></td> <td style="text-align: left;">网格数据</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>half_window_size</font></strong></td> <td style="text-align: left;">半边窗口的网格数据,例如当half_window_size = 1,时,计算区域中部的一个网格点的平均用到 3×3个格点,当half_window_size = 2时 用到了5×5个格点求平均, 在区域的边缘,计算平均的格点数为窗口内实际格点数,每个位置会略有差异,但会正确保持平均值的含义</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">滑动最大值场,每个格点是起附近窗口内原始场的最大值</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">v_max = meb.moving_max(rain24,half_window_size=5) # 平滑操作不改变网格范围和网格距 print(time.time() - start) meb.tool.plot_tools.contourf_2d_grid(v_max,cmap =meb.cmaps.rain_24h,title = "滑动窗口的最大值",dpi = 100)</code></pre> <pre><code>1.4234049320220947</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/9fde0f6c142418af5143e0c0a558db8e" alt="" /></p> <h1>网格数据滑动最小值</h1> <p><font face="黑体" color=blue size = 5><strong>moving_max(grd, half_window_size)</strong></font><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>grd</font></strong></td> <td style="text-align: left;">网格数据</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>half_window_size</font></strong></td> <td style="text-align: left;">半边窗口的网格数据,例如当half_window_size = 1,时,计算区域中部的一个网格点的平均用到 3×3个格点,当half_window_size = 2时 用到了5×5个格点求平均, 在区域的边缘,计算平均的格点数为窗口内实际格点数,每个位置会略有差异,但会正确保持平均值的含义</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">滑动最小值场,每个格点是起附近窗口内原始场的最小值</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">v_min = meb.moving_min(rain24,half_window_size=5) # 平滑操作不改变网格范围和网格距 print(time.time() - start) meb.tool.plot_tools.contourf_2d_grid(v_min,cmap =meb.cmaps.rain_24h,title = "滑动窗口的最小值",dpi = 100)</code></pre> <pre><code>2.7418622970581055</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/faa60851c62a0ba0d0c3d21ea4be8c44" alt="" /></p> <h1>网格数据滑动标准差</h1> <p><font face="黑体" color=blue size = 5><strong>moving_std(grd, half_window_size)</strong></font><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>grd</font></strong></td> <td style="text-align: left;">网格数据</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>half_window_size</font></strong></td> <td style="text-align: left;">半边窗口的网格数据,例如当half_window_size = 1,时,计算区域中部的一个网格点的平均用到 3×3个格点,当half_window_size = 2时 用到了5×5个格点求平均, 在区域的边缘,计算平均的格点数为窗口内实际格点数,每个位置会略有差异,但会正确保持平均值的含义</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">滑动标准差场,每个格点是起附近窗口内原始场的标准差</td> </tr> </tbody> </table> <p><strong>调用示例</strong></p> <pre><code class="language-python">v_std = meb.moving_std(rain24,half_window_size=5) # 平滑操作不改变网格范围和网格距 print(time.time() - start) meb.tool.plot_tools.contourf_2d_grid(v_std,cmap =meb.cmaps.rain_24h,title = "滑动窗口的标准差",dpi = 100)</code></pre> <pre><code>3.706881284713745</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitfile/sign/fe1bc2e3ac6d42bceb2d81ed77bc0831" alt="" /></p>

页面列表

ITEM_HTML