【问题标题】:Interpolation and increasing spatial resolution of netfdf data插值和增加 netfdf 数据的空间分辨率
【发布时间】:2021-02-08 00:32:36
【问题描述】:

如何提高 netfdf 数据的分辨率以在 python 中提供给 CNN? xarray 中是否有任何功能可以做同样的事情?

提前致谢。

【问题讨论】:

  • 他们的网站上有使用 xarray 进行插值的示例:xarray.pydata.org/en/stable/interpolation.html。这就是你要找的吗?
  • @drcrisp 我也希望重新网格化数据。目前我的数据有纬度(-90,90,0.25)和经度(0,360,0.25)。我想将其转换为纬度(-90,90,0.125)和经度(0,360,0.125)。然后插值相同。最终目标是提高空间分辨率。

标签: python geospatial netcdf python-xarray


【解决方案1】:

您可以使用 xarray 插值来实现您想要的。您必须定义要插入的新纬度和经度,并将其传递给 xarray interp 函数。请参阅下面的示例

import xarray as xr
import numpy as np
import matplotlib.pyplot as plt

# Create sample data
dx  = 0.25
lon = np.arange(0, 360, dx)
lat = np.arange(-90, 90+dx, dx)
data = 10 * np.random.rand(len(lat), len(lon))
data_set = xr.Dataset({"temp": (["lat", "lon"], data)},
                 coords={"lon": lon,"lat": lat})

# Just checking the datasets are not empty
print(data_set)

# Create new lat and lon
dx_new = 0.125
newlon = np.arange(0, 360, dx_new)
newlat = np.arange(-90, 90+dx_new, dx_new)

# Interpolate
data_set_interp = data_set.interp(lat=newlat, lon=newlon)

# Check output
print(data_set_interp)

【讨论】:

    猜你喜欢
    • 2015-09-23
    • 1970-01-01
    • 1970-01-01
    • 2022-08-22
    • 1970-01-01
    • 2021-11-10
    • 2013-11-29
    • 1970-01-01
    相关资源
    最近更新 更多