跳转到主要内容

扩展xarray.open_dataset以接受pystac对象

项目描述

xpystac

xpystac提供将xarray.open_dataset扩展以接受pystac对象的粘合剂。

目标是只要这个库在你的环境中,你就不必担心它。

示例

搜索COGs集合

import pystac_client
import xarray as xr


catalog = pystac_client.Client.open(
    "https://earth-search.aws.element84.com/v1",
)

search = catalog.search(
    intersects=dict(type="Point", coordinates=[-105.78, 35.79]),
    collections=['sentinel-2-l2a'],
    datetime="2022-04-01/2022-05-01",
)

xr.open_dataset(search, engine="stac")

以下是一些来自行星计算机文档的示例

import planetary_computer
import pystac_client
import xarray as xr


catalog = pystac_client.Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1",
    modifier=planetary_computer.sign_inplace,
)

从参考文件读取

collection = catalog.get_collection("nasa-nex-gddp-cmip6")
asset = collection.assets["ACCESS-CM2.historical"]

xr.open_dataset(asset)

参考: https://planetarycomputer.microsoft.com/dataset/nasa-nex-gddp-cmip6#Example-Notebook

从zarr文件读取

collection = catalog.get_collection("daymet-daily-hi")
asset = collection.assets["zarr-abfs"]

xr.open_dataset(asset)

参考: https://planetarycomputer.microsoft.com/docs/quickstarts/reading-zarr-data/

安装

pip install git+https://github.com/stac-utils/xpystac

工作原理

当你调用xarray.open_dataset(object, engine="stac")时,这个库将该open调用映射到正确的库。根据object的类型,这可能是一个堆叠库(要么是odc-stacstackstac)或者返回到xarray.open_dataset本身,但是使用从pystac对象拉取的引擎和其他选项。

现有技术

这项工作受到了https://github.com/TomAugspurger/staccontainers以及https://github.com/stac-utils/pystac/issues/846中的讨论的启发

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定要选择哪个,请了解更多关于安装软件包的信息。

源代码分发

xpystac-0.1.3.tar.gz (22.3 kB 查看哈希值)

上传时间 源代码

构建分发

xpystac-0.1.3-py3-none-any.whl (6.6 kB 查看哈希值)

上传时间 Python 3

由以下机构支持