Link Search Menu Expand Document

CAMS高度之內插方式

Table of contents

背景

pk+1/2 = Ak+1/2 + Bk+1/2ps

pk = 1/2 (pk-1/2 + pk+1/2)

  • 式中的A/B值,如下表所示。
na [Pa]bph [hPa]pf [hPa]Geopotential Altitude [m]Geometric Altitude [m]Temperature [K]Density [kg/m^3]
1370.0000001.0000001013.25001012.049410.0010.00288.091.223803
1360.0000000.9976301010.84871009.536330.9630.96287.951.221341
1353.7578130.9950031008.22391006.790053.9253.92287.801.218650
13422.8359380.9919841005.35621003.790679.0479.04287.641.215710
13362.7812500.9885001002.22501000.5165106.54106.54287.461.212498
23.1022410.0000000.03100.025573721.5874584.91209.210.000042
12.0003650.0000000.02000.010079301.7980301.65198.050.000018
00.0000000.0000000.000000-----
  • 由於CAMS並不提供各層壓力的下載、而按照上述計算式各層的壓力會隨時間、位置而異,如需精確校正壓力,必須計算各個時間框架的3維壓力。
  • 壓力的內插,可以使用wrf-python的函數(詳範例)。
  • WRF 24層對應到ifs之層數(約略對照地理高度求得
    • kk= ['137', '135', '133', '129', '125', '122', '120', '117', '114', '112', '110', '107', '105', '101', '96', '92', '87', '83', '78', '73', '67', '61', '56', '51']

程式設計

from pandas import *
import netCDF4
from wrf import (getvar, interplevel)

df=read_csv('/nas1/ecmwf/CAMS/CAMS_global_atmospheric_composition_forecasts/2022/heights.csv')
cname={'A':'a [Pa]','B':'b'}
for s in 'AB':
  for i in '01':
    exec(s+i+'=np.array([df.loc[df.n==int(k)-'+i+',"'+cname[s]+'"].values[0] for k in kk])')

root='/nas2/cmaqruns/2022fcst/grid45/wrfout/wrfout_d01_'
fnames=[root+str(i) for i in range(6)]
nc = netCDF4.Dataset(fnames[0], 'r')
nt,nlay,nrow,ncol=(nc.dimensions[i].size for i in ['Time','bottom_top','south_north','west_east'])
slp=np.zeros(shape=(nt*5,nrow,ncol))
pres=np.zeros(shape=(nt*5,nlay,nrow,ncol))
dens=np.zeros(shape=(nt*5,nlay,nrow,ncol))
p=np.zeros(shape=(nt*5+1,24,nrow,ncol))

t0=0
for fname in fnames:
  nc = netCDF4.Dataset(fname, 'r')
  nt=nc.dimensions['Time'].size
  for i in range(nt):
    slp[t0+i,:,:]=getvar(nc, "slp",timeidx=i)
    pres[t0+i,:,:,:]=getvar(nc, "pressure",timeidx=i)
  nc.close()
  t0+=nt
fname='/nas2/cmaqruns/2022fcst/grid45/mcip/DENS/METCRO3D.'+bdate.strftime('%Y%m%d')
nc = netCDF4.Dataset(fname,'r')
nt1,nlay1,nrow1,ncol1=nc.variables['DENS'].shape
dens1=nc.variables['DENS'][bt,:,:,:]
nc.close()
dens[:,:,:,:]=np.mean(dens1,axis=(0,2,3))[None,:,None,None]
dens[:,:,1:-1,1:-1]=dens1[:,:,:,:]  
p[:,:,:,:] =(A0[None,:,None,None]/100+B0[None,:,None,None]*slp[:,None,:,:])/2.
p[:,:,:,:]+=(A1[None,:,None,None]/100+B1[None,:,None,None]*slp[:,None,:,:])/2.
dens1 = interplevel(dens, pres, p)[::3,:,2:-2,2:-2]