AI agent for ensemble weather forecast analysis using Claude and multiple weather models
Project description
Weather Ensemble Agent ๐ค๏ธ
An AI-powered weather forecast analysis tool that uses Claude (Anthropic) to analyze ensemble forecasts from multiple numerical weather prediction models. The agent autonomously fetches data, performs statistical analysis, and creates beautiful visualizations to help you understand forecast uncertainty.
๐ Learning Project
This project is designed as a learning resource for developers interested in AI agents.
If you're wondering "What are AI agents and how can I use them in my coding?", this repository provides a complete, real-world example that you can study, run, and extend.
What You'll Learn
By exploring this codebase, you'll understand:
-
๐ค What AI Agents Are
- Autonomous systems that reason about which actions to take
- Different from traditional chatbots that just respond to input
- Use tool calling (function calling) to interact with the real world
- Implement an "agentic loop" pattern for iterative problem-solving
-
๐ง How to Build AI Agents
- Structuring your code for tool calling with Claude (or other LLMs)
- Designing tool schemas using JSON Schema
- Implementing the agentic loop pattern
- Handling tool execution and error cases
- Chaining multiple tool calls together
-
โ๏ธ Practical Patterns You Can Reuse
- Project structure for agent-based applications
- Integration with external APIs (weather, geocoding)
- Data analysis and visualization within an agent
- Building a CLI around an AI agent
- Environment configuration and API key management
-
๐ฏ When to Use AI Agents in Your Projects
- Scenarios where agents excel vs traditional code
- Cost-benefit analysis of agentic approaches
- Combining deterministic code with AI reasoning
- Best practices for production deployments
How to Use This for Learning
- Start with the README - Understand the "Why Agentic AI?" section below
- Run the examples - See the agent in action with different queries
- Read the code - Study
src/weather_agent/agent.pyto see the agentic loop - Trace execution - Watch the console output showing each tool call
- Modify tools - Add your own tool to see how easy it is to extend
- Build your own - Use this as a template for your own agent project
Perfect For
- ๐ Developers learning about AI agents and LLM applications
- ๐ ๏ธ Engineers wanting practical examples of tool calling/function calling
- ๐ฌ Anyone curious about the difference between traditional programming and agentic AI
- ๐ Data scientists interested in combining AI with data analysis workflows
This project demonstrates production-quality patterns while remaining simple enough to understand and modify.
Features
๐ค AI Agent with Tool Calling
- Autonomous reasoning: Claude decides which tools to use and when
- Agentic loop pattern: Continues gathering information until the user's question is fully answered
- Natural language interface: Ask questions in plain English
๐ Multi-Model Ensemble Analysis
- 4 Weather Models: GFS, ECMWF, GEM, and ICON
- Statistical analysis: Mean, median, standard deviation, percentiles, and spread
- Model agreement metrics: Quantify forecast confidence across models
- Uncertainty categorization: Low, moderate, or high uncertainty levels
๐ Visualization
- Multi-panel plots: Temperature (max/min), precipitation, and wind speed
- Ensemble traces: See individual model predictions
- Uncertainty envelopes: Visualize forecast spread
- Publication-quality output: Save as PNG with customizable paths
๐ฅ๏ธ Comprehensive CLI
- forecast: Get weather with optional visualization
- compare: Analyze model agreement for specific variables
- visualize: Create plots for any location
- models: List available weather models
- coordinates: Geocode location names
- ask: Free-form questions to the agent
๐ Data Sources
- Open-Meteo API: Free, no API key required for weather data
- Nominatim (OpenStreetMap): Free geocoding service
- Anthropic Claude: Sonnet 4 for AI reasoning (requires API key)
Why Agentic AI? ๐ง
The Paradigm Shift from Traditional Programming
This project demonstrates a fundamental shift in how we build softwareโfrom imperative programming to agentic AI.
Traditional Pre-AI Approach โ๏ธ
In traditional programming, you would build this weather analysis tool by:
-
Hard-coded logic: Writing explicit if/else statements for every scenario
if user_wants_forecast: location = geocode(user_input) if user_wants_visualization: data = fetch_data(location) stats = calculate_stats(data) create_plot(stats) else: data = fetch_data(location) print_forecast(data)
-
Fixed workflows: Predetermined sequences that can't adapt
-
Brittle parsing: Complex regex or NLP to understand user intent
-
Limited flexibility: Each new feature requires new code paths
-
Manual orchestration: Developer decides the exact order of operations
Problems with this approach:
- Can't handle unexpected user requests
- Requires anticipating every possible scenario
- Difficult to maintain as features grow
- Poor user experience for complex queries
Agentic AI Approach ๐ค
With agentic AI, the system reasons about what to do:
-
Autonomous decision-making: The AI agent decides which tools to use
# User asks: "Compare Denver and Seattle weather, which is better for skiing?" # Agent autonomously: # - Geocodes both locations # - Fetches forecasts for both # - Compares temperature and precipitation # - Reasons about skiing conditions # - Provides a nuanced answer
-
Dynamic workflows: Adapts to each unique request
-
Natural language: Users ask questions in plain English
-
Self-extending: New tools are automatically available to the agent
-
Contextual reasoning: Makes intelligent decisions based on the situation
Advantages of this approach:
- โ Handles unforeseen questions naturally
- โ Combines tools in novel ways without explicit programming
- โ Provides nuanced, context-aware responses
- โ Gracefully degrades when information is missing
- โ Explains its reasoning process
Real Example from This Project
User query: "What's the weather like in Miami this week? Should I pack an umbrella?"
Traditional approach would require:
def handle_query(query):
# Parse intent (umbrella question = check precipitation)
if "umbrella" in query.lower():
location = extract_location(query) # Complex regex
data = fetch_forecast(location, days=7)
precip = analyze_precipitation(data)
if precip > THRESHOLD:
return "Yes, bring umbrella"
else:
return "No umbrella needed"
Agentic approach:
- Agent sees the query and reasons: "I need to check precipitation in Miami"
- Calls
geocode_location("Miami")โ gets coordinates - Calls
fetch_daily_weather_forecast(...)โ gets 7-day data - Calls
calculate_ensemble_statistics(forecast, "precipitation")โ analyzes uncertainty - Synthesizes answer: "Expect 0.8 inches over the week, mostly on Tuesday and Wednesday. Pack an umbrella for mid-week, but you'll likely have sunny days too. Models show high agreement on this."
The agent autonomously chose this sequenceโyou didn't program it explicitly!
The Agentic Loop Pattern
This project implements what's called an agentic loop:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. User asks question โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 2. AI Agent reasons about what's needed โ
โ - What information do I need? โ
โ - Which tools should I use? โ
โ - In what order? โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 3. Execute tool(s) โ
โ - Fetch data โ
โ - Perform calculations โ
โ - Create visualizations โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 4. Agent evaluates results โ
โ - Do I have enough information? โ
โ - Do I need more data? โ
โ - Should I use another tool? โ
โโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโ No: Loop back to step 2 โโโโโ
โ โ
โผ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 5. Provide comprehensive answer โโ
โ - Synthesize information โโ
โ - Explain findings โโ
โ - Answer the user's question โโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Benefits
- Flexibility: Handles queries you never anticipated
- Intelligence: Combines tools in creative ways
- Adaptability: Adjusts approach based on available data
- Explainability: Can explain why it made certain choices
- Maintainability: Add new tools without changing core logic
When to Use Agentic AI vs Traditional Code
Use Agentic AI when:
- ๐ฏ User intent is varied and unpredictable
- ๐ Workflows need to be dynamic
- ๐งฉ Tasks require combining multiple operations
- ๐ฌ Natural language interface is important
- ๐จ Creativity in problem-solving is valuable
Use Traditional Code when:
- โก Performance is critical (milliseconds matter)
- ๐ฐ API costs must be minimized
- ๐ Deterministic behavior is required
- ๐ Simple, well-defined tasks
- ๐ Security/compliance requires full control
This project demonstrates how agentic AI can transform a complex data analysis task into an intuitive, conversational experience.
Installation
Prerequisites
- Python 3.12 or higher
- uv package manager (recommended) or pip
- Anthropic API key (get one here)
Quick Start
Install from PyPI (Recommended for Users)
# Install the package
pip install weather-ensemble-agent
# Configure your API key (interactive setup)
weather-agent configure
# Try it out!
weather-agent visualize "Denver, CO"
Install from Source (For Development)
# Clone the repository
git clone https://github.com/rmcd-mscb/weather-ensemble-agent.git
cd weather-ensemble-agent
# Install with uv (recommended)
uv sync
# Or with pip
pip install -e .
# Set up your API key (choose one method)
# Method 1: Use the configure command
weather-agent configure
# Method 2: Create .env file
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY
# Method 3: Set environment variable
export ANTHROPIC_API_KEY='your-key-here'
# Try it out!
weather-agent visualize "Denver, CO"
Usage
First Time Setup
After installing, configure your Anthropic API key:
weather-agent configure
This will:
- Prompt you for your API key (get one at https://console.anthropic.com/)
- Save it securely to
~/.config/weather-agent/config.env - Set file permissions to 600 (owner read/write only)
Alternative configuration methods:
# Environment variable (temporary)
export ANTHROPIC_API_KEY='sk-ant-...'
# Environment variable (persistent in ~/.bashrc or ~/.zshrc)
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
# Project .env file (for development)
echo 'ANTHROPIC_API_KEY=sk-ant-...' > .env
The API key is checked in this order:
ANTHROPIC_API_KEYenvironment variable- Config file at
~/.config/weather-agent/config.env .envfile in current directory (development)
Command Line Interface
Configure API Key
# Interactive configuration setup
weather-agent configure
Get a Weather Forecast
# Simple 7-day forecast with visualization
weather-agent forecast "Seattle, WA"
# 3-day hourly forecast without visualization
weather-agent forecast "New York" --days 3 --hourly --visualize false
# Specific models only
weather-agent forecast "Boulder, CO" --models gfs --models ecmwf
Create Visualizations
# Default: 7-day daily forecast
weather-agent visualize "Portland, OR"
# Custom output path
weather-agent visualize "Denver, CO" --output outputs/denver_forecast.png
# Hourly data for 3 days
weather-agent visualize "Miami, FL" --days 3 --hourly
Compare Models
# Temperature comparison
weather-agent compare "Chicago, IL" --variable temperature
# Precipitation analysis
weather-agent compare "Seattle" --variable precipitation --days 10
# Specific models
weather-agent compare "Boston" --variable wind_speed --models gfs --models ecmwf
List Available Models
weather-agent models
Geocode Locations
weather-agent coordinates "San Francisco, CA"
Ask Free-Form Questions
weather-agent ask "What's the weather like in Miami this week?"
weather-agent ask "Compare Denver and Boulder forecasts for skiing conditions"
Python API
Using the Agent Directly
from weather_agent.agent import WeatherEnsembleAgent
# Create agent instance
agent = WeatherEnsembleAgent()
# Run a query
agent.run(
"What's the 7-day forecast for Denver? "
"How confident are the models? Include a visualization."
)
Using Individual Tools
from weather_agent.tools.geocoding import geocode_location
from weather_agent.tools.weather_api import fetch_daily_weather_forecast
from weather_agent.tools.statistics import calculate_ensemble_statistics
from weather_agent.visualization.plotter import create_ensemble_uncertainty_plot
# Geocode a location
location = geocode_location("Denver, Colorado")
# Returns: {'latitude': 39.7392, 'longitude': -104.9903, 'display_name': '...'}
# Fetch weather data from multiple models
forecast = fetch_daily_weather_forecast(
latitude=location['latitude'],
longitude=location['longitude'],
days=7,
models=['gfs', 'ecmwf', 'gem', 'icon']
)
# Calculate ensemble statistics
stats = calculate_ensemble_statistics(forecast, variable="temperature", use_max=True)
# Returns: {'ensemble_mean': [...], 'spread': [...], 'percentile_25': [...], ...}
# Create visualization
result = create_ensemble_uncertainty_plot(
forecast_data=forecast,
output_path="outputs/denver_forecast.png",
title="Denver 7-Day Forecast"
)
# Returns: {'output_path': '...', 'models_plotted': [...], 'num_timesteps': 7}
Project Structure
weather-ensemble-agent/
โโโ src/weather_agent/
โ โโโ __init__.py
โ โโโ __main__.py # Python -m weather_agent support
โ โโโ agent.py # Main AI agent with agentic loop
โ โโโ cli.py # Command-line interface
โ โโโ tools/ # Tools available to the agent
โ โ โโโ __init__.py
โ โ โโโ geocoding.py # Location โ coordinates
โ โ โโโ weather_api.py # Fetch from Open-Meteo API
โ โ โโโ statistics.py # Ensemble analysis
โ โโโ utils/ # Utility functions
โ โโโ visualization/ # Plotting tools
โ โโโ __init__.py
โ โโโ plotter.py # Matplotlib visualization
โโโ examples/ # Example scripts
โ โโโ test_visualization.py
โโโ tests/ # Unit tests
โโโ outputs/ # Default output directory
โโโ pyproject.toml # Project metadata and dependencies
โโโ .env.example # Example environment variables
โโโ .pre-commit-config.yaml # Code quality hooks
โโโ README.md # This file
Configuration
Environment Variables
Create a .env file in the project root:
# Required: Your Anthropic API key
ANTHROPIC_API_KEY=sk-ant-...
Pre-commit Hooks
The project uses pre-commit hooks for code quality:
# Install hooks
pre-commit install
# Run manually
pre-commit run --all-files
Hooks include:
- ruff: Linting and formatting
- bandit: Security analysis
- pyupgrade: Python syntax modernization
- Trailing whitespace, EOF fixer, etc.
Operational Costs
Token Usage and API Costs
This agent uses Claude Sonnet 4, which has associated API costs based on token consumption. Understanding these costs helps you use the tool efficiently.
Cost Breakdown Per Query
Input Tokens (sent to Claude):
- System prompt: ~200-300 tokens
- Tool definitions (9 tools): ~2,000-2,500 tokens
- User query: 10-100 tokens
- Tool results per iteration: 500-5,000 tokens (weather data can be large)
- Conversation history grows with each iteration
Output Tokens (generated by Claude):
- Reasoning and tool calls per iteration: 100-500 tokens
- Final response: 200-800 tokens
Typical Query Estimates:
| Query Type | Iterations | Input Tokens | Output Tokens | Estimated Cost* |
|---|---|---|---|---|
| Simple forecast | 3 | 8,000-12,000 | 2,000-3,000 | $0.03-$0.08 |
| Compare models | 4 | 12,000-18,000 | 2,500-4,000 | $0.05-$0.12 |
| Complex + visualization | 5 | 15,000-25,000 | 3,000-5,000 | $0.08-$0.15 |
*Based on Claude Sonnet 4 pricing (~$3/million input tokens, ~$15/million output tokens as of early 2025)
Cost Optimization Tips
To minimize costs:
-
Use daily forecasts instead of hourly when possible
# More efficient (daily summaries) weather-agent forecast "Denver, CO" --days 7 # More expensive (hourly data) weather-agent forecast "Denver, CO" --days 7 --hourly
-
Limit the number of models for quick checks
weather-agent forecast "Seattle" --models gfs --models ecmwf
-
Use direct CLI commands instead of the
askcommand when you know exactly what you want# More efficient - direct tool calls weather-agent visualize "Portland, OR" # Less efficient - agent needs to reason about intent weather-agent ask "Can you make a weather visualization for Portland?"
-
Reduce forecast duration if you only need near-term data
weather-agent forecast "Boston" --days 3 # instead of default 7
-
Future: Implement caching (see TODO section)
- Tool result caching would dramatically reduce costs for repeated queries
- Prompt caching for static tool definitions (reduces ~2,500 tokens per request)
Budget Monitoring
Track your usage:
- Monitor your Anthropic API usage at: https://console.anthropic.com/
- Set up billing alerts in the Anthropic console
- Consider implementing request logging to track per-query costs
For learning/development:
- Typical exploration session (10-20 queries): $0.50-$2.00
- Building and testing features (50-100 queries): $2.00-$10.00
For production use:
- Consider prompt caching (reduces costs by ~50% for repeated queries)
- Implement response caching for recent queries
- Use smaller models (Claude Haiku) for simple queries
- See the TODO section for cost optimization features
How It Works
The Agentic Loop
The Weather Ensemble Agent uses Claude's tool-calling capability to autonomously reason about which actions to take:
- User Request: You ask a question in natural language
- Claude Reasoning: The AI decides which tools it needs (geocoding, weather data, statistics, visualization)
- Tool Execution: The agent executes the requested tools
- Result Analysis: Claude receives the tool results and decides what to do next
- Iteration: Steps 2-4 repeat until Claude has enough information
- Final Answer: Claude provides a comprehensive response
Available Tools
The agent has access to these tools:
- geocode_location: Convert location names to coordinates
- fetch_weather_forecast: Get hourly weather data (for detailed analysis)
- fetch_daily_weather_forecast: Get daily summaries (more efficient for multi-day forecasts)
- get_available_models: List supported weather models
- calculate_ensemble_statistics: Compute mean, spread, percentiles across models
- calculate_model_agreement: Measure how well models agree
- summarize_forecast_uncertainty: Overall uncertainty assessment
- calculate_daily_temperature_range_statistics: Temperature max/min analysis
- create_ensemble_uncertainty_plot: Generate visualization
Weather Models
| Model | Name | Provider | Resolution | Update Frequency |
|---|---|---|---|---|
| gfs | Global Forecast System | NOAA (USA) | 0.25ยฐ (~28 km) | 4x daily |
| ecmwf | European Centre for Medium-Range Weather Forecasts | ECMWF (EU) | High accuracy | 2x daily |
| gem | Global Environmental Multiscale | Environment Canada | 0.25ยฐ (~25 km) | 2x daily |
| icon | Icosahedral Nonhydrostatic | DWD (Germany) | 0.1ยฐ (~11 km) | 4x daily |
Geographic Coverage
All four models provide global coverage - you can query weather forecasts for any location on Earth:
- ๐ North America: New York, Denver, Mexico City, Toronto
- ๐ Europe: London, Paris, Berlin, Rome
- ๐ Asia: Tokyo, Beijing, Mumbai, Singapore
- ๐ South America: Sรฃo Paulo, Buenos Aires, Lima
- ๐ Africa: Cairo, Nairobi, Cape Town
- ๐ Oceania: Sydney, Melbourne, Auckland
- โ๏ธ Antarctica: McMurdo Station, South Pole
Regional Performance Notes:
- ECMWF generally considered most accurate globally, widely regarded as the gold standard
- GFS particularly strong over North America and oceans
- ICON excellent coverage over Europe and adjacent regions
- GEM strong performance over North America
- Forecast quality may vary by region due to observational data density (more weather stations and satellite coverage improves model initialization)
- Model agreement can indicate forecast confidence - when all models agree, confidence is typically higher regardless of region
The ensemble approach (combining all four models) helps compensate for individual model biases and provides more robust forecasts worldwide.
Examples
Example Output
$ weather-agent forecast "Denver, CO" --days 3
============================================================
USER: Get a 3-day daily weather forecast for Denver, CO.
Create a visualization saved to outputs/forecast.png.
Provide a clear summary of the forecast.
============================================================
--- Iteration 1 ---
Stop reason: tool_use
Tool call: geocode_location
Input keys: ['location']
Result: {'latitude': 39.7392, 'longitude': -104.9903, ...}
--- Iteration 2 ---
Stop reason: tool_use
Tool call: fetch_daily_weather_forecast
Input keys: ['latitude', 'longitude', 'days', 'models']
Result: [Large dataset - 4523 chars]
--- Iteration 3 ---
...
AGENT: Based on the 3-day forecast for Denver, Colorado, here's what to expect:
**Temperature**:
- Highs ranging from 45-55ยฐF
- Lows around 32-38ยฐF
- Models show good agreement (low uncertainty)
**Precipitation**:
- Minimal precipitation expected
- Less than 0.1" across all models
- High confidence in dry conditions
**Wind**:
- Moderate winds 8-12 mph
- Slightly higher on Day 2 (up to 15 mph)
**Forecast Confidence**: HIGH - All four models (GFS, ECMWF, GEM, ICON)
show strong agreement, suggesting this is a reliable forecast.
The visualization has been saved to outputs/forecast.png showing the
ensemble spread and individual model predictions.
โ Complete!
๐ Visualization saved to: outputs/forecast.png
Example Visualization
The generated plots show:
- Temperature Max/Min: Daily high and low temperatures with ensemble mean
- Precipitation: Daily total precipitation across models
- Wind Speed Max: Maximum wind speeds per day
- Model Traces: Individual model predictions (semi-transparent)
- Ensemble Mean: Bold black line showing the consensus forecast
Development
Setting Up Development Environment
# Clone and install with dev dependencies
git clone <repository-url>
cd weather-ensemble-agent
uv sync
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Run the agent in development mode
python -m weather_agent.agent
Code Style
- Formatter: ruff
- Linter: ruff (E, F, I rules)
- Line length: 100 characters
- Python version: 3.12+
Adding New Tools
To add a new tool for the agent:
- Create the function in
src/weather_agent/tools/ - Add the tool definition in
agent.pyโ_define_tools() - Add the execution handler in
agent.pyโ_execute_tool() - Update the system prompt if needed
Example:
# In _define_tools()
{
"name": "my_new_tool",
"description": "What this tool does and when to use it",
"input_schema": {
"type": "object",
"properties": {
"param": {"type": "string", "description": "Parameter description"}
},
"required": ["param"]
}
}
# In _execute_tool()
elif tool_name == "my_new_tool":
return my_new_tool(**tool_input)
Troubleshooting
Common Issues
API Key Error
Error: ANTHROPIC_API_KEY not set
Solution: Make sure you've created a .env file with your API key.
Module Not Found
ModuleNotFoundError: No module named 'weather_agent'
Solution: Install in editable mode: pip install -e . or uv sync
Geocoding Fails
Error: Could not geocode location
Solution: Try being more specific with the location (e.g., "Denver, CO" instead of "Denver")
No Models Available
Error: No valid model data available
Solution: Check your internet connection. The Open-Meteo API may be temporarily unavailable.
TODO / Future Enhancements
The following features and improvements are planned but not yet implemented:
Testing
- Unit tests for all tools (geocoding, weather API, statistics)
- Integration tests for the agent's agentic loop
- Mock API responses to avoid hitting real APIs during testing
- Test fixtures with sample weather data
- CI/CD pipeline with GitHub Actions or similar
- Test coverage reporting (aim for >80% coverage)
Features
- Caching layer to reduce duplicate API calls and costs
- Historical weather data comparison and analysis
- Weather alerts integration (severe weather warnings)
- Air quality data from additional APIs
- Multi-location comparison in a single visualization
- Export formats (CSV, JSON) for forecast data
- Configuration file support (YAML/TOML) for user preferences
User Experience
- Web interface using Flask, FastAPI, or Streamlit
- Interactive visualizations with Plotly or Bokeh
- Streaming responses for real-time feedback during long operations
- Progress indicators with detailed status updates
- Error recovery with retry logic and better error messages
- Conversation history for multi-turn interactions
Documentation
- Video tutorial demonstrating the tool
- API reference documentation (Sphinx or MkDocs)
- Architecture diagrams showing component interactions
- Contributing guide with setup instructions for developers
- Example notebooks (Jupyter) with analysis workflows
Advanced Features
- Multiple LLM providers (OpenAI, local models like Llama)
- Multi-agent collaboration (separate agents for different tasks)
- RAG integration with weather documentation/research papers
- Fine-tuned models for weather-specific tasks
- Custom ensemble weighting based on historical model performance
- Probabilistic forecasts with uncertainty quantification
- Seasonal forecasting for long-range predictions
Performance & Reliability
- Async API calls for parallel data fetching
- Rate limiting to respect API quotas
- Database storage for forecast history and analysis
- Monitoring/logging infrastructure
- Error tracking with Sentry or similar
Contributions welcome! If you'd like to implement any of these features, please open an issue to discuss your approach first.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Guidelines
- Follow the existing code style (ruff format)
- Add tests for new features (see TODO section above - tests are currently missing!)
- Update documentation as needed
- Ensure pre-commit hooks pass
Ideas for Learning Extensions
If you're using this as a learning project, here are some ideas to extend it:
Beginner:
- Add a new tool (e.g., sunrise/sunset times, moon phase)
- Modify the system prompt to change agent behavior
- Add support for additional weather variables (humidity, UV index)
- Create a new CLI command
Intermediate:
- Implement caching to reduce API calls
- Add historical weather data comparison
- Create alternative visualization styles
- Build a web interface with Flask or FastAPI
- Add support for different LLM providers (OpenAI, local models)
Advanced:
- Implement multi-agent collaboration (multiple agents working together)
- Add memory/conversation history for multi-turn interactions
- Create a feedback loop for agent self-improvement
- Build a RAG (Retrieval-Augmented Generation) system with weather documentation
- Implement streaming responses for real-time feedback
Learning Resources
Understanding AI Agents
- Anthropic's Tool Use Documentation: docs.anthropic.com
- LangChain Agents Guide: Learn about alternative agent frameworks
- OpenAI Function Calling: Compare different approaches to tool calling
Key Concepts Demonstrated in This Project
-
Agentic Loop Pattern (
src/weather_agent/agent.py:run())- Request โ Reasoning โ Tool Use โ Evaluation โ Repeat
- Study lines ~400-500 to see the implementation
-
Tool Schema Design (
src/weather_agent/agent.py:_define_tools())- How to describe tools to an LLM
- JSON Schema for parameter validation
- Descriptive prompts for better tool selection
-
Tool Execution (
src/weather_agent/agent.py:_execute_tool())- Dispatching tool calls to Python functions
- Error handling and graceful degradation
- Returning results back to the agent
-
System Prompts (
src/weather_agent/agent.py:run())- Guiding agent behavior with instructions
- Context injection (current date)
- Best practices for tool usage
Experiment Ideas
Try modifying the code to understand how it works:
- Change the model: Switch from
claude-sonnet-4toclaude-opus-4and observe differences - Limit iterations: Reduce
max_iterationsto see how the agent handles constraints - Remove a tool: Comment out a tool and see how the agent adapts
- Add verbose logging: Print more details about agent reasoning
- Test edge cases: Ask questions the agent can't answer and see how it responds
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Open-Meteo: Free weather API with multiple model support
- Anthropic: Claude AI for agentic reasoning
- OpenStreetMap: Nominatim geocoding service
Citation
If you use this project in your research or application, please cite:
@software{weather_ensemble_agent,
title = {Weather Ensemble Agent},
author = {Your Name},
year = {2026},
url = {https://github.com/yourusername/weather-ensemble-agent}
}
Contact
For questions or feedback, please open an issue on GitHub.
Happy forecasting! ๐ฆ๏ธ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weather_ensemble_agent-0.1.1.tar.gz.
File metadata
- Download URL: weather_ensemble_agent-0.1.1.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c62f9c2fd902d96b388a37af00c2fef6a1cce1ff2f91f82f59dc0794001cc89a
|
|
| MD5 |
bd3cfda39682417e34505f8ae5c4bdfc
|
|
| BLAKE2b-256 |
fa95c3a764b273bb3423d0b865694c00647fb25c7c0f37e7b0ce0494298e3e3b
|
File details
Details for the file weather_ensemble_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: weather_ensemble_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d33ec63aefa29226633b0f07002bbd31522848f2a048b73f447d86852e3ed42
|
|
| MD5 |
9bc01bd692f0b1525d04cf080b560aaf
|
|
| BLAKE2b-256 |
d6fc3ac98225f8531da340bbc4c45eb42ee9f40ea5568e2f302adb058437cee7
|