Metadata-Version: 2.5
Name: cmipget
Version: 0.1.0
Summary: Agent-ready CMIP7 & CMIP6 data downloader (Python SDK, CLI, MCP server, and Agent Skill)
Project-URL: Homepage, https://github.com/Radianjayjay/cmipget
Project-URL: Repository, https://github.com/Radianjayjay/cmipget
Project-URL: Issues, https://github.com/Radianjayjay/cmipget/issues
Project-URL: Changelog, https://github.com/Radianjayjay/cmipget/blob/main/CHANGELOG.md
Project-URL: ORCID, https://orcid.org/0009-0000-2806-6771
Project-URL: ResearchGate, https://www.researchgate.net/profile/Jie-Ren-126
Author-email: Jie Ren <renjie22@mails.ucas.ac.cn>
License: MIT
License-File: LICENSE
Keywords: climate,cmip6,cmip7,esgf,mcp,netcdf,stac
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: mcp<3,>=1.10
Requires-Dist: pydantic>=2.0
Requires-Dist: rich>=13.0
Requires-Dist: tomli>=2.0; python_version < '3.11'
Requires-Dist: typer>=0.19
Provides-Extra: cloud
Requires-Dist: aiohttp>=3.11; extra == 'cloud'
Requires-Dist: cftime>=1.6; extra == 'cloud'
Requires-Dist: fsspec>=2024.1; extra == 'cloud'
Requires-Dist: gcsfs>=2024.1; extra == 'cloud'
Requires-Dist: h5netcdf>=1.3; extra == 'cloud'
Requires-Dist: s3fs>=2024.1; extra == 'cloud'
Requires-Dist: xarray>=2025.1; extra == 'cloud'
Requires-Dist: zarr>=2.16; extra == 'cloud'
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: subset
Requires-Dist: cftime>=1.6; extra == 'subset'
Requires-Dist: h5netcdf>=1.3; extra == 'subset'
Requires-Dist: xarray>=2024.1; extra == 'subset'
Description-Content-Type: text/markdown

# cmipget

[![CI](https://github.com/Radianjayjay/cmipget/actions/workflows/ci.yml/badge.svg)](https://github.com/Radianjayjay/cmipget/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/cmipget.svg)](https://pypi.org/project/cmipget/)
[![Python](https://img.shields.io/pypi/pyversions/cmipget.svg)](https://pypi.org/project/cmipget/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

**Agent-ready CMIP7 & CMIP6 climate model data downloader** — one core engine with four entrypoints: **Python SDK**, **CLI**, **MCP Server**, and **Agent Skill (`cmipget-agent`)**.

Built directly on the modern **ESGF-NG STAC API** (`discovery.west.esgf.io` & `discovery.east.esgf.io`) to succeed legacy `acccmip6` / Solr workflows for both **CMIP7** and **CMIP6**.

[中文文档 (README_zh.md)](README_zh.md)

---

## Use with AI Agents (No Coding Required)

Even if you do not write code, you can paste this repository URL (or `cmipget`) to an AI coding/desktop agent (Claude Code, Codex, Cursor, Antigravity, Cherry Studio, etc.) and describe what data you want in plain English or Chinese:

> *"Use https://github.com/Radianjayjay/cmipget (or `uvx cmipget`) and follow `skills/cmipget-agent/SKILL.md` to check available CMIP7 monthly near-surface air temperature (`tas`) for `historical`, show me the size first, and download one member per model into `./data`."*

- **Terminal Agents**: zero-install via `uvx cmipget ... --json`, or install the bundled skill:
  ```bash
  pip install cmipget
  cmipget skill install --target agents   # or: claude | codex | cursor | antigravity
  ```
- **MCP Clients**: print ready-to-paste MCP server config:
  ```bash
  cmipget mcp config
  ```
  ```json
  {
    "mcpServers": {
      "cmipget": {
        "command": "uvx",
        "args": ["cmipget", "mcp"]
      }
    }
  }
  ```

---

## Key Features

- **CMIP7 + CMIP6 Unified Engine**: defaults to `cmip7` (`MIP-DRS7`, `branding_suffix`, `region`) and seamlessly supports `-p cmip6` (`table_id`) or `-p all` cross-generation search.
- **Cross-Generation Hints & CN/EN Term Resolution**: detects legacy CMIP6 habits (`ssp245`, `Amon`) in CMIP7 queries and suggests exact replacements (`scen7-m`, `frequency=mon + realm=atmos`) without silent guessing; resolves Chinese/English climate terms (`地表气温` -> `tas`, `高排放` -> `scen7-h` / `ssp585`).
- **Two-Phase Safe Planning (`plan` -> `download`)**: estimates file counts, total GB, free disk space, and flags variant/branding/grid ambiguities (`--one-member` picks `r1i1p1f1` / lowest member). MCP and CLI enforce a `10 GB` confirmation guard by default.
- **Resilient Download Engine**:
  - Async concurrency, `.part` HTTP `Range` resume, atomic commit, and **automatic SHA-256 verification** (`file:checksum` multihash).
  - **Toggleable multi-segment Range parallel download (`--segmented`)** to accelerate throttled ESGF single-stream servers on large `.nc` files.
  - **Multi-Source Resilience & Provenance**: persistent host health & EWMA speed ranking (`host_stats.json`), cross-node STAC + CMIP6 legacy ESGF Solr checksum-verified replica fallback (`--solr-fallback`), user-configurable mirrors (`--mirror` / `~/.config/cmipget/mirrors.toml`), shared read-only pool reuse (`--local-root`), `--complete` multi-experiment/variable filtering, `--with-cell-measures` (`areacello`/`areacella`), opt-in `--probe-missing` (THREDDS `catalog.xml` + time-gap URL probing marked unverified), `cmipget audit` retraction/update checks, and Pangeo GCS/AWS CMIP6 cloud Zarr search & NetCDF export (`cmipget cloud search` / `cmipget cloud download` via `cmipget[cloud]`).
  - Directory-locked `manifest.json` + offline `cmipget verify`, detached background jobs (`--background`), and exports to `urls`, `aria2c`, `wget`, `globus`, `opendap`, and `kerchunk`.

---

## Installation

```bash
pip install cmipget
# Optional third-party Pangeo GCS/AWS cloud Zarr NetCDF export:
pip install "cmipget[cloud]"
# or run without global install:
uvx cmipget --help
```

---

## CLI Quickstart

`cmipget` supports both explicit flags and `acccmip6`-style short flags (`-m`, `-e`, `-v`, `-f`, `-r`, `-yr`, `-rlzn`), and every command accepts `--json`:

```bash
# 1. Resolve Chinese/English terms or validate query flags
cmipget check "地表气温" "高排放" -p cmip7

# 2. Explore live models/experiments/variables on ESGF-NG
cmipget facets -p cmip7 -v tas

# 3. Search datasets
cmipget search -p cmip7 -e historical -v tas -f mon --one-member

# 4. Preview download size, disk check, and warnings
cmipget plan -o ./cmip_data -p cmip7 -m ACCESS-ESM1-6 -e historical -v tas -f mon -yr 1990-2014

# 5. Download (add --segmented for multi-segment Range acceleration on large files)
cmipget download -o ./cmip_data -p cmip7 -m ACCESS-ESM1-6 -e historical -v tas -f mon --one-member --segmented

# 6. Background job for multi-GB batches
cmipget download -o ./cmip_data -p cmip6 -e ssp245 -v tas -t Amon --one-member --yes --background
cmipget jobs list

# 7. Verify local files against manifest.json, audit for retractions/updates, & export external lists
cmipget verify ./cmip_data
cmipget audit ./cmip_data
cmipget export --format aria2c --out-file cmip.aria2 -p cmip7 -e historical -v tas -f mon

# 8. Third-party Pangeo GCS/AWS CMIP6 cloud Zarr mirrors
cmipget cloud search -v tos -e historical -t Omon --one-member
cmipget cloud download -v tos -e historical -t Omon -m CanESM5 -yr 2000-2014 --provider gcs --max-stores 1 -o ./cmip_data
```

---

## Python SDK Quickstart

```python
from cmipget import CMIPClient, DownloadConfig, Query

client = CMIPClient()
query = Query(
    project="cmip7",
    source_id=["ACCESS-ESM1-6"],
    experiment_id=["historical"],
    variable_id=["tas"],
    frequency=["mon"],
    years="2000-2014",
    one_member=True,
)

plan = client.plan_sync(query, output_dir="./cmip_data", layout="compact")
print(f"Files: {plan.files_to_download}, Bytes: {plan.bytes_to_download}")

report = client.download_sync(
    plan,
    config=DownloadConfig(concurrency=4, segmented=True, segment_count=4),
)
print(client.verify("./cmip_data"))
```

## Citation

If you use `cmipget` in research, please cite this software (metadata in [CITATION.cff](CITATION.cff)):

> Ren, J. (2026). *cmipget: Agent-ready CMIP7 and CMIP6 climate model data downloader* (Version 0.1.0) [Computer software]. GitHub. https://github.com/Radianjayjay/cmipget

## Author

Jie Ren, South China Sea Institute of Oceanology, Chinese Academy of Sciences / University of Chinese Academy of Sciences.

- Email: `renjie22@mails.ucas.ac.cn`
- ORCID: [0009-0000-2806-6771](https://orcid.org/0009-0000-2806-6771)
- ResearchGate: [Jie Ren](https://www.researchgate.net/profile/Jie-Ren-126)

## License

MIT — see [LICENSE](LICENSE).
