Skip to content

JCwinning/weather_trend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 中文

Weather Trend Forecast App

A comprehensive weather forecast application built with Streamlit that provides detailed weather information, air quality monitoring, and interactive location selection with enhanced visual features.

Screenshot

Features

  • 🌤️ Weather Forecast: Get 7-day historical and 5-day future weather data
  • 🗺️ Interactive Map: Click anywhere on the map to get weather for that location
  • 🌍 Bilingual Interface: Full English/Chinese language support with toggle button
  • 🌏 Bilingual City Search: Search for weather by city name in English or Chinese (支持中文城市名)
  • 📊 Enhanced Data Visualization: Static temperature trend charts with solid/dotted line differentiation
  • 🌬️ Air Quality Monitoring: PM2.5 levels with optimized color-coded health indicators
  • 🌧️ Rain Probability: Visual indicators for precipitation likelihood
  • 🎨 Weather Icons: Emoji-based weather representation for quick visual understanding
  • 📍 Today Highlighting: Today's weather row is highlighted with larger text
  • 🔒 Static Charts: Fixed view charts prevent accidental zoom/pan for consistent display
  • 🔄 Enhanced Reverse Geocoding: Improved location name resolution for map clicks
  • 🤖 AI Weather Recommendations: Get AI-powered weather analysis and dress suggestions using DeepSeek-V3.2
  • 📱 Responsive Design: Clean, modern interface that works on all devices

Live Demo

https://weather-trend.streamlit.app/

Installation

  1. Clone this repository:

    git clone <your-repo-url>
    cd weather_trend
  2. Install the required packages:

    pip install streamlit pandas requests altair folium streamlit-folium geopy python-dotenv openai
  3. Set up environment variables for AI features: Create a .env file in the project root and add your ModelScope API key:

    modelscope=your_modelscope_api_key_here
    

    To get a ModelScope API key:

    • Visit ModelScope
    • Create an account and obtain an API key
    • Add the key to your .env file

Usage

Run the application with:

streamlit run app.py

The app will open in your web browser at http://localhost:8501

How to Use

  1. Language Toggle: Click the language button (EN/中文) in the top-right corner
  2. Search by City: Enter a city name in English or Chinese in the sidebar and click "Get Weather "
  3. Click on Map: Click anywhere on the interactive map to get weather for that location
  4. View Data:
    • Static temperature trend chart with solid line (past) and dotted line (future from today)
    • Detailed weather table with weather icons and color-coded indicators
    • PM2.5 air quality levels (based on US EPA standards)
    • Rain probability indicators
    • Today's row highlighted with larger font size
  5. AI Weather Recommendations: Click the "AI Weather Advice" button to get:
    • Historical weather pattern analysis (last 7 days)
    • Detailed forecast summary (upcoming 5 days)
    • Dress recommendations for different weather conditions
    • Outdoor activity suggestions and warnings

🤖 AI Weather Recommendations

The app features intelligent weather analysis powered by DeepSeek-V3.2 through ModelScope API:

Screenshot

AI Capabilities

  • Historical Analysis: Examines weather patterns from the past 7 days
  • Forecast Interpretation: Translates complex weather data into understandable insights
  • Dress Recommendations: Suggests appropriate clothing based on weather conditions
  • Activity Advice: Provides recommendations for outdoor activities based on weather forecasts
  • Bilingual Support: AI responds in the same language as the UI (English or Chinese)

How AI Works

  1. Data Collection: Gathers all 12 days of weather data (7 historical + 5 forecast)
  2. Context Analysis: Identifies weather patterns, temperature trends, and precipitation risks
  3. Intelligent Response: Generates concise, actionable recommendations (100-200 words)
  4. Language Adaptation: Automatically matches the user's selected interface language

AI Model Details

  • Model: DeepSeek-V3.2-Exp via ModelScope
  • API Integration: OpenAI client library with ModelScope endpoints
  • Response Time: Typically 2-5 seconds depending on data complexity
  • Error Handling: Graceful fallback with clear error messages if API is unavailable

Data Sources

  • Weather Data: Open-Meteo API (https://open-meteo.com/) with multilingual support
  • Air Quality: Open-Meteo Air Quality API
  • Geocoding: Open-Meteo Geocoding API & Nominatim
  • Maps: Folium with OpenStreetMap tiles
  • AI Recommendations: ModelScope API with DeepSeek-V3.2 model for weather analysis and suggestions

Air Quality Index

The app displays PM2.5 levels with optimized color coding based on US EPA standards:

  • 🟢 Good (0-12 μg/m³): Deeper green with white text
  • 🟢 Moderate (12.1-35.4 μg/m³): Light green with black text
  • 🟡 Unhealthy for Sensitive Groups (35.5-55.4 μg/m³): Darker yellow with black text
  • 🟠 Unhealthy (55.5-150.4 μg/m³): Darker orange with white text
  • 🔴 Very Unhealthy (150.5-250.4 μg/m³): Darker red with white text
  • Hazardous (250.5+ μg/m³): Very dark red with white text

Rain Probability

  • 🟢 Low (<50%): Material Design gray with white text
  • 🟠 Medium (50-79%): Material Design amber with white text
  • 🔴 High (≥80%): Material Design red with white text

Weather Icons

The app uses emoji icons for weather conditions:

  • ☀️ Clear sky / Mainly clear
  • ⛅ Partly cloudy
  • ☁️ Overcast
  • 🌫️ Fog
  • 🌦️ Drizzle / Light rain
  • 🌧️ Rain (heavy/moderate)
  • ❄️ Snow / Snow showers
  • ⛈️ Thunderstorm

Technical Stack

  • Frontend: Streamlit
  • Data Processing: Pandas
  • Visualization: Altair Charts
  • Maps: Folium
  • HTTP Requests: Requests
  • Geocoding: Open-Meteo + Nominatim Enhanced Multi-API Strategy
  • AI Integration: OpenAI client library with ModelScope API
  • AI Model: DeepSeek-V3.2 for weather analysis and recommendations
  • Environment Management: python-dotenv for secure API key handling
  • Internationalization: Extended Chinese character detection and multilingual API support

License

This project is open source and available under the MIT License.

Acknowledgments

  • Open-Meteo for providing free weather and air quality APIs with multilingual support
  • Streamlit for the amazing web app framework
  • OpenStreetMap contributors for map data
  • WMO for standardized weather code definitions

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages