Generate EPW file for any location & any year from 1940

Hi,

A few people have asked about accessing EPW file via API and I thought I’d also share here. We’ve recently added a new API endpoint (https://api.oikolab.com/epw) to get AMY or TMY EPW file via API by specifying lat/lon or location name and the year of interest. Here’s a sample Python code:

import requests

api_key = 'your_api_key_here'

r = requests.get('https://api.oikolab.com/epw',
                 params={'lat': 42.1, 'lon': -71.2, 'year': 2012},
                 headers={'api-key': api_key},)

with open('amy_filename.epw','wb') as f:
    f.write(r.content)

If the ‘year’ value is omitted from the request it will generate a TMY file based on last 15 years of data. Note that you can also provide ‘location’ value instead of lat/lon, in which case we’ll do a lat/lon lookup for the place name (we do a reverse-geocode lookup when lat/lon values are provided).

A couple of tweaks were added to make this a bit more usable:

  • Both AMY and TMY will use 250 units, which will allow up to 6 free AMY EPW files per month under the free tier. The TMY files were previously generated using the same weather data API using 15 years worth of data so a few users were surprised to see that it used so many more units so we’ve been meaning to fix that for a while.
  • Since this isn’t a fast changing data, we’ve also added a cache check so that if you repeatedly call the EPW API within say 8~12 hours and cached data is still available, we’ll return the cached data which will be a) much faster and b) will only take 1 unit per call instead of chargin 250 units for the data again.

Hopefully this will address some issues when people have a hard time finding the relevant EPW file. Note that the EPW files are generated on the fly so it take ~10 seconds for AMY file and ~25 seconds for TMY file but hopefully this won’t be too much of an inconvenience. The EPW files are generated from ERA5 dataset from ECMWF, with some reference discussions here.

Any questions/feedback, please feel free to ask. Of course, everything noted above still applies if you download it via the app, available at https://weatherdownloader.oikolab.com/.

Thanks!
Joseph

@chris @SaeranVasanthakumar @lionpeloux

7 Likes

Thank you so much for the effort and time!
We want to use the EPW generator
how can we get an API key to use the tool at its maximum potential?
Im not a programer, Im city Manager who is looking for this solutions to be applied at Mexico.
We use climate consultant and some other apps that i would like to run with more specific data.
thank you again

Hi @GerardoD - thanks for the kind feedback. You can sign up for an account at https://oikolab.com and you will be assigned an API key which you can see in your profile.

If you’re not a programmer and you’d like to download an EPW file, you can download it by pasting your API in the top-left text box you see below:

2 Likes

FYI, the Downloader app and the EPW API endpoint have both been updated to allow users to create EPW files for custom date range.

1 Like