【发布时间】:2022-01-11 09:32:24
【问题描述】:
有几个教程(example 1、example 2、example 3)关于使用 shapefile 屏蔽 NetCDF 和计算平均度量。但是,我对那些关于屏蔽 NetCDF 和提取平均值等度量的工作流程感到困惑,并且这些教程不包括提取异常(例如,2019 年的温度与基线平均温度之间的差异)。
我在这里举个例子。我下载了 2000 年到 2019 年的月度温度 (download temperature file) 和美国州级 shapefile (download shapefile)。我想根据 2000 年至 2019 年的月平均温度以及 2019 年相对于 2000 年至 2010 年的基准温度的温度异常来获得州级平均温度。具体而言,最终数据框如下所示:
| state | avg_temp | anom_temp2019 |
|---|---|---|
| AL | xx | xx |
| AR | xx | xx |
| ... | ... | ... |
| WY | xx | xx |
# Load libraries
%matplotlib inline
import regionmask
import numpy as np
import xarray as xr
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
# Read shapefile
us = gpd.read_file('./shp/state_cus.shp')
# Read gridded data
ds = xr.open_mfdataset('./temp/monthly_mean_t2m_*.nc')
......
非常感谢您提供的可以完成上述任务的明确工作流程的帮助。非常感谢。
【问题讨论】:
标签: python mask netcdf shapefile