def griddata_from_cmadaas_json(json,time=None,dtime=None): try: lonS = round(json['startLon'],4) # lonE = round(json['endLon'],3) latS = round(json['startLat'],4) # latE = round(json['endLat'],3) dlon = round(json['lonStep'],4) dlat = round(json['latStep'],4) nlon = int(json['lonCount']) nlat = int(json['latCount']) lonE = lonS + (nlon-1)*dlon latE = latS + (nlat-1)*dlat #print(lonS,dlon,nlon,lonE) data = np.array(json['DS']) #data # print(data.shape) if time is not None: if not isinstance(time,list): time = [time]#确保time为列表 if dtime is not None: if not isinstance(dtime,list): dtime = [dtime]#确保dtime为列表 # print(time,dtime) grid_info = meb.grid([lonS,lonE,dlon],[latS,latE,dlat] ,gtime = time ,dtime_list=dtime) #print(grid_info) grid = meb.grid_data(grid_info,data) except Exception as data: print(json) return None return grid
def plot_values(dataset_ob, grd_ob, grd_fo, cmap): data_Xlabeled = grd_ob data_Ylabeled = grd_fo #整理无坐标信息的格点场的坐标:原始的观测场和预报场的经纬度范围应该是对应的 glon = [ dataset_ob["lon"].values[0], dataset_ob["lon"].values[-1], dataset_ob["lon"].values[1] - dataset_ob["lon"].values[0] ] #经度的起点、终点、间隔 glat = [ dataset_ob["lat"].values[0], dataset_ob["lat"].values[-1], dataset_ob["lat"].values[1] - dataset_ob["lat"].values[0] ] #纬度的起点、终点、间隔 grid1 = meb.grid(glon, glat) data_Xlabeled_tr = meb.grid_data(grid1, data_Xlabeled) data_Ylabeled_tr = meb.grid_data(grid1, data_Ylabeled) a = data_Xlabeled_tr b = data_Ylabeled_tr #colorbar生成 #cmap, clev = meb.def_cmap_clevs(meb.cmaps.mode, vmax = np.max((np.max(a), np.max(b)))) #clev = meb.def_cmap_clevs(meb.cmaps.mode, vmax = np.max((np.max(a), np.max(b)))) #meb.tool.color_tools.show_cmap_clev(cmap, clev) #展示colorbar #meb.tool.plot_tools.plot_2d_grid_list([a, b], cmap = cmap, clevs = clev) meb.tool.plot_tools.plot_2d_grid_list([a, b], cmap=cmap, vmax=np.max((np.max(a), np.max(b))))
def get_grd(dataset_ob, data): #dataset_ob参数是为了获取原始场的起始经纬度坐标和间隔 #整理无坐标信息的格点场的坐标:原始的观测场和预报场的经纬度范围应该是对应的 glon = [ dataset_ob["lon"].values[0], dataset_ob["lon"].values[-1], dataset_ob["lon"].values[1] - dataset_ob["lon"].values[0] ] #经度的起点、终点、间隔 glat = [ dataset_ob["lat"].values[0], dataset_ob["lat"].values[-1], dataset_ob["lat"].values[1] - dataset_ob["lat"].values[0] ] #纬度的起点、终点、间隔 grid1 = meb.grid(glon, glat) data_tr = meb.grid_data(grid1, data) return data_tr
def plot_ids(dataset_ob, grd_ob, grd_fo): data_Xlabeled = grd_ob data_Ylabeled = grd_fo #整理无坐标信息的格点场的坐标:原始的观测场和预报场的经纬度范围应该是对应的 glon = [ dataset_ob["lon"].values[0], dataset_ob["lon"].values[-1], dataset_ob["lon"].values[1] - dataset_ob["lon"].values[0] ] #经度的起点、终点、间隔 glat = [ dataset_ob["lat"].values[0], dataset_ob["lat"].values[-1], dataset_ob["lat"].values[1] - dataset_ob["lat"].values[0] ] #纬度的起点、终点、间隔 grid1 = meb.grid(glon, glat) data_Xlabeled_tr = meb.grid_data(grid1, data_Xlabeled) data_Ylabeled_tr = meb.grid_data(grid1, data_Ylabeled) a = data_Xlabeled_tr b = data_Ylabeled_tr meb.tool.plot_tools.plot_2d_grid_list([a, b], cmap="mode", vmax=np.max( (np.max(a), np.max(b))) + 1)
getTimeOb.qiBaoShiJian[2:-2] + '.' + str(x).zfill(3) for x in range(1, 25) ] listFileSrc = [qibaoshijian + '.' + str(x).zfill(3) for x in range(13, 37)] ################从FTP下载资料 ftpOb = FtpLoad(ftpHost, ftpPort, ftpUsr, ftpPwd) ftpConnect = ftpOb.ftpConnet # fileList = ftpConnect.nlst('/20200915') # print(fileList) for eFile in listFileSrc: try: ftpOb.ftp_download(pathDstOrig + eFile, '/20' + qibaoshijian[:-2] + pathFTPBase + eFile) ########################插值切片 grd = meb.read_griddata_from_micaps4(pathDstOrig + eFile) grid1 = meb.grid([89.3, 102.95, 0.05], [31.4, 39.4, 0.05]) grd1 = meb.interp_gg_linear(grd, grid1) save_path = pathDstOrig + eFile meb.write_griddata_to_micaps4(grd1, save_path, effectiveNum=2) except Exception as downloadError: print(downloadError) # ##############拷贝############## try: for ee in range(len(listFileDst)): shutil.copy(pathDstOrig + listFileSrc[ee], pathDst + listFileDst[ee]) except Exception as e: print(e) #######################选取最大最小值 try: finalData = get_Tmost_array(listFileDst)