当前位置:   article > 正文

Python绘制nino指数IEP和ICP学习笔记_怎么计算nino3指数

怎么计算nino3指数

一、数据下载

# 文件地址:https://psl.noaa.gov/data/gridded/data.noaa.ersst.v4.html

厄尔尼诺/拉尼娜事件的主要监测关键区,包括NINO1+2区(90°W-80°W,10°S-0°)、
NINO3区(150°W-90°W,5°S-5°N)、NINO4区(160°E-150°W,5°S-5°N)
和NINO3.4区(170°W-120°W,5°S-5°N)。

承上一篇文章

NINO3.4的3个月滑动平均绝对值达到或超过0.5℃、持续至少5个月,判定为一次厄尔尼诺/拉尼娜事件(指数≥0.5℃为厄尔尼诺事件;指数≤-0.5℃为拉尼娜事件);以NINO3.4满足事件判定的时间为持续时间。
在事件过程中,NINO3.4的3个月滑动平均绝对值达到最大的时间和数值分别定义为事件的峰值时间和峰值强度。然后,用 IEP和 ICP来判定事件的类型:事件过程中 
IEP的绝对值达到或超过0.5℃且持续至少3个月的类型判定为东部型事件;事件过程中 
ICP的绝对值达到或超过0.5℃且持续至少3个月的类型判定为中部型事件。
若一次事件中同时包含上述两种情况、存在两种类型间的转换,则将事件峰值所在类型定义为事件主体类型,另一种为非主体类型,整个事件的类型以事件主体类型为准。

计算ICP和IEP

IEP=Inino3-α*Inino4

ICP=Inino4-α*Inino3

若nino3*nino4>0.4,α=0.4,否则为0

二、数据处理和绘图

  1. # 导入库
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. import netCDF4 as nc
  5. # 设置中英文字体
  6. from matplotlib import rcParams
  7. config = {
  8. "font.family":'serif',
  9. "font.size": 14,
  10. "mathtext.fontset":'stix',
  11. "font.serif": ['Times New Roman']}
  12. rcParams.update(config)
  13. # 需要加载的数据集
  14. path= r"E:\sst.mnmean.v3.nc" # 1854.01-2020.02年的月均sst
  15. # time<1994> 1994/12=166,即每月测量的平均气温,总共有1994个月,精度为2°
  16. f= nc.Dataset(path)
  17. nsst1=f.variables['sst'][1512:-1,42:47,105:136]#1980-2020
  18. nsst1_3 = f.variables['sst'][1512:1884,42:47,105:136]#1980-2010-NINO3平均海温
  19. nsst2=f.variables['sst'][1512:-1,42:47,80:106]#1980-2020
  20. nsst2_4 = f.variables['sst'][1512:1884,42:47,80:106]#1980-2010-NINO4平均海温
  21. #计算参考https://northfar.net/nino-intro/
  22. #计算多年每个月的平均海温
  23. #Nino3区域
  24. list1=[]
  25. for i in range(0,12):
  26. a = np.mean(nsst1_3[i:-1:12,:,:],axis=0)
  27. list1.append(a)
  28. #Nino4区域
  29. list2=[]
  30. for i in range(0,12):
  31. a = np.mean(nsst2_4[i:-1:12,:,:],axis=0)
  32. list2.append(a)
  33. # 将每个月的平均海温从nsst中减去
  34. #Nino3区域
  35. anomalies1 = nsst1.copy()
  36. for i in range(0, 12):
  37. anomalies1[i:-1:12, :, :] -= list1[i]
  38. #Nino4区域
  39. anomalies2 = nsst2.copy()
  40. for i in range(0, 12):
  41. anomalies2[i:-1:12, :, :] -= list2[i]
  42. #计算区域平均nino3.4指数
  43. a1 = np.mean(anomalies1, axis=(1, 2))
  44. a1 = a1[:-1]
  45. a2 = np.mean(anomalies2, axis=(1, 2))
  46. a2 = a2[:-1]
  47. # 根据条件计算a
  48. condition = a1 * a2 > 0.4
  49. a_3 = np.where(condition, a1, a1 - a2 * 0.4)#IEP
  50. a_4 = np.where(condition, a2, a2 - a1 * 0.4)#ICP
  51. time = np.arange(1980 , 2020, 1/12) # 修改这里,确保与数据的时间范围一致
  52. #绘图
  53. # 创建两个子图
  54. fig, (ax, bx) = plt.subplots(2, 1, figsize=(20, 15))
  55. # 在第一个子图(ax)上绘制IEP
  56. ax.plot(time, a_3, 'black', alpha=1, linewidth=2)
  57. ax.fill_between(time, 0, a_3, a_3 > 0, color='red', alpha=0.75)
  58. ax.fill_between(time, 0, a_3, a_3 < 0, color='blue', alpha=0.75)
  59. ax.set_ylabel('IEP [$^oC$]')
  60. ax.set_title('Historical IEP and ICP 40-year (1980-2020)')
  61. # 在第二个子图(bx)上绘制ICP
  62. bx.plot(time, a_4, 'k', alpha=1, linewidth=2)
  63. bx.fill_between(time, 0, a_4, a_4 > 0, color='red', alpha=0.75)
  64. bx.fill_between(time, 0, a_4, a_4 < 0, color='blue', alpha=0.75)
  65. bx.set_xlabel('Years')
  66. bx.set_ylabel('ICP [$^oC$]')
  67. # 设置 y 轴范围和刻度间隔
  68. ax.set_ylim(-2.5, 3)
  69. ax.set_yticks(np.arange(-2.5, 3.5, 0.5))
  70. bx.set_ylim(-2.5, 3)
  71. bx.set_yticks(np.arange(-2.5, 3.5, 0.5))
  72. # 添加水平虚线
  73. ax.axhline(y=0.5, c='k', lw=0.8, ls='--')
  74. ax.axhline(y=-0.5, c='k', lw=0.8, ls='--')
  75. bx.axhline(y=0.5, c='k', lw=0.8, ls='--')
  76. bx.axhline(y=-0.5, c='k', lw=0.8, ls='--')
  77. # 显示图形
  78. plt.show()

结果如下

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/889009
推荐阅读
相关标签
  

闽ICP备14008679号