Git Product home page Git Product logo

knmy's People

Contributors

barthoekstra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

knmy's Issues

issue with parser

When I try using this example code I get the following error.
Am I doing something wrong or is this script out of date?

Traceback (most recent call last):
  File "W:\Some_map\knmi.py", line 3, in <module>
    disclaimer, stations, variables, data = knmy.get_hourly_data(stations=[209, 235], start=2022061715, end=2022061716, inseason=True, variables=['WIND', 'TEMP'], parse=True)
  File "C:\Users\some_name\AppData\Local\Programs\Python\Python39\lib\site-packages\knmy\knmy.py", line 214, in get_hourly_data
    return get_knmi_data('hourly', stations=stations, start=start, end=end, variables=variables, inseason=inseason,
  File "C:\Users\some_name\AppData\Local\Programs\Python\Python39\lib\site-packages\knmy\knmy.py", line 136, in get_knmi_data
    return parse_raw_weather_data(r.text)
  File "C:\Users\some_name\AppData\Local\Programs\Python\Python39\lib\site-packages\knmy\parser.py", line 31, in parse_raw_weather_data
    stations_raw = next(chunk)
StopIteration

Possible improvement: add warnings

Great tool! I successfully used your package to download daily KNMI data for all avalaible stations using just a few lines of code. I have some suggestions which might offer improvements:

  • Add warnings. For example, I tried to download time series including the period 1901-2022, which resulted in the following error:
    image

Apparently, the KNMI API does not support retrievals of this length: 'De query geeft te veel resultaten terug. Pas uw parameters aan!' You could add a warning message when this message is returned by the api call.

  • Add multi-dimensional array (data cube) support using e.g. xarray:
    image

I might be able to contribute if you are interested in adding this functionality.

Best,
Michiel

Solving error caused by external change of data structure

Your tool is excellent!

There appears to have been a change in the way the data is delivered by KNMI. Date and time columns are repeated, leading the parser to fail.

In the parser, I modified the code as follows (line 61):
# We've reached the header of the CSV section with data
raw_header = line.strip('# ').replace(' ', '')
raw_header = raw_header.split(',')

            # Remove duplicate headers to avoid error
            header = []
            for item in raw_header:
                if item not in header:
                    header.append(item)

An additional change is in the way the headers are specified when creating the dataframe:
data = pd.read_csv(StringIO('\n'.join(records)), names=header)

The split of the string is not required here anymore.

Hope this helps.

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.