Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library function for finding weather warnings #2

Open
petteripitkanen opened this issue Nov 1, 2018 · 8 comments
Open

Library function for finding weather warnings #2

petteripitkanen opened this issue Nov 1, 2018 · 8 comments

Comments

@petteripitkanen
Copy link
Collaborator

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.

@l0n3star
Copy link
Contributor

@petteripitkanen I'll take this one

@l0n3star
Copy link
Contributor

@petteripitkanen by location are you looking for zip code? city and state? both? something else?

@petteripitkanen
Copy link
Collaborator Author

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.

@l0n3star
Copy link
Contributor

l0n3star commented Sep 17, 2019

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).

@l0n3star
Copy link
Contributor

Just submitted a PR. For some reason couldn't get npm run doc to work so added jsdoc comments manually.

@l0n3star
Copy link
Contributor

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.

@petteripitkanen
Copy link
Collaborator Author

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.

@l0n3star
Copy link
Contributor

l0n3star commented Sep 30, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants