meteva

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


特征时间

<p>[TOC]</p> <pre><code class="language-python"> import meteva.base as meb import meteva.product as mpd import meteva.method as mem import numpy as np import pandas as pd import datetime</code></pre> <pre><code class="language-python">#创建一个简单的测试数据,用于展示 data_ob = [1,1,0,0,1,2,1,0,1,1,0,0] data_fo = [0,1,0,0,1,2,3.0,0,0,0,1,1] dtime= np.arange(1,len(data_ob)+1) df = pd.DataFrame({"dtime":dtime,"OBS":data_ob,"FST":data_fo}) rain01 = meb.sta_data(df) rain01[["level","id","lon","lat"]] = 0 rain01["time"] = datetime.datetime(2020,1,1,8) print(rain01)</code></pre> <pre><code> level time dtime id lon lat OBS FST 0 0 2020-01-01 08:00:00 1 0 0 0 1 0.0 1 0 2020-01-01 08:00:00 2 0 0 0 1 1.0 2 0 2020-01-01 08:00:00 3 0 0 0 0 0.0 3 0 2020-01-01 08:00:00 4 0 0 0 0 0.0 4 0 2020-01-01 08:00:00 5 0 0 0 1 1.0 5 0 2020-01-01 08:00:00 6 0 0 0 2 2.0 6 0 2020-01-01 08:00:00 7 0 0 0 1 3.0 7 0 2020-01-01 08:00:00 8 0 0 0 0 0.0 8 0 2020-01-01 08:00:00 9 0 0 0 1 0.0 9 0 2020-01-01 08:00:00 10 0 0 0 1 0.0 10 0 2020-01-01 08:00:00 11 0 0 0 0 1.0 11 0 2020-01-01 08:00:00 12 0 0 0 0 1.0</code></pre> <pre><code class="language-python">#绘图展示降水的时间序列 result = mpd.score(rain01,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "1小时降水量",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=f276aad2652a348cb99954329f6799da" alt="" /></p> <h1>降水过程标识</h1> <p><font face="黑体" color=blue size = 5><strong>rain_to_01process(rain01h_ob_fos,used_coords = &quot;time&quot;)</strong></font><br /> 将降水的时间序列转换成降水过程标识序列,标识为1代表该对应时刻处于降水过程中,否则标识为0。 根据《中国降水日变化》(宇如聪等)中的定义,1小时降水量开始达到0.1mm时记为降水过程开始,当连续2个小时降水降水量低于0.1mm则判断为降水过程结束。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度诊断降水过程</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/nmc?page_id=3744334022014027">站点数据</a>,形式和输入数据rain01h_ob_fos类似,数据列上的取值只能为0或1,但为了后续统计方便,在过程的起止时间外延了1小时</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">process = meb.rain_to_01process(rain01,used_coords="dtime") print(process)</code></pre> <pre><code> level time dtime id lon lat OBS FST 13 0 2020-01-01 08:00:00 0 0 0.0 0.0 0.0 0.0 0 0 2020-01-01 08:00:00 1 0 0.0 0.0 1.0 0.0 1 0 2020-01-01 08:00:00 2 0 0.0 0.0 1.0 1.0 2 0 2020-01-01 08:00:00 3 0 0.0 0.0 0.0 0.0 3 0 2020-01-01 08:00:00 4 0 0.0 0.0 0.0 0.0 4 0 2020-01-01 08:00:00 5 0 0.0 0.0 1.0 1.0 5 0 2020-01-01 08:00:00 6 0 0.0 0.0 1.0 1.0 6 0 2020-01-01 08:00:00 7 0 0.0 0.0 1.0 1.0 7 0 2020-01-01 08:00:00 8 0 0.0 0.0 1.0 0.0 8 0 2020-01-01 08:00:00 9 0 0.0 0.0 1.0 0.0 9 0 2020-01-01 08:00:00 10 0 0.0 0.0 1.0 0.0 10 0 2020-01-01 08:00:00 11 0 0.0 0.0 0.0 1.0 11 0 2020-01-01 08:00:00 12 0 0.0 0.0 0.0 1.0 12 0 2020-01-01 08:00:00 13 0 0.0 0.0 0.0 0.0</code></pre> <p>上述生成的结果中增加了0 和13时效,它们取值为0,且都是输入数据中不包含的,目的是为了方便后续统计过程起止时间</p> <pre><code class="language-python">#将上述生成的过程标识绘制成图形 result = mpd.score(process,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程标记",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=ca08327051759d47de9c11f310134118" alt="" /></p> <p>在本示例中,观测数据在008时效中断了1个小时,但是过程仍然判断为未结束,因此过程标识仍为1。</p> <h1>降水过程起始标识</h1> <p><font face="黑体" color=blue size = 5><strong>rain_process_start(rain01h_ob_fos,used_coords = &quot;time&quot;)</strong></font><br /> 将降水的时间序列转换成降水过程开始标识序列,标识为1代表该对应时刻处于降水过程开始时刻,否则标识为0。例如,若08-09时开始出现0.1mm以上降水,计算结果会在将09时记为过程起始时刻。 根据《中国降水日变化》(宇如聪等)中的定义,1小时降水量开始达到0.1mm时记为降水过程开始,当连续2个小时降水降水量低于0.1mm则判断为降水过程结束。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度诊断降水过程</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/nmc?page_id=3744334022014027">站点数据</a>,形式和输入数据rain01h_ob_fos类似,数据列上的取值只能为0或1</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">process_start = meb.rain_process_start(rain01,used_coords="dtime") print(process_start)</code></pre> <pre><code> level time dtime id lon lat OBS FST 0 0 2020-01-01 08:00:00 1 0 0.0 0.0 1.0 0.0 1 0 2020-01-01 08:00:00 2 0 0.0 0.0 0.0 1.0 2 0 2020-01-01 08:00:00 3 0 0.0 0.0 0.0 0.0 3 0 2020-01-01 08:00:00 4 0 0.0 0.0 0.0 0.0 4 0 2020-01-01 08:00:00 5 0 0.0 0.0 1.0 1.0 5 0 2020-01-01 08:00:00 6 0 0.0 0.0 0.0 0.0 6 0 2020-01-01 08:00:00 7 0 0.0 0.0 0.0 0.0 7 0 2020-01-01 08:00:00 8 0 0.0 0.0 0.0 0.0 8 0 2020-01-01 08:00:00 9 0 0.0 0.0 0.0 0.0 9 0 2020-01-01 08:00:00 10 0 0.0 0.0 0.0 0.0 10 0 2020-01-01 08:00:00 11 0 0.0 0.0 0.0 1.0 11 0 2020-01-01 08:00:00 12 0 0.0 0.0 0.0 0.0 12 0 2020-01-01 08:00:00 13 0 0.0 0.0 0.0 0.0</code></pre> <p>在本示例中观测降水001h时效出现了1mm降水,因此降水实际上是在0-1时效段内的,因此观测数据的1时效记为过程开始时间,其它过程也类似。</p> <pre><code class="language-python">#将上述生成的过程起始标识绘制成图形 result = mpd.score(process_start,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程开始时刻标记",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=0d60591c2f2bf678e369ac8df5ddec51" alt="" /></p> <h1>降水过程结束标识</h1> <p><font face="黑体" color=blue size = 5><strong>rain_process_end(rain01h_ob_fos,used_coords = &quot;time&quot;)</strong></font><br /> 将降水的时间序列转换成降水过程结束标识序列,标识为1代表该对应时刻处于降水过程结束时刻,否则标识为0。例如默认09时之后连续2个小时未出现0.1mm以上降水,计算结果会在将09时记为过程结束时刻,在返回结果中时间为09时的一行会记录为1。 根据《中国降水日变化》(宇如聪等)中的定义,1小时降水量开始达到0.1mm时记为降水过程开始,当连续2个小时降水降水量低于0.1mm则判断为降水过程结束。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度诊断降水过程</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/nmc?page_id=3744334022014027">站点数据</a>,形式和输入数据rain01h_ob_fos类似,数据列上的取值只能为0或1</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">process_end = meb.rain_process_end(rain01,used_coords="dtime") print(process_end)</code></pre> <pre><code> level time dtime id lon lat OBS FST 0 0 2020-01-01 08:00:00 0 0 0.0 0.0 -0.0 -0.0 1 0 2020-01-01 08:00:00 1 0 0.0 0.0 -0.0 -0.0 2 0 2020-01-01 08:00:00 2 0 0.0 0.0 1.0 1.0 3 0 2020-01-01 08:00:00 3 0 0.0 0.0 -0.0 -0.0 4 0 2020-01-01 08:00:00 4 0 0.0 0.0 -0.0 -0.0 5 0 2020-01-01 08:00:00 5 0 0.0 0.0 -0.0 -0.0 6 0 2020-01-01 08:00:00 6 0 0.0 0.0 -0.0 -0.0 7 0 2020-01-01 08:00:00 7 0 0.0 0.0 -0.0 1.0 8 0 2020-01-01 08:00:00 8 0 0.0 0.0 -0.0 -0.0 9 0 2020-01-01 08:00:00 9 0 0.0 0.0 -0.0 -0.0 10 0 2020-01-01 08:00:00 10 0 0.0 0.0 1.0 -0.0 11 0 2020-01-01 08:00:00 11 0 0.0 0.0 -0.0 -0.0 12 0 2020-01-01 08:00:00 12 0 0.0 0.0 -0.0 1.0</code></pre> <p>在本示例中观测降水001和002h时效出现了1mm降水,之后中断超过2小时,因此观测数据的002时效记为过程结束时间,其它过程也类似。</p> <pre><code class="language-python">#将上述生成的过程结束标识绘制成图形 result = mpd.score(process_end,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程时刻时刻标记",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=076da6640df1da8f26d6a1b11d3a7412" alt="" /></p> <h1>降水过程时间长度</h1> <p><font face="黑体" color=blue size = 5><strong>rain_process_lenght(rain01h_ob_fos,used_coords = &quot;time&quot;,record_on = &quot;end&quot;)</strong></font><br /> 统计降水过程时长,即降水过程持续的小时数。 根据《中国降水日变化》(宇如聪等)中的定义,1小时降水量开始达到0.1mm时记为降水过程开始,当连续2个小时降水降水量低于0.1mm则判断为降水过程结束。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度诊断降水过程</td> </tr> <tr> <td style="text-align: left;"><strong>record_on</strong></td> <td style="text-align: left;">过程时长记录位置,当record=&quot;end&quot;时将时间长度记录在过程结束时刻,否则记录在过程起始时刻</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/nmc?page_id=3744334022014027">站点数据</a>,形式和输入数据rain01h_ob_fos类似</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">process_lenght = meb.rain_process_lenght(rain01,used_coords="dtime",record_on="end") print(process_lenght)</code></pre> <pre><code> level time dtime id lon lat OBS FST 0 0 2020-01-01 08:00:00 0 0 0.0 0.0 0.0 0.0 1 0 2020-01-01 08:00:00 1 0 0.0 0.0 0.0 0.0 2 0 2020-01-01 08:00:00 2 0 0.0 0.0 2.0 1.0 3 0 2020-01-01 08:00:00 3 0 0.0 0.0 0.0 0.0 4 0 2020-01-01 08:00:00 4 0 0.0 0.0 0.0 0.0 5 0 2020-01-01 08:00:00 5 0 0.0 0.0 0.0 0.0 6 0 2020-01-01 08:00:00 6 0 0.0 0.0 0.0 0.0 7 0 2020-01-01 08:00:00 7 0 0.0 0.0 0.0 3.0 8 0 2020-01-01 08:00:00 8 0 0.0 0.0 0.0 0.0 9 0 2020-01-01 08:00:00 9 0 0.0 0.0 0.0 0.0 10 0 2020-01-01 08:00:00 10 0 0.0 0.0 6.0 0.0 11 0 2020-01-01 08:00:00 11 0 0.0 0.0 0.0 0.0 12 0 2020-01-01 08:00:00 12 0 0.0 0.0 0.0 2.0 13 0 2020-01-01 08:00:00 13 0 0.0 0.0 0.0 0.0</code></pre> <pre><code class="language-python">#将上述生成的过程时长绘制成图形 result = mpd.score(process_lenght,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程时间长度(记录在结束时刻)",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=13019024b7010379a34680cd9c2a2d3a" alt="" /></p> <p>在本示例中,观测数据在001和002时效出现1mm降水,因此在002时效记录2小时的降水时长,其它过程类似</p> <pre><code class="language-python">#降水过程时长记录在开始时刻的效果 process_lenght = meb.rain_process_lenght(rain01,used_coords="dtime",record_on="start") result = mpd.score(process_lenght,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程时间长度(记录在开始时刻)",tag = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=64e507abb06feb2b1d7db506212c8a85" alt="" /></p> <h1>降水过程峰值</h1> <p><font face="黑体" color=blue size = 5><strong>rain_process_peak(rain01h_ob_fos,used_coords = &quot;time&quot;,record_on = &quot;end&quot;)</strong></font><br /> 统计降水过程降水峰值对应的时间和峰值降水量,如果有多个时刻降水量完全相同,则随机选取一个作为峰值时刻。 根据《中国降水日变化》(宇如聪等)中的定义,1小时降水量开始达到0.1mm时记为降水过程开始,当连续2个小时降水降水量低于0.1mm则判断为降水过程结束。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;"><a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a></td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度诊断降水过程</td> </tr> <tr> <td style="text-align: left;"><strong>record_on</strong></td> <td style="text-align: left;">过程时长记录位置,当record=&quot;end&quot;时将时间长度记录在过程结束时刻,否则记录在过程起始时刻</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/nmc?page_id=3744334022014027">站点数据</a>,第0个元素为降水峰值的时间标记,即在降水峰值时刻标记值为1,其余为0,第1个元素在峰值时刻取值为降水量本身,其余为0</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">peak_time,peak_value = meb.rain_process_peak(rain01,used_coords="dtime") result = mpd.score(peak_time,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程峰值时间标记",tag = 0) result = mpd.score(peak_value,mem.ob_fo_mean,g = "dtime",plot = "bar",ylabel = "过程峰值",tag = 3)</code></pre> <pre><code>已完成3% 已完成7% 已完成11% 已完成14% 已完成18% 已完成22% 已完成25% 已完成29% 已完成33% 已完成37% 已完成40% 已完成44% 已完成51% 已完成55% 已完成59% 已完成62% 已完成66% 已完成70% 已完成74% 已完成77% 已完成81% 已完成85% 已完成88% 已完成92%</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=c2e898e92f331c1432b748a10ef00875" alt="" /></p> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=98899b9674b262bc1171cd7591bd566e" alt="" /></p> <p>以上介绍了降水过程相关的时间峰值降水量的诊断方法,但降水过程的诊断结果还需开展进一步的统计分析,以下给出了一个分析的示例</p> <pre><code class="language-python">#读取2022年5月6日08时至17日20时的逐1小时降水预报及与之匹配的观测数据 path = r"H:\test_data\input\mem\rain01.h5" rain01 = pd.read_hdf(path) print(rain01)</code></pre> <pre><code> level time dtime id lon lat ob RUC 122326 0 2022-05-06 08:00:00 1 57909 105.82 24.98 0.0 0.0 122338 0 2022-05-06 08:00:00 1 57927 107.18 24.97 0.0 0.0 122345 0 2022-05-06 08:00:00 1 57949 110.00 24.98 0.0 0.0 122758 0 2022-05-06 08:00:00 1 59001 105.33 24.78 0.0 0.0 122759 0 2022-05-06 08:00:00 1 59004 105.10 24.50 0.0 0.0 ... ... ... ... ... ... ... ... ... 788374 0 2022-05-17 20:00:00 24 59673 112.77 21.73 0.0 0.0 788375 0 2022-05-17 20:00:00 24 59750 110.07 20.97 0.0 0.0 788376 0 2022-05-17 20:00:00 24 59754 110.18 20.33 0.0 0.0 788377 0 2022-05-17 20:00:00 24 59757 110.37 20.00 0.0 0.0 788378 0 2022-05-17 20:00:00 24 59758 110.25 20.00 0.0 0.0 [104832 rows x 8 columns]</code></pre> <pre><code class="language-python"># 统计降水过程峰值时间和峰值降水量 peak_time,peak_value = meb.rain_process_peak(rain01,used_coords="dtime")</code></pre> <pre><code>已完成1% 已完成3% 已完成5% 已完成7% 已完成9% 已完成11% 已完成13% 已完成15% 已完成17% 已完成19% 已完成21% 已完成23% 已完成25% 已完成27% 已完成29% 已完成31% 已完成33% 已完成35% 已完成37% 已完成39% 已完成41% 已完成43% 已完成45% 已完成47% 已完成50% 已完成52% 已完成54% 已完成56% 已完成58% 已完成60% 已完成62% 已完成64% 已完成66% 已完成68% 已完成70% 已完成72% 已完成74% 已完成76% 已完成78% 已完成80% 已完成82% 已完成84% 已完成86% 已完成88% 已完成90% 已完成92% 已完成94% 已完成96%</code></pre> <pre><code class="language-python"># 对于所有时刻,当其为峰值时被记为1,否则记为0 #因此对于一类样本求平均值,则可以获得对应类型的样本正好为降水过程峰值的比例(频率) result = mpd.score(peak_time,mem.ob_fo_mean,g = "ob_hour",plot = "line",ylabel = "出现过程峰值的频率",vmin = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=8399e75fbd8f252575b6b8c2cea573cd" alt="" /></p> <p>在上述示例中,观测的降水序列中,降水峰值最容易出现在09时,预报的峰值时间出现在07时。观测和预报的降水峰值出现频次日变化曲线有相似性,但是预报的降水表现出很明显的3小时波动的特征,这说明在制作该降水预报产品所用的时间拆分方法未能很好的让降水强度在逐3小时内合理的分配。</p> <h1>日最大值标识</h1> <p><font face="黑体" color=blue size = 5><strong>is_max_of_oneday(sta,used_coords = &quot;time&quot;,start_hour_of_one_day = 0,keep_zeros = True)</strong></font><br /> 统计各个站点某个时刻是否为一天当中的最大值,如果是则记为1,否则记为0。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;">原始的<a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a>,其中的时间序列或时效序列的间隔必须小于24小时</td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度判别最大值</td> </tr> <tr> <td style="text-align: left;"><strong>start_hour_of_one_day</strong></td> <td style="text-align: left;">记为一天的时段,默认是01-00时记为1天,类似的如果该参数等于8,则计09-08时为一天</td> </tr> <tr> <td style="text-align: left;"><strong>keep_zeros</strong></td> <td style="text-align: left;">当最大值为0时,是否仍然标记为最大值,默认为True。但在判断降水的最大值标识时,该参数应该取为False,因为当一天中所有时刻的降水都为0时,所有时刻都不是最大值</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">站点数据,其中记录了每个站点每个时刻或时效是否为一天中的最大值,1代表是,0代表否,如果某一天的时间或时效序列不完整,则相应时刻的样本会被剔除</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">#首先通过单个站点数据展示识别前后数据 rain01_oneday = meb.sele_by_para(rain01,time = "2022051008",id = 59663) print(rain01_oneday) #原始的预报数据序列</code></pre> <pre><code> level time dtime id lon lat ob \ 351981 0 2022-05-10 08:00:00 1 59663 111.97 21.83 1.900000 354392 0 2022-05-10 08:00:00 2 59663 111.97 21.83 0.300000 354392 0 2022-05-10 08:00:00 3 59663 111.97 21.83 0.200000 354392 0 2022-05-10 08:00:00 4 59663 111.97 21.83 0.400000 354392 0 2022-05-10 08:00:00 5 59663 111.97 21.83 0.200000 354392 0 2022-05-10 08:00:00 6 59663 111.97 21.83 0.300000 354392 0 2022-05-10 08:00:00 7 59663 111.97 21.83 1.500000 354392 0 2022-05-10 08:00:00 8 59663 111.97 21.83 1.300000 354392 0 2022-05-10 08:00:00 9 59663 111.97 21.83 0.000000 354392 0 2022-05-10 08:00:00 10 59663 111.97 21.83 0.000000 354392 0 2022-05-10 08:00:00 11 59663 111.97 21.83 0.600000 354392 0 2022-05-10 08:00:00 12 59663 111.97 21.83 0.000000 354392 0 2022-05-10 08:00:00 13 59663 111.97 21.83 0.700000 354392 0 2022-05-10 08:00:00 14 59663 111.97 21.83 0.000000 354392 0 2022-05-10 08:00:00 15 59663 111.97 21.83 0.000000 354392 0 2022-05-10 08:00:00 16 59663 111.97 21.83 1.200000 354392 0 2022-05-10 08:00:00 17 59663 111.97 21.83 1.200000 354392 0 2022-05-10 08:00:00 18 59663 111.97 21.83 7.800000 354392 0 2022-05-10 08:00:00 19 59663 111.97 21.83 13.800000 354392 0 2022-05-10 08:00:00 20 59663 111.97 21.83 94.300003 354392 0 2022-05-10 08:00:00 21 59663 111.97 21.83 60.099998 354392 0 2022-05-10 08:00:00 22 59663 111.97 21.83 21.700001 354392 0 2022-05-10 08:00:00 23 59663 111.97 21.83 0.600000 354392 0 2022-05-10 08:00:00 24 59663 111.97 21.83 0.100000 RUC 351981 1.99 354392 0.30 354392 0.03 354392 0.89 354392 1.18 354392 1.07 354392 1.02 354392 0.89 354392 0.69 354392 0.90 354392 0.83 354392 0.90 354392 1.29 354392 1.82 354392 1.75 354392 1.53 354392 1.46 354392 1.56 354392 1.21 354392 1.33 354392 3.01 354392 6.47 354392 8.22 354392 6.28 </code></pre> <pre><code class="language-python">max_index_oneday = meb.is_max_of_oneday(rain01_oneday,used_coords="dtime",start_hour_of_one_day=8) print(max_index_oneday) # 最大的标记</code></pre> <pre><code> level time dtime id lon lat ob RUC 0 0 2022-05-10 08:00:00 1 59663 111.97 21.83 0 0 1 0 2022-05-10 08:00:00 2 59663 111.97 21.83 0 0 2 0 2022-05-10 08:00:00 3 59663 111.97 21.83 0 0 3 0 2022-05-10 08:00:00 4 59663 111.97 21.83 0 0 4 0 2022-05-10 08:00:00 5 59663 111.97 21.83 0 0 5 0 2022-05-10 08:00:00 6 59663 111.97 21.83 0 0 6 0 2022-05-10 08:00:00 7 59663 111.97 21.83 0 0 7 0 2022-05-10 08:00:00 8 59663 111.97 21.83 0 0 8 0 2022-05-10 08:00:00 9 59663 111.97 21.83 0 0 9 0 2022-05-10 08:00:00 10 59663 111.97 21.83 0 0 10 0 2022-05-10 08:00:00 11 59663 111.97 21.83 0 0 11 0 2022-05-10 08:00:00 12 59663 111.97 21.83 0 0 12 0 2022-05-10 08:00:00 13 59663 111.97 21.83 0 0 13 0 2022-05-10 08:00:00 14 59663 111.97 21.83 0 0 14 0 2022-05-10 08:00:00 15 59663 111.97 21.83 0 0 15 0 2022-05-10 08:00:00 16 59663 111.97 21.83 0 0 16 0 2022-05-10 08:00:00 17 59663 111.97 21.83 0 0 17 0 2022-05-10 08:00:00 18 59663 111.97 21.83 0 0 18 0 2022-05-10 08:00:00 19 59663 111.97 21.83 0 0 19 0 2022-05-10 08:00:00 20 59663 111.97 21.83 1 0 20 0 2022-05-10 08:00:00 21 59663 111.97 21.83 0 0 21 0 2022-05-10 08:00:00 22 59663 111.97 21.83 0 0 22 0 2022-05-10 08:00:00 23 59663 111.97 21.83 0 1 23 0 2022-05-10 08:00:00 24 59663 111.97 21.83 0 0</code></pre> <p>在上面的示例中,是对时效维度求日最大值标记,观测的最大值位于020H时效,预报最大值为于023H时效。上面的样例数据只能在09-08时段构成完整的一天,如果用默认的01-00作为一天的话,结果将没有完整的一天,效果如下所示:</p> <pre><code class="language-python">max_index_oneday = meb.is_max_of_oneday(rain01_oneday,used_coords="dtime") print(max_index_oneday) # 最大的标记</code></pre> <pre><code>Empty DataFrame Columns: [level, time, dtime, id, lon, lat, ob, RUC] Index: []</code></pre> <pre><code class="language-python">#日最大值标记函数也可以用于包含多个站点的长序列数据 max_index_all = meb.is_max_of_oneday(rain01,used_coords="dtime",start_hour_of_one_day=8,keep_zeros=False)</code></pre> <pre><code class="language-python">#根据日最大值标记的结果,可以统计最大值出现频率的日变化情况 result = mpd.score(max_index_all,mem.ob_fo_mean,g = "ob_hour",plot = "line", ylabel = "日降水峰值的频率随观测时点的变化",vmin = 0)</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=dd19c5b06ddf3268068b9a159d19cb17&amp;file=file.png" alt="" /></p> <pre><code class="language-python">temp_all = pd.read_hdf(r"H:\test_data\input\mpd\temp_data.h5") #加载一周的预报数据</code></pre> <pre><code class="language-python">max_index_all = meb.is_max_of_oneday(temp_all,used_coords="dtime",start_hour_of_one_day=2) result = mpd.score(max_index_all,mem.ob_fo_mean,g="ob_hour",plot = "line",title="日最高温出现的频次") </code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=6403eb3fd8a2dbf777275ffaf4c0f6e9&amp;file=file.png" alt="" /></p> <p>从上面的数据中可以看到,预报对高温出现在14时的频次估计过高,而对17时的频次估计过低</p> <h1>日最小值标识</h1> <p><font face="黑体" color=blue size = 5><strong>is_min_of_oneday(sta,used_coords = &quot;time&quot;,start_hour_of_one_day = 0)</strong></font><br /> 统计各个站点某个时刻是否为一天当中的最小值,如果是则记为1,否则记为0。</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>rain01h_ob_fos</font></strong></td> <td style="text-align: left;">原始的<a href="https://www.showdoc.cc/nmc?page_id=3744334022014027">站点数据</a>,其中的时间序列或时效序列的间隔必须小于24小时</td> </tr> <tr> <td style="text-align: left;"><strong>used_coords</strong></td> <td style="text-align: left;">降水过程诊断所用的维度,可选项为&quot;time&quot;,&quot;dtime&quot;,分布代表在时间维度和时效维度判别最大值</td> </tr> <tr> <td style="text-align: left;"><strong>start_hour_of_one_day</strong></td> <td style="text-align: left;">记为一天的时段,默认是01-00时记为1天,类似的如果该参数等于8,则计09-08时为一天</td> </tr> <tr> <td style="text-align: left;"><font face="黑体" color=blue size=5>return</font></td> <td style="text-align: left;">站点数据,其中记录了每个站点每个时刻或时效是否为一天中的最小值,1代表是,0代表否,如果某一天的时间或时效序列不完整,则相应时刻的样本会被剔除</td> </tr> </tbody> </table> <p><strong>调用示例</strong> </p> <pre><code class="language-python">min_index_all = meb.is_min_of_oneday(temp_all,used_coords="dtime",start_hour_of_one_day=2) result = mpd.score(min_index_all,mem.ob_fo_mean,g="ob_hour",plot = "line")</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=81440b2413a1af01507bdef863e44472&amp;file=file.png" alt="" /></p> <p>在上面的示例中,预报数据是逐3小时的,一天中的第一个有效时刻是02时,因此start_hour_of_one_day设为02。</p> <pre><code class="language-python"></code></pre>

页面列表

ITEM_HTML