meteva

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


输出矩阵数据

<p>[TOC]</p> <pre><code class="language-python"> import meteva.base as meb import numpy as np</code></pre> <h1>将数组输出成excel</h1> <p><font face="黑体" color=blue size = 5><strong>write_array_to_excel(array,save_path,name_list_dict,columns = None,index = None)</strong></font> </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>array</font></strong></td> <td style="text-align: left;">numpy 矩阵数据,暂时只支持1、2、3维的矩阵</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>save_path</font></strong></td> <td style="text-align: left;">数据保存路径,需要以.xlsx作为后缀</td> </tr> <tr> <td style="text-align: left;"><strong><font face="黑体" color=blue size = 5>name_list_dict</font></strong></td> <td style="text-align: left;">以字典形式存储的每个维度的描述信息,其中字典的key为维度的名称,字典的value 为维度的坐标值的列表,列表中的元素只支持字符型 和 时间类型</td> </tr> <tr> <td style="text-align: left;"><strong>columns</strong></td> <td style="text-align: left;">输出结果中excel表的列名称</td> </tr> <tr> <td style="text-align: left;"><strong>index</strong></td> <td style="text-align: left;">输出结果中excel表的行名称</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">#将一维数据输出输出到excel的示例 data1 = np.random.rand(10) name_list_dict1 = {"时效(单位:小时)":[3,6,9,12,15,18,21,24,27,30]} save_path = r"H:\test_data\output\meb\data1.xlsx" meb.write_array_to_excel(data1,save_path,name_list_dict1) </code></pre> <pre><code>数据已以excel表格形式保存至H:\test_data\output\meb\data1.xlsx</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=ddbf41d22b265f7dcfe9dfebbcb96709" alt="" /></p> <pre><code class="language-python">#将二维数据输出输出到excel的示例 data2 = np.random.rand(3,10) name_list_dict2 = {"预报成员":["ECMWF","GRAPES","NCEP"], "时效(单位:小时)":[3,6,9,12,15,18,21,24,27,30]} save_path = r"H:\test_data\output\meb\data2.xlsx" meb.write_array_to_excel(data2,save_path,name_list_dict2,index="预报成员") </code></pre> <pre><code>数据已以excel表格形式保存至H:\test_data\output\meb\data2.xlsx</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=e0b069195b6835836492ac979ab2f2b6" alt="" /></p> <pre><code class="language-python">#将二维数据输出输出到excel的示例 data3 = np.random.rand(3,4,10) name_list_dict3 = {"预报成员":["ECMWF","GRAPES","NCEP"], "检验指标":["TS评分","Bias评分","空报率","漏报率"], "时效(单位:小时)":[0,3,6,9,12,15,18,21,24,27]} save_path = r"H:\test_data\output\meb\data3.xlsx" meb.write_array_to_excel(data3,save_path,name_list_dict3,index="时效(单位:小时)",columns="预报成员") </code></pre> <pre><code>数据已以excel表格形式保存至H:\test_data\output\meb\data3.xlsx</code></pre> <p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=072a9a41ed327f786e125fe319fd0def" alt="" /></p>

页面列表

ITEM_HTML