我正在研究一个陆地表面模型,我想用一些虚拟数据来测试。有一个数据集读取时没有错误。土壤数据如下:
<xarray.dataset>
Dimensions: (time: 1, x: 200, y: 200)
Coordinates:
* time (time) float64 1.051e+04
Dimensions without coordinates: x, y
Data variables:
t_clay (time, y, x) float32 ...
t_sand (time, y, x) float32 ...
t_silt (time, y, x) float32 ...
t_sum (time, y, x) float32 ...
s_clay (time, y, x) float32 ...
s_sand (time, y, x) float32 ...
s_silt (time, y, x) float32 ...
s_sum (time, y, x) float32 ...
latitude (y, x) float64 40.0 40.0 40.0 40.0 40.0 ... 50.0 50.0 50.0 50.0
longitude (y, x) float64 0.0 0.0656 0.1312 0.1968 ... 15.4 15.48 15.56
Attributes:
Conventions: CF-1.0
content: HARMONIZED WORLD SOIL DATABASE; first it was aggregated ...
scaling_factor: 20
我想在我的其他变量中使用相同的latitude
/longitude
网格。在
例如,辐射数据(随机生成的值)如下所示:
^{pr2}$xr.Dataset
形状与上面的土壤数据相同。longitude
&;latitude
Coordinates
存储为Data variables
。当Fortran存储为Coordinate
而不是Variable
时,它在读取“经度”时遇到了问题
谢谢!在
因此,我使用以下代码成功地从另一个
xr.Dataset
对象中的数据制作了样本:1。导入包
2。根据土壤数据初始化“骨架”
^{pr2}$3。循环每个变量,从感兴趣的变量(
Rg
)中随机抽取值,并插入到旧的xr.Dataset
提供的骨架中。我认为这个程序对于其他需要为水文和气候模型生成随机强迫数据的人来说是非常有用的。在
相关问题 更多 >
编程相关推荐