A comprehensive weather forecast application built with Streamlit that provides detailed weather information, air quality monitoring, and interactive location selection with enhanced visual 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
https://weather-trend.streamlit.app/
-
Clone this repository:
git clone <your-repo-url> cd weather_trend
-
Install the required packages:
pip install streamlit pandas requests altair folium streamlit-folium geopy python-dotenv openai
-
Set up environment variables for AI features: Create a
.envfile in the project root and add your ModelScope API key:modelscope=your_modelscope_api_key_hereTo get a ModelScope API key:
- Visit ModelScope
- Create an account and obtain an API key
- Add the key to your
.envfile
Run the application with:
streamlit run app.pyThe app will open in your web browser at http://localhost:8501
- Language Toggle: Click the language button (EN/中文) in the top-right corner
- Search by City: Enter a city name in English or Chinese in the sidebar and click "Get Weather "
- Click on Map: Click anywhere on the interactive map to get weather for that location
- 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
- 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
The app features intelligent weather analysis powered by DeepSeek-V3.2 through ModelScope API:
- 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)
- Data Collection: Gathers all 12 days of weather data (7 historical + 5 forecast)
- Context Analysis: Identifies weather patterns, temperature trends, and precipitation risks
- Intelligent Response: Generates concise, actionable recommendations (100-200 words)
- Language Adaptation: Automatically matches the user's selected interface language
- 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
- 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
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
- 🟢 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
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
- 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
This project is open source and available under the MIT License.
- 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

