爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 329|回复: 1

[作图] NCL计算Plumb波活动通量

[复制链接]

新浪微博达人勋

发表于 2024-6-6 11:03:07 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 是冉冉升起的冉 于 2024-6-6 11:05 编辑

结果跟摸鱼的对比了一下,但感觉在大西洋地区有一点差异,大体趋势差不多,20°低纬地区有一点奇怪,然后垂直方向没有对比;有问题联系我ing;
  1. ;///////////////////////////////////////////////////////////////
  2. ;  Calculate 3-D wave-activity flux:plumb[1985]
  3. ;///////////////////////////////////////////////////////////////
  4. ;  Written by Ran,20240606.
  5. ;  E-mail: 602023280016@nju.edu.cn

  6. ;If there is a problem with the code calculation, please contact me by email.

  7. ;Input data:hgt t u v

  8. ;Note that the data downloaded by ERA5 is the gravitational potential (unites:m^2/s^2).
  9. ;The ncep data is the gravity potential height z, which needs to be multiplied by g.

  10. ;Input data must include the entire longitude!!! Because to take the zonal deviation!!

  11. ;Return value -  Four multi-dimentional arrays containing:
  12. ;                    x-component:  Fx
  13. ;                    y-component:  Fy
  14. ;                    z-component:  Fz
  15. ;                    z_ano

  16. ;Usage: [/Fx,Fy,Fz,z_ano/] = plumb_pLLL(hgt,t,u,v)


  17. undef("plumb_pLLL")
  18. function plumb_pLLL(hgt[*][*][*][*]:numeric,t[*][*][*][*]:numeric,u[*][*][*][*]:numeric,v[*][*][*][*]:numeric)
  19. local re,sclhgt,k,pi,dName,level,lat,lon,f,wmg,ga,z,coslat,sin2lat,leveltmp,ftmp,coslattmp,sin2lattmp,t_ano,u_ano,v_ano,t_mean,dt_meandz,\
  20.         S,Stmp,dvzdlon,duzdlon,dtzdlon
  21. begin
  22. ;基本量

  23. ; Radius of the earth
  24. re      = 6.37*10^6;6378388

  25. ; scale height
  26. sclhgt  = 8000.

  27. k=0.286

  28. ; pi
  29. pi      = atan(1.0)*4.
  30. printVarSummary(hgt)
  31. dName   = getvardims(hgt)
  32. if (any(ismissing(dName(1:)))) then
  33.    print("fatal: plumb_pLLL: requires that all the rightmost dimensions be named")
  34.    exit
  35. end if
  36.     level   = hgt&$dName(1)$
  37.     lat     = hgt&$dName(2)$
  38.     lon     = hgt&$dName(3)$

  39. ; Coriolis parameter
  40. f       = lat(:)
  41. f       = (/2.*2.*pi/(60.*60.*24.)*sin(pi/180.*f)/)
  42. f@_FillValue = hgt@_FillValue

  43. ;Rotational angular velocity of the earth
  44. wmg=2.*pi/(60.*60.*24.)

  45. ; Gravitational acceleration
  46. ga      = 9.80665
  47. z=hgt*ga
  48. copy_VarMeta(hgt, z)
  49. ; cosine
  50. coslat  = cos(lat(:)*pi/180.)
  51. coslat@_FillValue = default_fillvalue(typeof(coslat))
  52. coslat  = (/where(coslat.le.0.,coslat@_FillValue,coslat)/)

  53. ; sin2lat
  54. sin2lat  = sin(2*(lat(:)*pi/180.))
  55. sin2lat@_FillValue = default_fillvalue(typeof(sin2lat))
  56. sin2lat  = (/where(sin2lat.le.0.,sin2lat@_FillValue,sin2lat)/)


  57. ; 1-D -> 4-D
  58. leveltmp   = conform_dims(dimsizes(hgt),level,1)
  59. ftmp       = conform_dims(dimsizes(hgt),f,2)
  60. coslattmp  = conform_dims(dimsizes(hgt),coslat,2)
  61. sin2lattmp = conform_dims(dimsizes(hgt),sin2lat,2)
  62. ;Zonal deviation
  63. t_ano   =dim_rmvmean_n_Wrap(t, 3)
  64. u_ano   =dim_rmvmean_n_Wrap(u, 3)
  65. v_ano   =dim_rmvmean_n_Wrap(v, 3)
  66. z_ano   =dim_rmvmean_n_Wrap(z, 3)
  67. ;printVarSummary(t_ano)
  68. ;printVarSummary(z_ano)

  69. ;Zonal mean
  70. t_mean=dim_avg_n_Wrap(t, 3)
  71. dt_meandz = center_finite_diff_n(t_mean,-sclhgt*log(level/1000.),False,0,1)


  72. S=dt_meandz+k*t_mean/sclhgt;
  73. copy_VarCoords_1(hgt, S)
  74. ;printVarSummary(S)
  75. ; 3-D -> 4-D
  76. Stmp = conform_dims(dimsizes(hgt),S,(/0,1,2/))
  77. ;printVarSummary(Stmp)

  78. ; dvz/dlon
  79. dvzdlon      =  center_finite_diff_n(v_ano*z_ano,lon*pi/180.,True,0,3)
  80. ; duz/dlon
  81. duzdlon      =  center_finite_diff_n(u_ano*z_ano,lon*pi/180.,True,0,3)
  82. ; dtz/dlon
  83. dtzdlon      =  center_finite_diff_n(t_ano*z_ano,lon*pi/180.,True,0,3)

  84. ;printVarSummary(sin2lattmp)
  85. ;printVarSummary(dvzdlon)
  86. ;printVarSummary(wmg)
  87. ;printVarSummary(coslattmp)

  88. ; x-component
  89. Fx      = leveltmp/1000.*coslattmp*v_ano*v_ano-1./(2.*wmg*re*sin2lattmp)*dvzdlon
  90. ;printVarSummary(Fx)

  91. ; y-component
  92. Fy      = leveltmp/1000.*coslattmp*(-u_ano*v_ano+1./(2.*wmg*re*sin2lattmp)*duzdlon)

  93. ; z-component
  94. Fz      = leveltmp/1000.*coslattmp*(ftmp/Stmp*(v_ano*t_ano-1./(2.*wmg*re*sin2lattmp)*dtzdlon))

  95. copy_VarCoords(hgt,Fx)
  96. copy_VarCoords(Fx,Fy)
  97. copy_VarCoords(Fx,Fz)

  98. Fx@units = "m^2/s^2"
  99. Fx@var_desc = "wave-activity flux"
  100. Fx@long_name = "x-component of wave-activity flux (Plumb1985)"

  101. Fy@units = "m^2/s^2"
  102. Fy@var_desc = "wave-activity flux"
  103. Fy@long_name = "y-component of wave-activity flux (Plumb1985)"

  104. Fz@units = "Pa m/s^2"
  105. Fz@var_desc = "wave-activity flux"
  106. Fz@long_name = "z-component of wave-activity flux (Plumb1985)"

  107. return [/Fx,Fy,Fz,z_ano/]

  108. end
复制代码
Snipaste_2024-06-06_11-01-03.png Snipaste_2024-06-06_11-00-38.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2024-6-6 15:17:54 | 显示全部楼层
Fx计算的时候发现少打了一个括号ing (v_ano*v_ano-1./(2.*wmg*re*sin2lattmp)*dvzdlon)
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表