# 海象 (https://nolantw.github.io/cwa/guides/marine/)

## 潮汐預報

`cwa.marine.tides()` 回傳鄉鎮或沿海地點一個月的潮汐預報。可傳入鄉鎮名稱、`Township`、氣象署地點代碼，或其序列。

```python
import cwa

forecast = cwa.marine.tides("花蓮縣吉安鄉")
for day in forecast.days[:2]:
    print(day.date, day.lunar_date, day.tide_range)
    for tide in day.tides:
        print(tide.time, tide.type, tide.height_twvd)
```

潮高單位為公分，`height_twvd`、`height_local_msl`、`height_chart_datum` 分別以臺灣高程基準、當地平均海平面及海圖基準為零點。`tide_range` 為大、中或小。

## 海況觀測

`cwa.marine.sea()` 回傳浮標與潮位站的觀測，依時間排序。`days=2` 取近 48 小時，`days=30` 取近 30 天。

```python
station = cwa.marine.sea("46694A")
latest = station.observations[-1]
print(latest.time, latest.wave_height, latest.sea_temperature, latest.wind_speed)
```

每筆觀測包含潮高、波高（m）、波向、波浪週期（s）、海溫與氣溫（°C）、氣壓（hPa）、風速與陣風（m/s），以及各深度層的 `currents`。測站沒有觀測的項目為 `None`。

不傳參數時回傳所有測站；傳入序列時回傳以輸入為鍵、依輸入順序排列的對照表。