openmeteopy

repository·main·Indexed 41 days ago

https://github.com/m0rp43us/openmeteopy

A Python client wrapper for the Open-Meteo web API that allows developers to consume meteorological data through a simple object model. It provides access to 14 different Open-Meteo APIs with support for hourly, daily, and 15-minute temporal resolutions. The library enables data retrieval in multiple formats, including Python dictionaries, JSON strings, NumPy arrays, and Pandas DataFrames. Note: This project is archived and no longer maintained.

Tokens
19.3K
Snippets
39
Records
91
Agent score
50%

What's inside openmeteopy

  1. Overview of the openmeteopy package structure

    main

    The openmeteopy package is organized into several subpackages based on temporal resolutions and utility functions. Use the specific subpackage that matches your required data frequency:

    • openmeteopy.daily: For daily data operations.
    • openmeteopy.fifteen_minutes: For 15-minute interval data operations.
    • openmeteopy.hourly: For hourly data operations.
    • openmeteopy.options: For managing configuration or parameter options.
    • openmeteopy.utils: For general utility functions.
  2. Overview of the openmeteopy.daily package modules

    main

    The openmeteopy.daily package provides specialized modules for accessing and processing daily meteorological data from various global and regional providers. Depending on your data source requirements, you can use the following modules:

    • openmeteopy.daily.dwd: Data from the Deutscher Wetterdienst (DWD).
    • openmeteopy.daily.flood: Flood-related meteorological data.
    • openmeteopy.daily.forecast: Daily forecast data.
    • openmeteopy.daily.gem: Data from the GEM (Global Environmental Multiscale) model.
    • openmeteopy.daily.gfs: Data from the Global Forecast System (GFS).
    • openmeteopy.daily.historical: Historical meteorological datasets.
    • openmeteopy.daily.jma: Data from the Japan Meteorological Agency (JMA).
    • openmeteopy.daily.marine: Marine-specific meteorological data.
    • openmeteopy.daily.meteo_france: Data from Météo-France.
  3. Overview of Openmeteopy APIs and Classes

    main

    Openmeteopy provides access to 14 different Open-Meteo APIs. Each API is accessed through a specific set of classes categorized by their temporal resolution (Hourly, Daily, etc.) and an Options class for configuration.

    Note: This project is archived and no longer maintained. For official SDKs, visit open-meteo.com.

    | API | Options Class | Hourly Class | Daily Class | 15 Minutes Class |
    |-----|---------------|--------------|-------------|------------------|
    | Weather forecast | `ForecastOptions()` | `HourlyForecast()` | `DailyForecast()` | - |
    | Historical Weather | `HistoricalOptions()` | `HourlyHistorical()` | `DailyHistorical()` | - |
    | ECMWF Weather Forecast | `EcmwfOptions()` | `HourlyEcmwf()` | - | - |
    | GFS & HRRR Forecast | `GfsOptions()` | `HourlyGfs()` | `DailyGfs()` | - |
    | MeteoFrance | `MeteoFranceOptions()` | `HourlyMeteoFrance()` | `DailyMeteoFrance()` | - |
    | DWD ICON | `DwdOptions()` | `HourlyDwd()` | `DailyDwd()` | `FifteenMinutesDwd()` |
    | JMA | `JmaOptions()` | `HourlyJma()` | `DailyJma()` | - |
    | MET Norway | `MetnoOptions()` | `HourlyMetno()` | - | - |
    | GEM | `GemOptions()` | `HourlyGem()` | `DailyGem()` | - |
    | Marine Weather | `MarineOptions()` | `HourlyMarine()` | `DailyMarine()` | - |
    | Air Quality | `AirQualityOptions()` | `HourlyAirQuality()` | - | - |
    | Geocoding | `GeocodingOptions()` | - | - | - |
    | Elevation | `ElevationOptions()` | - | - | - |
    | Global Flood | `FloodOptions()` | - | `DailyForecast()` | - |
  4. Explore the openmeteopy.options package modules

    main

    The openmeteopy.options package provides specialized option modules for various meteorological data sources, services, and environmental parameters. Developers can use these modules to configure requests or parameters specific to different providers and data types.

    Available modules include:

    • Air Quality: openmeteopy.options.air_quality
    • Data Providers/Models:
      • openmeteopy.options.dwd (Deutscher Wetterdienst)
      • openmeteopy.options.ecmwf (European Centre for Medium-Range Weather Forecasts)
      • openmeteopy.options.gfs (Global Forecast System)
      • openmeteopy.options.jma (Japan Meteorological Agency)
      • openmeteopy.options.meteo_france
      • openmeteopy.options.metno (Norwegian Meteorological Institute)
    • Environmental/Specialized Data:
      • openmeteopy.options.elevation
      • openmeteopy.options.flood
      • openmeteopy.options.gem
      • openmeteopy.options.geocoding
      • openmeteopy.options.marine
    • Temporal/Forecast Types:
      • openmeteopy.options.forecast
      • openmeteopy.options.historical
  5. Explore the openmeteopy.hourly package modules

    main
    The openmeteopy.hourly package provides specialized modules for accessing hourly meteorological and environmental data from various global and regional providers. Use these modules to fetch data from specific sources such as air quality services, national weather services (DWD, JMA, Meteo France, MetNO), or global forecast models (ECMWF, GFS, GEM).
  6. Access pressure level variables

    main

    Pressure level variables (e.g., temperature, humidity, wind) are accessed by appending the pressure level to the variable name with an underscore.

    Pattern: {variable}_{pressure_level}()

    Example: To get temperature at 1015 hPa, use temperature_1015hpa().

    Available variables for pressure levels include:

    • weathercode (WMO code)
    • temperature_{level} (°C / °F)
    • relativehumidity_{level} (%)
    • dewpoint_{level} (°C / °F)
    • cloudcover_{level} (%)
    • windspeed_{level} (km/h, mph, m/s, knots)
    • winddirection_{level} (°)
    • geopotential_height_{level} (meters)
  7. Interpret WMO Weather Codes

    main

    The weathercode variable returns a WMO (World Meteorological Organization) code. Use the following mapping to interpret the weather condition:

    • 0: Clear sky
    • 1, 2, 3: Mainly clear, partly cloudy, and overcast
    • 45, 48: Fog and depositing rime fog
    • 51, 53, 55: Drizzle (Light, moderate, and dense intensity)
    • 56, 57: Freezing Drizzle (Light and dense intensity)
    • 61, 63, 65: Rain (Slight, moderate and heavy intensity)
    • 66, 67: Freezing Rain (Light and heavy intensity)
    • 71, 73, 75: Snow fall (Slight, moderate, and heavy intensity)
    • 77: Snow grains
    • 80, 81, 82: Rain showers (Slight, moderate, and violent)
    • 85, 86: Snow showers (slight and heavy)
    • 95: Thunderstorm (Slight or moderate)
    • 96, 99: Thunderstorm with slight and heavy hail
  8. Request pressure level variables

    main

    You can request atmospheric variables at specific pressure levels. To do this, use a method name following the pattern: {variable}_{pressure_level}().

    For example, to get temperature at 1015 hPa, use temperature_1015hpa().

    Supported Pressure Levels (hPa): 10, 20, 30, 50, 100, 150, 175, 200, 225, 250, 275, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 875, 900, 925, 950, 970, 985, 1000, 1015.

    Available Pressure Level Variables:

    • weathercode (WMO code)
    • temperature_{level} (°C/°F)
    • relativehumidity_{level} (%)
    • dewpoint_{level} (°C/°F)
    • cloudcover_{level} (%)
    • windspeed_{level} (km/h, mph, m/s, knots)
    • winddirection_{level} (°)
    • geopotential_height_{level} (meters)
    # Example: Requesting geopotential height at 600hPa
    from openmeteopy import OpenMeteo
    from openmeteopy.hourly import HourlyJma
    from openmeteopy.options import JmaOptions
    
    longitude = 139.817413
    latitude =  35.672855
    
    hourly = HourlyJma()
    options = JmaOptions(latitude, longitude)
    
    # Use the specific pressure level method
    mgr = OpenMeteo(options, hourly.geopotential_height_600hpa())
    
    meteo = mgr.get_pandas()
    print(meteo)
  9. Request variables at specific pressure levels

    main

    You can request atmospheric variables at specific pressure levels (e.g., temperature, humidity, wind) by appending an underscore and the pressure level to the variable name.

    Pattern: {variable}_{pressure_hpa}()

    Example: To get temperature at 1015 hPa, use temperature_1015hpa().

    Available Pressure Levels and approximate elevations:

    • 10 hPa (~26 km)
    • 100 hPa (~15.8 km)
    • 500 hPa (~5.6 km)
    • 700 hPa (~3 km)
    • 850 hPa (~1500 m)
    • 1000 hPa (~110 m)
    • 1015 hPa (~ -10 m)

    Note: For precise altitudes, use geopotential_height at the desired pressure level.

  10. How to request pressure level variables

    main

    Pressure level variables (like temperature or wind speed at specific atmospheric pressures) are accessed by appending an underscore and the pressure level (in hPa) to the variable name.

    Pattern: {variable}_{pressure_level}hpa()

    Example: To get geopotential height at 600 hPa, use geopotential_height_600hpa().

  11. Get weather forecasts using OpenMeteo

    main

    To retrieve weather data, you need to define your location using ForecastOptions, select specific weather variables from HourlyForecast or DailyForecast, and then use the OpenMeteo manager to fetch the data. The manager can return the data as a Pandas DataFrame via the .get_pandas() method.

    Workflow:

    1. Define latitude and longitude.
    2. Initialize ForecastOptions with the coordinates.
    3. Instantiate HourlyForecast and DailyForecast to select desired variables.
    4. Create an OpenMeteo instance passing the options and the selected variables.
    5. Call .get_pandas() to download the data.
    from openmeteopy import OpenMeteo
    from openmeteopy.hourly import HourlyForecast
    from openmeteopy.daily import DailyForecast
    from openmeteopy.options import ForecastOptions
    
    # Latitude, Longitude 
    longitude = 33.89
    latitude =  -6.31
    
    hourly = HourlyForecast()
    daily = DailyForecast()
    
    options = ForecastOptions(latitude, longitude)
    
    # Select variables (e.g., shortwave radiation for both hourly and daily)
    mgr = OpenMeteo(options, hourly.shortwave_radiation(), daily.shortwave_radiation_sum())
    
    # Download data as a Pandas DataFrame
    meteo = mgr.get_pandas()
    
    print(meteo)