Code Monkey home page Code Monkey logo

Comments (3)

pnuu avatar pnuu commented on August 20, 2024

The library works as expected, but you are accessing the data in the non-timeseries way 😉 As the documentation says, with timeseries=True the data are organized by location:

print(obs).data.keys())
# -> dict_keys(['Helsinki Kaisaniemi'])
print(obs.data["Helsinki Kaisaniemi"].keys())
# -> dict_keys(['times', 't2m', 'ws_10min', 'wg_10min', 'wd_10min', 'rh', 'td', 'r_1h', 'ri_10min', 'snow_aws', 'p_sea', 'vis', 'n_man', 'wawa'])
print(obs.data["Helsinki Kaisaniemi"]["t2m"].keys())                   
# -> dict_keys(['values', 'unit'])
print(obs.data["Helsinki Kaisaniemi"]["t2m"]["values"][0])             
# -> 7.7

When you use the capitalized version, you are getting the same version as you'd get withtimeseries=False, that is, not a timeseries version.

from fmiopendata.

jeppoo1 avatar jeppoo1 commented on August 20, 2024

Thank you very much @pnuu! I got it to work somehow now.

I'm very sorry if this is not the right place to ask for further instructions, but I would need help in understanding why my script does not return me enough data. I would like to download historical weather data for the past 10 years or so, but I'm unable to download even a full day of data with my current script:

print(dt.datetime.utcnow())
print(dt.timedelta(hours=9))
end_time = dt.datetime.utcnow()
start_time = end_time - dt.timedelta(hours=24)
# Convert times to properly formatted strings
start_time = start_time.isoformat(timespec="seconds") + "Z"
end_time = end_time.isoformat(timespec="seconds") + "Z"
print("Start time:", start_time, "\nEnd time:", end_time)

obs = download_stored_query("fmi::observations::weather::multipointcoverage",
args=["bbox=24.87,60.14,25.01,60.19", "bbox=24.88,60.14,25.01,60.19"
"timeseries=True"])

print("SORTED OBS DATA KEYS:", sorted(obs.data.keys()))
print(obs.data["Helsinki Kaisaniemi"].keys())
print(obs.data["Helsinki Kaisaniemi"]["t2m"].keys()) # t2m = temperature
print(obs.data["Helsinki Kaisaniemi"]["t2m"]["values"])
print(len((obs.data["Helsinki Kaisaniemi"]["times"])))
for i in range(0, len((obs.data["Helsinki Kaisaniemi"]["times"]))):
print(obs.data["Helsinki Kaisaniemi"]["times"][i])

I have tried to alter the start_time = end_time - dt.timedelta(hours=24) "hours" to 48 or 100 or 200 but no matter what I enter, this script always returns me 72 datapoints (len((obs.data["Helsinki Kaisaniemi"]["times"]) returns 72).
What should I do in order to download more data points, so that I would be able to download for example a full month of Kaisaniemi weather data?

from fmiopendata.

pnuu avatar pnuu commented on August 20, 2024

I would need help in understanding why my script does not return me enough data. I would like to download historical weather data for the past 10 years or so, but I'm unable to download even a full day of data with my current script:

end_time = dt.datetime.utcnow()
start_time = end_time - dt.timedelta(hours=24)
# Convert times to properly formatted strings
start_time = start_time.isoformat(timespec="seconds") + "Z"
end_time = end_time.isoformat(timespec="seconds") + "Z"

obs = download_stored_query("fmi::observations::weather::multipointcoverage",
args=["bbox=24.87,60.14,25.01,60.19", "bbox=24.88,60.14,25.01,60.19"
"timeseries=True"])

What should I do in order to download more data points, so that I would be able to download for example a full month of Kaisaniemi weather data?

You haven't used the start_time and end_time in the query. and to be sure to get only data from Kaisaniemi, use the place parameter (see FMI Open Data manual for the syntax used below). The call should be:

obs = download_stored_query("fmi::observations::weather::multipointcoverage", args=["place=kaisaniemi,helsinki", "timeseries=True", "starttime=" + start_time, "endtime=" + end_time])

As a general note, I suggest not to download 10 years of data in one go, but split it in for example 1 month chunks. That way possible network errors won't ruin the whole query, and more importantly, it will be easier on the servers at FMI.

from fmiopendata.

Related Issues (20)

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.