pip install gma==2.0.4
注意:此版本没有Linux版!
编译gma的Linux虚拟机崩溃了,暂时无法编译Linux版gma 2.0.4。暂时无法修复,本期Linux版暂停发布。
?1、io.CreateFeature:由点、wkt、wkb、json或kml字符创建Feature。
?2、climet.Index.RMI:新增相对湿润度指数(RMI)计算。
参考资料:http://image.data.cma.cn/staticDry/article/20170927151824947.pdf
?io.CreateFeatureFromPoint:由于构建了更加强大的CreateFeature函数,此函数将会弃用,但不会移除。
?rsvi.TVDI:修复一个参数检查不通过的问题(由于1.X 向 2.X转换不完全引起)。
?climet.SPI/SPEI:重构此类函数,并增加新的功能。现在你可以:
??目前支持:
三种分布(Distribution):‘Gamma’, ‘LogLogistic’, ‘Pearson3’ ;
三种参数拟合方法(FitMethod):‘LMoment’, ‘LMoment2’, ‘MLE’ ;
共计 9 种组合方式。
??现在,你可以选择使用部分数据(基于周期)进行参数拟合(早期版本是使用全部数据),并将其应用到全部数据上。
??现在,如果Axis上有不同长度的有效数据,gma会根据有效数据量,为每组数据配置不同的N。
示例数据及下载:https://gma.luosgeo.com/UserGuide/climet/Index/RMI.html
from gma import io, climet, osf
Layer = io.ReadVector("Luoyang.gpkg")
import pandas as pd
Data = pd.read_excel("PRE_ET0.xlsx")
PRE = Data['PRE'].values
ET0 = Data['ET0'].values
# 分别计算1个月、3个月、6个月、12个月、24个月、60个月尺度的 RMI 数据
RMI1 = climet.Index.RMI(PRE, ET0)
RMI3 = climet.Index.RMI(PRE, ET0, Scale = 3)
RMI6 = climet.Index.RMI(PRE, ET0, Scale = 6)
RMI12 = climet.Index.RMI(PRE, ET0, Scale = 12)
RMI24 = climet.Index.RMI(PRE, ET0, Scale = 24)
RMI60 = climet.Index.RMI(PRE, ET0, Scale = 60)
??绘图:
import matplotlib.pyplot as plt
PAR = {'font.sans-serif': 'Times New Roman',
'axes.unicode_minus': False,
}
plt.rcParams.update(PAR)
## 标记一下不同时间尺度结果变量的不同
S = [1,3,6,12,24,60]
## 准备横坐标(年份)的标签
X = range(len(PRE))
Date = osf.DateSeries('198101','202101',DateDelta='M', Format='%Y%m').strftime('%Y-%m')
## 循环绘制 6 个尺度的 SPEI 结果
plt.figure(figsize = (18, 14), dpi = 300)
for i in range(6):
ax = plt.subplot(4, 2, i + 1)
### 绘制数据
ax.plot(X, eval(f'RMI{S[i]}'), linewidth = 0.8, c = 'gray')
### 添加图例
ax.legend([f'RMI{S[i]}'],frameon = False)
### 添加横坐标标签
ax.set_xticks(X[::72], Date[::72], rotation = 0)
### 定义横纵坐标显示范围
ax.set_xlim(-12)
ax.set_ylim(-3.8, 3.8)
### 绘制干(-1)湿(1)分界线
plt.axhline(y = -1, ls = (0,(6,6)), c = "r", linewidth = 0.4)
plt.axhline(y = 1, ls = (0,(6,6)), c = "b", linewidth = 0.4)
### 绘制其他网格
ax.grid(True, linestyle = (0,(6,6)), linewidth = 0.3)
## 修改子图边距
plt.subplots_adjust(wspace = 0.04, hspace = 0.18)
plt.show()
help(climet.Index.SPEI)
Help on cython_function_or_method in module gma.climet.Index:
SPEI(PRE, PET, Axis=None, Scale=1, Periodicity=12, Distribution='LogLogistic', FitMethod='LMoment', Calibration=None)
Calculate the Standardized Precipitation Evapotranspiration Index.
Parameters
----------
PRE: array.
Precipitation (mm).
PET: array.
Potential evapotranspiration (mm).
**Optional
----------
Axis = int. Default None.
Calculation axis. If not set (None), multidimensional data will be expanded to 1 dimension for calculation.
Scale = int. Default 1.
Time scale. For example: 1, 3 or others.
Periodicity = int. Default 12.
Periodicity of data. For example: the monthly scale can have a period of 12.
Distribution = str. Default 'LogLogistic'.
Distribution type to be used for the internal fitting/transform computation.
Supported distributions include:
'Gamma', 'LogLogistic', 'Pearson3'.
FitMethod = str. Default 'LMoment'.
Fitting methods for distribution parameters.
Supported method include:
'MLE': Maximum Likelihood Estimation,
'LMoment': L-Moment Estimation(PWD),
'LMoment2': L-Moment Estimation.
Calibration = list, slice or None. Default None.
Fit the calibration interval of distribution parameter data, Based on the Periodicity.
Default(None) using all data. For example:
Select the data from 1-5 Periodicity to fit parameters:
Calibration = [0, 5]
Then apply the parameter fitting results to all data.
*Note: Scale, Periodicity, Calibration are based on calculated axis!
Returns
----------
Type: array.
References
----------
Vicente-Serrano S M , S Beguería, JI López-Moreno. A Multiscalar Drought Index
Sensitive to Global Warming: The Standardized Precipitation Evapotranspiration Index[J].
Journal of Climate, 2010, 23(7):1696-1718.