From 41c834bbaddd652a49b38b49c37448e54e7198a8 Mon Sep 17 00:00:00 2001 From: liucouhua Date: Sun, 27 Oct 2024 23:44:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E9=80=8F=E8=A7=86=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=AB=98=E7=A9=BA=E8=A6=81=E7=B4=A0=E6=A3=80=E9=AA=8C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=B8=AD=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=9C=B0=E5=BD=A2?= =?UTF-8?q?mask=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在对高空气象要素进行检验时,如果某一层的部分区域处于地面以下,在检验时理应排除在统计样本之外,改进后增加了对这些功能的支持,可以通过para中的zs和gh参数读取地面的海拔高度和某一层的位势高度数据,从而实现扣除地下数据样本的功能 --- meteva/perspact/middel_high.py | 80 ++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 14 deletions(-) diff --git a/meteva/perspact/middel_high.py b/meteva/perspact/middel_high.py index c8d67db3..2828df95 100644 --- a/meteva/perspact/middel_high.py +++ b/meteva/perspact/middel_high.py @@ -39,7 +39,12 @@ "time_type": "UT", # 预报数据时间类型是北京时,即08时起报 "multiple": 1, # 当文件数据的单位是位势米,通过乘以9.8转换成位势 "move_fo_time":0, - "veri_by":"CRA40" + "veri_by":"CRA40", + "gh":{ + "dirm": r"\\10.28.16.234\data2\AI\fuxi\Z\LLL\YYYYMMDDHH\YYYYMMDDHH.TTT.nc", #位势高度的文件路径 + "read_method": meteva.base.read_griddata_from_nc, #读取位势高度的函数 + "read_para": {}, #读取位势高度所用的函数参数 + }, }, "pa": { @@ -50,13 +55,24 @@ "time_type": "UT",#预报数据时间类型是北京时,即08时起报 "multiple":1, #当文件数据的单位是位势米,通过乘以9.8转换成位势 "move_fo_time": 12, - "veri_by": "CRA40" + "veri_by": "CRA40", + "gh": { + "dirm": r"\\10.28.16.234\data2\AI\Pangu_ERA5\Z\LLL\YYYYMMDDHH\YYYYMMDDHH.TTT.nc", #位势高度的文件路径 + "read_method": meteva.base.read_griddata_from_nc, #读取位势高度的函数 + "read_para": {}, #读取位势高度所用的函数参数 + }, }, }, + + "zs": { + "path": r"\\10.28.16.234\data2\AI\fuxi\Z\LLL\YYYYMMDDHH\YYYYMMDDHH.TTT.nc", #地形高度的文件路径 + "read_method": meteva.base.read_griddata_from_nc, #读取地形高度的函数 + "read_para": {}, #读取地形高度的函数参数 + } } -def task_of_one_p(para,middle_result_path,v_df): +def task_of_one_p(para,middle_result_path,v_df,mid0 = None,zs = None): time_cost_dict = {"total_cost":0,"veri_cost":0} time_cost_total0 = time.time() @@ -66,7 +82,10 @@ def task_of_one_p(para,middle_result_path,v_df): else: marker = meteva.perspact.get_grid_marker(grid0, step=para["step"]) mid_method = para["mid_method"] - mid_list = [] + if mid0 is None: + mid_list = [] + else: + mid_list = [mid0] save_k = 0 # 用来在收集的过程间隔一段时间报错一下结果,避免程序错误时没有任何输出导致要重头再来 v_df_group, level_list = meteva.base.group(v_df, g="level") for i in range(len(level_list)): @@ -131,11 +150,15 @@ def task_of_one_p(para,middle_result_path,v_df): if para_fo1["time_type"].lower() == "bt": time1_ = time1 + datetime.timedelta(hours=8) time1_ -= datetime.timedelta(hours=move_fo_time) - path1 = meteva.base.get_path(para_fo1["dirm"], time1_, dh + move_fo_time) - path1 = path1.replace("LLL", str(level)) - time_cost0 = time.time() - grd_fo = para_fo1["read_method"](path1, grid=para["grid"], time=time1, dtime=dh, level=level, - data_name=model, show=True, **para_fo1["read_para"]) + if para_fo1["dirm"] is not None: + path1 = meteva.base.get_path(para_fo1["dirm"], time1_, dh + move_fo_time) + path1 = path1.replace("LLL", str(level)) + time_cost0 = time.time() + grd_fo = para_fo1["read_method"](path1, grid=para["grid"], time=time1, dtime=dh, level=level, + data_name=model, show=True, **para_fo1["read_para"]) + else: + grd_fo = para_fo1["read_method"](grid=para["grid"], time=time1, dtime=dh, level=level, + data_name=model, show=True) time_cost = time.time() - time_cost0 if model not in time_cost_dict.keys(): time_cost_dict[model] = 0 @@ -144,6 +167,23 @@ def task_of_one_p(para,middle_result_path,v_df): if grd_fo is not None: grd_fo.values *= para_fo1["multiple"] time_cost0 = time.time() + + #读取位势高度用于判断是否在地下 + if zs is not None: + if para_fo1["gh"]["dirm"] is not None: + path1 = meteva.base.get_path(para_fo1["gh"]["dirm"], time1_, dh + move_fo_time) + path1 = path1.replace("LLL", str(level)) + time_cost0 = time.time() + grd_gh = para_fo1["gh"]["read_method"](path1, grid=para["grid"], time=time1, dtime=dh, + level=level, + data_name=model, show=True, **para_fo1["gh"]["read_para"]) + else: + grd_gh = para_fo1["gh"]["read_method"](grid=para["grid"], time=time1, dtime=dh, level=level, + data_name=model, show=True) + + grd_fo.values[grd_gh.values