Coder Social home page Coder Social logo

python-zamg's Introduction

python-zamg

GitHub Release GitHub Activity License

pre-commit Black Code Coverage

Project Maintenance

Python library to read 10 min weather data from ZAMG

About

This package allows you to read the weather data from weather stations of ZAMG weather service. ZAMG is the Zentralanstalt für Meteorologie und Geodynamik in Austria.

Installation

pip install zamg

Usage

Simple usage example to fetch specific data from the closest station.

"""Asynchronous Python client for ZAMG weather data."""
import asyncio

import src.zamg.zamg
from src.zamg.exceptions import ZamgError


async def main():
    """Sample of getting data"""
    try:
        async with src.zamg.zamg.ZamgData() as zamg:
            # option to disable verify of ssl check
            zamg.verify_ssl = False
            # trying to read zamg station id of the closest station
            data = await zamg.closest_station(46.99, 15.499)
            # set closest station as default one to read
            zamg.set_default_station(data)
            print("closest_station = " + str(zamg.get_station_name) + " / " + str(data))
            # print list with all possible parameters
            print(f"Possible station parameters: {zamg.get_all_parameters()}")
            # set parameters directly
            zamg.station_parameters = "TL,SO"
            # or set parameters as list
            zamg.set_parameters(("TL", "SO"))
            # if none of the above parameters are set, all possible parameters are read
            # do an update
            await zamg.update()

            print(f"---------- Weather for station {zamg.get_station_name} ({data})")
            for param in zamg.get_parameters():
                print(
                    str(param)
                    + " -> "
                    + str(zamg.get_data(parameter=param, data_type="name"))
                    + " -> "
                    + str(zamg.get_data(parameter=param))
                    + " "
                    + str(zamg.get_data(parameter=param, data_type="unit"))
                )
            print("last update: %s", zamg.last_update)
    except (ZamgError) as exc:
        print(exc)


if __name__ == "__main__":
    asyncio.run(main())

Contributions are welcome!

If you want to contribute to this please read the Contribution guidelines

Credits

Code template to read dataset API was mainly taken from @LuisTheOne's zamg-api-cli-client

Dataset API Dokumentation


python-zamg's People

Contributors

dependabot[bot] avatar killer0071234 avatar tklecka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.