UBC-MDS / airpyllution

Python package for visualising future, historic and current air pollution data
Other
2 stars 2 forks source link

Discussion on Functions (Python) #2

Closed christopheralex closed 2 years ago

christopheralex commented 2 years ago

Ways to use the API for functionality of our package.

Take away from the meetings regarding the same -

  1. Data overview.
  2. Plot.
  3. Analysis.
danfke commented 2 years ago

In relation to mapping pollution/weather, what were you guys thinking? Like literally mapping some sort of marker onto a map? How would we do that in Altair?

mel-liow commented 2 years ago

Yeah, I was thinking more that the function accepts an array of cities or something, and then based on the values of pollutant values it returns (https://openweathermap.org/api/air-pollution), we could plot a circle on the map of the location and colour it based on air quality where red is very poor, green is great.

mel-liow commented 2 years ago

We could also create a forecast() function that shows air pollution prediction for the next 5 days and it could output a simple line chart

danfke commented 2 years ago

Yeah, I was thinking more that the function accepts an array of cities or something, and then based on the values of pollutant values it returns (https://openweathermap.org/api/air-pollution), we could plot a circle on the map of the location and colour it based on air quality where red is very poor, green is great.

So you are saying that instead of a user finding pollution levels for one location they would specify multiple locations that they are interested in first?

Similar to what you just said, we could implement the function to accept one location, and then within the function an array is generated (containing coordinates within a certain range of the input coordinates) after which pollutant values are obtained for each position of the array which we then use to create a map

Or we could even do a combination of these two ideas?

Let me know if I'm misunderstanding you

mel-liow commented 2 years ago

Also, another analysis/data collection function could be that it makes a request to fetch historic data, and then for the JSON object that gets returned - we output it into a pandas data frame or a csv

danfke commented 2 years ago

Sounds like three good function ideas, one for past, present, and future, I like it!

mel-liow commented 2 years ago

@danfke Yes, so it could accept one or more locations (we'll need to somehow get the long/latitude values of these locations, or require them to only pass in long/lat values) and we will summarise how polluted these areas are on a world map.

I like your second idea too - maybe they pass in a single set of coordinates, and then we generate other coordinates based on that input and get data from within a radius of the initial coordinates

danfke commented 2 years ago

I like the idea of the user not needing coordinates, I did a quick google search and there's a package called geopy that translates locations to coordinates, I think. Our functions could determine whether a coordinate or location name is entered and then act accordingly

christopheralex commented 2 years ago

I like your second idea too - maybe they pass in a single set of coordinates, and then we generate other coordinates based on that input and get data from within a radius of the initial coordinates

But we could do this only if we have data for the nearby coordinates right ?

danfke commented 2 years ago

Hmm good point @christopheralex, I'm sure we could work around that by having it only display points for where there is data, or else just scrap that idea entirely

christopheralex commented 2 years ago

My suggestion. Lets first create a POC ( proof of concept) for using our API and seeing what data we are getting and then make a decision ? If data is given in JSON then giving out a dataframe could be a function. I haven't tried using the API yet . Will get back once I get there or if any of you have a tried something out, It would be great if you could share your learnings.

danfke commented 2 years ago

I agree with that, I've created an account and obtained an API key but so far it doesn't work (I'm getting response 401) - my welcome email said it should work after a couple hours but it has been more than that. I'm hoping that they just gave an underestimate

mel-liow commented 2 years ago

I'll also look into calling the API this evening - I found tutorial https://www.geeksforgeeks.org/python-find-current-weather-of-any-city-using-openweathermap-api/ which might be useful

christopheralex commented 2 years ago

I agree with that, I've created an account and obtained an API key but so far it doesn't work (I'm getting response 401) - my welcome email said it should work after a couple hours but it has been more than that. I'm hoping that they just gave an underestimate

Dan did you get through ?

I'll also look into calling the API this evening - I found tutorial https://www.geeksforgeeks.org/python-find-current-weather-of-any-city-using-openweathermap-api/ which might be useful

I will look into it tonight well unless there is something else you guys want me to look into .

danfke commented 2 years ago

Tried this morning still didnt work lol but I will follow along with Mel's link and see if I'm doing something wrong

danfke commented 2 years ago

I got it to work, it was just a dumb mistake. I don't think you can type the API Key directly into the URL they give you because I didn't realize they expect you to use it as an f-string which gets rid of the curly brackets present in the URL 🤦🏻

christopheralex commented 2 years ago

Closing issue . Can reopen if needed in next milestone