【问题标题】:Using netcdf file data in pygmt在 pygmt 中使用 netcdf 文件数据
【发布时间】:2022-01-17 19:40:18
【问题描述】:

一个小问题。有没有一种简单的方法可以将 netcdf 文件数据转换为可在 pygmt 中使用的网格? Pygmt 有以下数据集作为默认示例:

<xarray.DataArray 'elevation' (lat: 120, lon: 120)>
array([[-3539.5, -3510.5, -3557.5, ..., -3013. , -2982. , -2981.5],
       [-3583.5, -3467.5, -3575.5, ..., -2941. , -2967. , -2982.5],
       [-3663. , -3497. , -3452.5, ..., -2900.5, -2976. , -2941. ],
       ...,
       [-3600.5, -3568. , -3572.5, ..., -2558. , -2985. , -3190. ],
       [-3535.5, -3499. , -3542. , ..., -2604. , -3016. , -3091.5],
       [-3480. , -3455. , -3488.5, ..., -2758. , -3155. , -3248.5]],
      dtype=float32)
Coordinates:
  * lon      (lon) float64 -92.46 -92.38 -92.29 -92.21 ... -82.71 -82.62 -82.54
  * lat      (lat) float64 -2.958 -2.875 -2.792 -2.708 ... 6.792 6.875 6.958
Attributes:
    long_name:         elevation relative to the geoid
    units:             meters
    vertical_datum:    EMG96
    horizontal_datum:  WGS84

使用常见的 nc-read 语法后,我得到一个掩码数组。

问候

【问题讨论】:

    标签: netcdf pygmt


    【解决方案1】:

    我有一个简单的解决方案:

    nc = nc4.Dataset('filename.nc', mode='r')  # Or from siphon.ncss
    dataset = xr.open_dataset(xr.backends.NetCDF4DataStore(nc))
    

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    • PyGMT 支持使用 xarray 来处理 netcdf 文件。
    猜你喜欢
    • 1970-01-01
    • 2013-04-07
    • 2014-12-17
    • 2015-05-11
    • 2023-03-26
    • 2021-08-02
    • 1970-01-01
    • 2021-08-30
    • 2022-07-16
    相关资源
    最近更新 更多