Anomaly
汇总
根据时间维度间隔和异常计算方法,创建包含输入多维栅格的异常像素值的栅格对象。
讨论
使用 Anomaly 函数可计算多维栅格对象中时间变量的像素值异常。例如,如果具有每日降雨量数据,则可以查找整个数据集中与每月平均降雨量值高度不同的像素。
可通过三种数学方法使用此函数计算异常值,如下所示:
与平均值的差值 = x - µ
x = 剖切中的像素值
μ = 给定时间间隔内该像素值的平均值
与平均值的百分比差值 = |x - µ| /[(x + µ)/2]
x = 剖切中的像素值
μ = 给定时间间隔内该像素值的平均值
|x - µ| = 该值与平均值之差的绝对值
平均值百分比 = x / µ
x = 剖切中的像素值
μ = 给定时间间隔内该像素值的平均值
栅格对象的引用栅格数据集是临时的。要将其设置为永久,可以调用栅格对象的 save 方法。
语法
Anomaly(in_raster, {dimension_name}, {anomaly_type}, {temporal_interval}, {ignore_nodata})
| 参数 | 说明 | 数据类型 |
|---|---|---|
|
in_raster |
输入多维栅格。 |
Raster |
|
dimension_name |
执行异常定义时所沿的维度名称。 (默认值为 StdTime) |
String |
|
anomaly_type |
指定用于计算异常的方法。
(默认值为 DIFFERENCE_FROM_MEAN) |
String |
|
temporal_interval |
指定用于计算平均值的时间间隔。
(默认值为 None) |
String |
|
ignore_nodata |
指定分析中是否忽略 NoData 值。
(默认值为 True) |
Boolean |
返回值
| 数据类型 | 说明 |
|---|---|
|
Raster |
输出异常多维栅格。 |
代码示例
计算所有剖切的降水量异常和月降水量异常值。
import arcpy
from arcpy.sa import *
in_raster = Raster("C:/sapyexamples/data/ClimateData_Daily.nc", True)
# Choose the precipitation variable
prcp_raster = Subset(in_raster, variables = 'prcp')
# Calculate percent of mean anomalies,
# where the mean_value is the mean of all slices
prcp_anomaly = Anomaly(prcp_raster, anomaly_type = 'PERCENT_OF_MEAN')
# Calculate the difference from mean,
# where the mean_value is the mean of each year
prcp_monthly_anomaly = Anomaly(prcp_raster, temporal_interval = 'YEARLY')