powerplant
powerplant copied to clipboard
Library function for finding weather warnings
Write function that finds a list of current weather warnings (frost, rain) when given a geographic location.
Weather data is obtained from external web weather services. There are libraries available for many weather services, and generally the data is in JSON or XML format so it is fairly easy to handle manually.
Place code for example in shared/weather.js. Write also a test.
@petteripitkanen I'll take this one
@petteripitkanen by location are you looking for zip code? city and state? both? something else?
Thanks, I mean an object that has the properties latitude
and longitude
, though some weather services might need some sort of address for querying weather information. It looks like these components are needed:
- Functions to convert a geographic location (latitude and longitude) to city name, and possibly to other sort of addresses.
- Functions to fetch weather information from web services to a JS object. Note that there might be libraries available to help with this. Even if the web service is giving only XML it would be nice to convert this to JS at this point, so that the parsing functions for different formats can possibly share code.
- Functions to parse current weather information to extract weather warnings into a common format independent of the web service that is used as input.
Some weather services might explicitly present weather warnings in the data, for some other services it might be necessary to parse temperature and precipitation information to extract the weather warnings (frost and rain). Some weather services might also provide forecasts.
How this will get integrated to powerplant is still TODO.
I'm almost done with this. I'm just working on the unit testing. Trying to figure out how to get sinon stub to work (to simulate JSON data being returned by weather API call).
Just submitted a PR. For some reason couldn't get npm run doc
to work so added jsdoc comments manually.
As far as rain warnings go, wondering if this is useful. The dark sky API gives you a forecast for the next 8 days. It can determine if it will rain or not. So I could have the function say "rain is expected in 5 of the next 8 days." The API doesn't distinguish between say drizzle, rain and a storm. Is that a problem? If it is I can find another API.
Along with having the information if there will be rain it would be interesting to know how accurate this is for the different forecast day offsets, but for now it's difficult to say how exactly this information should be used to present warnings for the user.
Besides weather warnings there could be more uses for generic weather data, like estimating the amount of water that would be harvested. Another reason for storing the weather data to a generic format is that the user may already be using some weather API, so it should be possible to just write an adapter for their API and make rest of the calculations (weather warnings, harvest estimations, etc.) use the generic data. Instead of working on weather warnings, it is better for now to concentrate on getting weather data from the Dark Sky API, converting it to a generic format, and storing it to farmOS. In farmOS it is possible to draw graphs based on sensor data, so simply storing weather data could be useful for the user (after farmOS is installed it is easy to try this by using curl
as instructed here).
We could extend the generic format in #99 that already includes timestamp
and rain
to also include forecast variables rainForecast24Hour
, rainForecast48Hour
, rainForecast72Hour
, where each of these variables would have a binary value just like rain
. This would make it possible to later determine accuracy percentages for the different forecast day offsets.
Looking at https://darksky.net/dev/docs, instead of using the textual properties summary
and icon
, it would be preferable to use the properties precipProbability
and precipIntensity
(and perhaps other precip*
properties) by defining threshold values that would be used to determine whether there is rain or not. For now it is safer to determine just a binary value, later when we extend this to other APIs, we could find some common unit and make the generic rain variables more accurate. It looks like the same function for determining rain can be used for both the current observation and forecasts.
Yes it is quite tricky to determine how to present warnings and focusing on getting weather data is the way to go. Since I already started on issue 83 I'd like to continue working on that.
On Mon, Sep 30, 2019 at 11:14 AM petteripitkanen [email protected] wrote:
Along with having the information if there will be rain it would be interesting to know how accurate this is for the different forecast day offsets, but for now it's difficult to say how exactly this information should be used to present warnings for the user.
Besides weather warnings there could be more uses for generic weather data, like estimating the amount of water that would be harvested https://en.wikipedia.org/wiki/Permaculture#Rainwater_harvesting. Another reason for storing the weather data to a generic format is that the user may already be using some weather API, so it should be possible to just write an adapter for their API and make rest of the calculations (weather warnings, harvest estimations, etc.) use the generic data. Instead of working on weather warnings, it is better for now to concentrate on getting weather data from the Dark Sky API, converting it to a generic format, and storing it to farmOS. In farmOS it is possible to draw graphs based on sensor data, so simply storing weather data could be useful for the user (after farmOS is installed it is easy to try this by using curl as instructed here https://farmos.org/guide/assets/sensors/).
We could extend the generic format in #99 https://github.com/Ecohackerfarm/powerplant/issues/99 that already includes timestamp and rain to also include forecast variables rainForecast24Hour, rainForecast48Hour, rainForecast72Hour, where each of these variables would have a binary value just like rain. This would make it possible to later determine accuracy percentages for the different forecast day offsets.
Looking at https://darksky.net/dev/docs, instead of using the textual properties summary and icon, it would be preferable to use the properties precipProbability and precipIntensity (and perhaps other precip* properties) by defining threshold values that would be used to determine whether there is rain or not. For now it is safer to determine just a binary value, later when we extend this to other APIs, we could find some common unit and make the generic rain variables more accurate. It looks like the same function for determining rain can be used for both the current observation and forecasts.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Ecohackerfarm/powerplant/issues/2?email_source=notifications&email_token=ALAQO33B67ECUJBKRHI3FI3QMI6XNA5CNFSM4GA6FLM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD76SQTI#issuecomment-536684621, or mute the thread https://github.com/notifications/unsubscribe-auth/ALAQO33FMWORZX5CJFGYZULQMI6XNANCNFSM4GA6FLMQ .