File size: 7,995 Bytes
933800e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35af981
 
 
 
 
 
 
 
 
 
933800e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35af981
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
933800e
 
 
 
 
 
 
 
 
 
 
 
35af981
933800e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
---
license: other
license_name: tccip-terms-of-use
license_link: https://tccip.ncdr.nat.gov.tw
language:
  - zh
pretty_name: CAE Capstone 氣候資料集(TCCIP AR6 + 網格化觀測)
tags:
  - climate
  - taiwan
  - tccip
  - stac
  - zarr
  - cmip6
viewer: false
---

# CAE Capstone 氣候資料集

臺大 CAE Capstone 課程用的臺灣氣候資料集。原始資料來自 **TCCIP**(臺灣氣候變遷推估資訊與調適知識平台,NCDR),
我們把申請取得的逐年 CSV 整理成 **Zarr**,並用 **STAC** 目錄描述,讓你不必先下載幾十 GB 就能查到有什麼資料、範圍多大、單位是什麼。

- STAC 目錄入口:<https://huggingface.co/datasets/NTU-CompHydroMet-Lab/CAPSTONE-CAE/resolve/main/stac_catalog/catalog.json>
- 資料本體:`asset/` 底下的 `.zarr`
- 官方說明文件(PDF):`asset/docs/`

## 一、有哪些資料

| Collection / Item | 內容 | 網格 | 時間 | 變數 | 大小 |
|---|---|---|---|---|---|
| `TCCIP_Gridded_Historical_Daily_Data` → `Gridded_Historical_Daily_Data` | 網格化觀測日資料 V2(地面測站內插) | 0.01°,345 × 243 | 1960-01-01 – 2024-12-31(23,742 天) | `pr`, `tas_mean`, `tas_min`, `tas_max` | 8.3 GB |
| `TCCIP_AR6_Data` → `AR6_SD_Daily` | AR6 統計降尺度日資料 | 0.05°,72 × 53 | 1960-01-01 – 2100-12-31(51,465 天) | `pr`, `tas_mean`, `tas_min`, `tas_max` | 每情境約 0.95 GB |
| `TCCIP_AR6_Data` → `AR6_Climate_Change_Key_Indices` | AR6 氣候變遷關鍵指標(年值) | 0.05°,72 × 53 | 1960 – 2100(141 年) | 22 個 ETCCDI 式指標(`txx`, `tnn`, `rx1day`, `prcptot`, `cdd`, `sdii` …) | 每情境約 9 MB |

兩個 AR6 item 各有 4 個情境 asset:`ssp126` / `ssp245` / `ssp370` / `ssp585`,模式目前只有 **TaiESM1**。
座標系統一律 EPSG:4326,`lat` / `lon` 是網格中心點,缺值為 `NaN`(原始 CSV 的 `-99.9`)。
單位:降雨 `mm/day`、溫度 `degC`。

## 二、最快上手:直接讀

不用下載,`xarray` 可以直接開遠端 Zarr(需要 `xarray`、`zarr>=3`、`fsspec`、`aiohttp`、`dask`):

```python
import xarray as xr

BASE = "https://huggingface.co/datasets/NTU-CompHydroMet-Lab/CAPSTONE-CAE/resolve/main/asset"

ds = xr.open_zarr(f"{BASE}/Gridded_Historical_Daily_Data/Gridded_Historical_Daily_Data.zarr")
print(ds)

# 取某個網格點某天的雨量(北士科附近)
v = ds.pr.sel(time="2020-07-01", lat=25.10, lon=121.50, method="nearest")
print(float(v), ds.pr.units)      # 11.6 mm/day
```

AR6 推估資料同理,換路徑即可:

```python
ssp245 = xr.open_zarr(f"{BASE}/AR6_SD_Daily/AR6_SD_Daily_ssp245_TaiESM1.zarr")
idx    = xr.open_zarr(f"{BASE}/AR6_Climate_Change_Key_Indices/AR6_Climate_Change_Key_Indices_ssp245_TaiESM1.zarr")

# 2081–2100 平均的年最高溫指標 TXx 空間分布
txx = idx.txx.sel(time=slice("2081", "2100")).mean("time")
```

## 三、用 STAC 目錄找資料

STAC 的用途是「先看 metadata 再決定要下載什麼」。目錄是 self-contained 的靜態 JSON,`pystac` 可以直接吃網址:

```python
import pystac

CATALOG = ("https://huggingface.co/datasets/NTU-CompHydroMet-Lab/CAPSTONE-CAE"
           "/resolve/main/stac_catalog/catalog.json")

cat = pystac.Catalog.from_file(CATALOG)

for col in cat.get_children():
    print(col.id, "|", col.extent.spatial.bboxes[0])
    for item in col.get_items():
        print("   ", item.id, item.properties["data_variables"])
        for key, asset in item.assets.items():
            print("      ", key, "->", asset.href)
```

拿到 asset 的 `href` 就可以直接餵給 `xr.open_zarr()`:

```python
item  = cat.get_child("TCCIP_AR6_Data").get_item("AR6_SD_Daily")
ds245 = xr.open_zarr(item.assets["ssp245_TaiESM1"].href)
```

每個 item 都帶 [datacube 擴充](https://github.com/stac-extensions/datacube),所以不必下載就查得到維度、形狀、單位與 chunk 切法:

```python
props = item.properties
print(props["cube:variables"]["pr"])   # dimensions / shape / unit
print(props["chunk_shape"])            # 每個變數的 zarr chunk 大小
```

也可以直接用網頁瀏覽(點開就能看,不必安裝任何東西):
<https://browser.moregeo.it/external/huggingface.co/datasets/NTU-CompHydroMet-Lab/CAPSTONE-CAE/resolve/main/stac_catalog/catalog.json>

## 四、效能:先看這段再跑分析

Zarr 的 chunk 切法是 **「一年 × 整張網格」**(觀測資料為 `365 × 345 × 243` float32,解壓後約 122 MB/chunk)。
這代表:

- **取空間切片(某一天/某一年的全臺分布)很快** —— 只碰 1 個 chunk。
- **取單點長時間序列很慢** —— 例如某一格 1960–2024 的逐日雨量,會拉滿 65 個 chunk。

所以:

```python
# 慢:整段單點序列走網路
ts = ds.pr.sel(lat=25.10, lon=121.50, method="nearest").compute()

# 快:先把要用的 store 抓到本地再算
from huggingface_hub import snapshot_download

local = snapshot_download(
    repo_id="NTU-CompHydroMet-Lab/CAPSTONE-CAE",
    repo_type="dataset",
    allow_patterns="asset/Gridded_Historical_Daily_Data/**",   # 8.3 GB
)
ds = xr.open_zarr(f"{local}/asset/Gridded_Historical_Daily_Data/Gridded_Historical_Daily_Data.zarr")
```

只要一個變數時,`allow_patterns` 可以縮成 `"asset/Gridded_Historical_Daily_Data/**/pr/**"`,
但記得把 `zarr.json`、`time/`、`lat/`、`lon/` 一起帶上,否則 xarray 開不起來。
更省事的做法是遠端開檔後先 `.sel(time=slice("2015", "2024"))` 再 `.compute()` —— dask 只會抓那幾年的 chunk
(chunk 路徑就是 `pr/c/{年序}/0/0`,1960 年為 0)。

AR6 資料每個情境不到 1 GB,直接遠端讀通常就夠用。

## 五、兩個容易踩到的坑

**1. 座標軸是稀疏的,不要假設等距。**
觀測是 0.01°、AR6 是 0.05°,但因為含離島,`lat` / `lon` 軸上有跳格
(例如觀測的 lat 從 25.49 直接跳到 25.62)。所以 STAC metadata 裡 `cube:dimensions` 的 `step` 是 `null`,
而 `.sel(lat=..., lon=..., method="nearest")` 有可能默默對到很遠的格點。取完值請順手檢查真正對到哪裡:

```python
sel = ds.pr.sel(lat=25.10, lon=121.50, method="nearest")
print(float(sel.lat), float(sel.lon))   # 確認和你要的點夠近
```

**2. AR6 日資料沒有閏日,觀測有。**
AR6 統計降尺度日資料是 141 年 × 365 天 = 51,465 步,完全不含 2/29;
網格化觀測 1960–2024 則含 17 個 2/29。兩邊直接對齊 `time` 會逐年錯位,
做偏差校正、delta change 或任何觀測 vs 推估的比對前,請先決定閏日怎麼處理。

## 六、資料來源與引用

資料來源:臺灣氣候變遷推估資訊與調適知識平台(TCCIP),<https://tccip.ncdr.nat.gov.tw/>
Taiwan Climate Change Projection Information and Adaptation Knowledge Platform (TCCIP).

原始資料由 TCCIP 依其使用規範提供,本 repo 僅做格式轉換(CSV → Zarr)與 STAC 描述,
**未修改數值**(僅將 `-99.9` 缺值轉為 `NaN`)。使用時請依 TCCIP 規範標註來源;
資料的正式定義、產製方法與已知限制請以 `asset/docs/` 下的官方 PDF 為準:

- 網格化觀測 V2:資料說明文件、溫度/雨量資料生產履歷
- AR6 統計降尺度:資料說明文件、溫度/雨量資料生產履歷
- AR6 氣候變遷關鍵指標:資料說明文件、資料生產履歷

## 七、目錄結構

```
asset/
├── Gridded_Historical_Daily_Data/
│   └── Gridded_Historical_Daily_Data.zarr
├── AR6_SD_Daily/
│   └── AR6_SD_Daily_{ssp126,ssp245,ssp370,ssp585}_TaiESM1.zarr
├── AR6_Climate_Change_Key_Indices/
│   └── AR6_Climate_Change_Key_Indices_{ssp126,ssp245,ssp370,ssp585}_TaiESM1.zarr
└── docs/                      # TCCIP 官方 PDF
stac_catalog/
├── catalog.json               # 從這裡開始
├── TCCIP_AR6_Data/collection.json
└── TCCIP_Gridded_Historical_Daily_Data/collection.json
```