Metadata-Version: 2.1
Name: aisky
Version: 0.1.2
Summary: aisky 系列子模型的云端预报数据读取与缓存工具
Author: aisky contributors
License: MIT License
        
        Copyright (c) 2026 aisky contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        
Project-URL: Homepage, https://github.com/AISky-forecast/aisky
Project-URL: Repository, https://github.com/AISky-forecast/aisky
Project-URL: Documentation, https://github.com/AISky-forecast/aisky#readme
Project-URL: Issues, https://github.com/AISky-forecast/aisky/issues
Keywords: forecast,xarray,netcdf,meteorology,aisky
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: xarray (>=2023.1.0)
Requires-Dist: netCDF4 (>=1.6.0)
Requires-Dist: numpy (>=1.23.0)
Requires-Dist: pandas (>=1.5.0)
Requires-Dist: scipy (>=1.9.0)
Provides-Extra: dev
Requires-Dist: pytest (>=7.0) ; extra == 'dev'
Requires-Dist: pytest-cov (>=4.0) ; extra == 'dev'
Requires-Dist: build (>=1.2.0) ; extra == 'dev'
Requires-Dist: twine (>=5.0) ; extra == 'dev'

# aisky

English | [中文](README_CN.md)

`aisky` is a Python package for downloading, caching, and reading cloud-hosted forecast data for the **aisky submodel family**. Each submodel can have its own cycle times, step rules, variable set, and URL conventions, so `aisky` exposes a model-client interface.

## Submodel Technical References

aisky-aerosol

  **Paper**

  > Gui, K., Zhang, X., Che, H. et al. *Advancing operational global aerosol forecasting with machine learning.* Nature **651**, 658–665 (2026).

  - Link: https://www.nature.com/articles/s41586-026-10234-y

  **Architecture**

  ![aisky-aerosol architecture](docs/figures/aisky-aerosol-arc.png)

aisky-sds (TBD)

  **Paper**

  - TBD

  **Architecture**

  - TBD

## Install

```bash
pip install aisky
```

## Quick Start (aisky-aerosol)

```python
from aisky import aisky

client = aisky(model="aisky-aerosol")
print(client.info().to_dict())

da = client.get_forecast(
    init_time="20260101_0130",
    step_hours=3,
    count=8,
    variable="TOTEXTTAU",
)
print(da)
```

Fetch multiple variables at once (returns an `xarray.Dataset`):

```python
from aisky import aisky

client = aisky("aisky-aerosol")
ds = client.get_forecast(
    "20260101_0130",
    step_hours=3,
    count=8,
    variable=["TOTEXTTAU", "DUEXTTAU"],
)
print(ds)
```

### List available models

```python
import aisky

print(aisky.available_models())
```

### Inspect model metadata (cycle/variables/rules)

```python
from aisky import aisky

client = aisky("aisky-aerosol")
info = client.info()

print(info.cycle_times)
print(info.variables)
```

### Fetch forecasts

```python
from aisky import aisky

client = aisky("aisky-aerosol")
da = client.get_forecast("20260101_0130", step_hours=3, count=8, variable="TOTEXTTAU")
```

### Cache to a local folder

`store_dir` creates a subfolder named by `init_time` (e.g., `./data/20260101_0130/`):

```python
from aisky import aisky

client = aisky("aisky-aerosol")
da = client.get_forecast(
    "20260101_0130",
    count=8,
    variable="TOTEXTTAU",
    store_dir="./data",
)
```

## API

### `aisky(model=...)`

Returns a model client with:

- `client.info()`: submodel metadata (cycle times, variables, rules, defaults)
- `client.get_forecast(...)`: download/cache/read forecast data

### `client.get_forecast(...)`

- `init_time`: init time (`"YYYYMMDD_HHMM"`, `datetime`, or `pandas.Timestamp`)
- `step_hours`: step size (hours), constrained by the submodel rules (`aisky-aerosol`: multiple of 3)
- `count`: number of forecast targets (`>= 1`; `1` means a single valid time)
- `store_dir`: optional; if set, files are stored under `store_dir/init_time/`
- `cache_dir`: optional; default uses the OS cache directory (Windows: `%LOCALAPPDATA%\\aisky\\cache`)
- `variable`: optional; a variable name or a list of variables (`aisky-aerosol`: must be in `client.info().variables`)
- `engine`: `xarray.open_dataset` engine (default: `netcdf4`)
- `timeout`: download timeout (seconds)
- `retries`: retry attempts
- `overwrite`: overwrite existing cached files
- `return_dataset`: return `xarray.Dataset` directly

More examples: [docs/usage.md](docs/usage.md).

## Data Source & URL Template

URL template (the path naming is historical and does not affect the product name):

```
https://obs.cstcloud.cn/s/ai-gamfs/AI-GAMFS/forecast_data/{init}/AI_GAMFS.{init}+{valid}.V01.nc
```

Both `init` and `valid` use `YYYYMMDD_HHMM`.

## License

MIT License. See [LICENSE](LICENSE).
