xd_interp = da_xd.interp(longitude=newlon, latitude=newlat) yd_interp = da_yd.interp(longitude=newlon, latitude=newlat) zd_interp = da_zd.interp(longitude=newlon, latitude=newlat) #missing value dfx = xd_interp.to_pandas() dfy = yd_interp.to_pandas() dfz = zd_interp.to_pandas() if(dfx.isnull().values.sum() != 0 or dfy.isnull().values.sum() != 0\ or dfz.isnull().values.sum() != 0): logging.warning("missing value exists in interpolation") continue xdtc = xd_interp.values.reshape(nlat, nlon) ydtc = yd_interp.values.reshape(nlat, nlon) zdtc = zd_interp.values.reshape(nlat, nlon) xdnp, ydnp, zdnp = librotate.tc2np(lonc, latc, xdtc, ydtc, zdtc) #debug xb, yb, zb = librotate.np2tc(lonc, latc, xdnp, ydnp, zdnp) logging.debug(f"tc2np x {np.max(np.abs(xdtc-xb))}") logging.debug(f"tc2np y {np.max(np.abs(ydtc-yb))}") logging.debug(f"tc2np z {np.max(np.abs(zdtc-zb))}") #missing value if(np.isnan(xdnp).sum() != 0 or np.isnan(ydnp).sum() != 0 or \ np.isnan(zdnp).sum() != 0): logging.warning("missing value exists in tc2np") continue lonnp = lonin.reshape(1, -1) latnp = latin.reshape(-1, 1) #unp,vnp = librotate.xyzd2uv(xdnp,ydnp,zdnp,lonnp) unp, vnp = librotate.xyzd2uv(xdnp, ydnp, zdnp, lonnp, latnp) #debug
#for j in range(nlat): # for i in range(nlon): # if msk[j, i]: # xdnp[:, :, j, i] = xd_interp.values[:, :, k] # ydnp[:, :, j, i] = yd_interp.values[:, :, k] # zdnp[:, :, j, i] = zd_interp.values[:, :, k] # k += 1 # else: # xdnp[:, :, j, i] = 0.0 # ydnp[:, :, j, i] = 0.0 # zdnp[:, :, j, i] = 0.0 #logging.debug(xdnp.size - np.isnan(xdnp).sum()) #exit() xdtc, ydtc, zdtc = librotate.np2tc(lonc, latc, xdnp, ydnp, zdnp) #debug xb, yb, zb = librotate.tc2np(lonc, latc, xdtc, ydtc, zdtc) logging.debug(f"np2tc x {np.max(np.abs(xdnp-xb))}") logging.debug(f"np2tc y {np.max(np.abs(ydnp-yb))}") logging.debug(f"np2tc z {np.max(np.abs(zdnp-zb))}") #exit() #missing value if(np.isnan(xdtc).sum() != 0 or np.isnan(ydtc).sum() != 0 \ or np.isnan(zdtc).sum() != 0): logging.warning("missing value exists in np2tc") continue #lonnp = lonin.reshape(1,-1) #lontc = lon[None, None, None, :] #lattc = lat[None, None, :, None] #unp,vnp = librotate.xyzd2uv(xdnp,ydnp,zdnp,lonnp) utc, vtc = librotate.xyzd2uv(xdtc, ydtc, zdtc, lontc[None, None, :], lattc[None, None, :])