Skip to content

Instantly share code, notes, and snippets.

@liddiard
Last active March 13, 2018 03:59
Show Gist options
  • Save liddiard/7c0d55f570b9f7aec41f6e4ec920dbdf to your computer and use it in GitHub Desktop.
Save liddiard/7c0d55f570b9f7aec41f6e4ec920dbdf to your computer and use it in GitHub Desktop.
Use OpenWeatherMap data to compile historical cloud cover by hour in specific months to figure out when the best time of day is to reserve VFR flight lessons.
data
.filter(x => (new Date(x.dt_iso)).getMonth() > 5 && (new Date(x.dt_iso)).getMonth() < 8)
.reduce((acc, x) => {
const h = (new Date(x.dt_iso)).getHours();
return acc.hasOwnProperty(h) ?
Object.assign({}, acc, { [h]: acc[h] + x.clouds.all }) :
Object.assign({}, acc, { [h]: x.clouds.all })
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment