New visualize_tides and visualize_conditions MCP tools that generate PNG (inline via MCP ImageContent) or interactive HTML (Plotly) charts. Optional dependency group [viz] keeps the base install lightweight. - charts/ package: rendering logic separated from MCP tool wiring - Shared marine color palette (ocean blue, teal, slate, sand, coral) - 14 new tests (parsing, PNG/HTML rendering, tool registration) - Example chart images in README with realistic synthetic tidal data
34 lines
971 B
Python
34 lines
971 B
Python
"""Chart rendering for NOAA tide and conditions data.
|
|
|
|
Optional dependency — requires noaa-tides[viz] to be installed.
|
|
"""
|
|
|
|
# Marine color palette — shared across all chart renderers
|
|
OCEAN_BLUE = "#1B4F72"
|
|
TEAL = "#148F77"
|
|
SLATE = "#5D6D7E"
|
|
SAND = "#D4A017"
|
|
CORAL = "#E74C3C"
|
|
BG_COLOR = "#FAFAFA"
|
|
GRID_COLOR = "#E0E0E0"
|
|
|
|
|
|
def check_deps(format: str) -> None:
|
|
"""Raise ValueError with install hint if visualization deps are missing."""
|
|
if format == "png":
|
|
try:
|
|
import matplotlib # noqa: F401
|
|
except ImportError:
|
|
raise ValueError(
|
|
"PNG charts require matplotlib. Install with: "
|
|
"uv pip install noaa-tides[viz]"
|
|
)
|
|
elif format == "html":
|
|
try:
|
|
import plotly # noqa: F401
|
|
except ImportError:
|
|
raise ValueError(
|
|
"HTML charts require plotly. Install with: "
|
|
"uv pip install noaa-tides[viz]"
|
|
)
|