Skip to content

Plotted 4 weather variables to understand what the climate is like around the world.

Notifications You must be signed in to change notification settings

Uc71/Plotting-Global-Weather-by-Latitude

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 

Repository files navigation

Plotting-Global-Weather-by-Latitude

With this project, I visualized correlations between latitude, maximum temperature, % humidity, % cloud cover, and wind speed. I also sought visual insight into how these correlations differ between the Northern and Southern Hemispheres. This project is for understanding global weather as it stands on the day that the code is run.

To use my project, clone the repository to your computer, navigate into the Today'sWeather folder, open the "Today'sGlobalWeather.ipynb" file in Jupyter Notebook, and press the play buttons next to each code block in sequence.

After importing my dependencies, I generated a list of several hundred cities from around the world. I did this by generating pairs of random latitudes and longitudes, then using the citipy module to find the city closest to the point specified by the lat and lon numbers. Then, for each city in the list, I called the openweathermap.org API to get today's maximum temperature, % humidity, % cloud cover, and wind speed. In order not to lock myself out of the API by performing too many times each minute, I incorporated a time.sleep() line which caused my code to wait slightly more than a second before doing the next call. For each call, I used a try and except code chunk to check whether data actually existed for each city in the list before appending any data to my data lists. The cities are randomly selected, citipy sometimes approximates different points with the same city, and there is not always every desired piece of weather data for a given city. For these 3 reasons, the number of data points obtained for each weather variable data list may differ each time the code is run. Here is the beginning of the list of random cities: image

I used a line of code to convert all the temperatures from openweathermap.org from Celsius to Fahrenheit, then displayed all of the weather data, including the Fahrenheit temperatures, in a dataframe. The beginning of that df is shown here. For the 3 reasons listed in the previous paragraph, you may find that there are fewer rows in the df than there were randomly chosen cities. image

I run basic descriptive statistics on each of my variables: latitudes, maximum temperatures, humidities, cloud covers, and wind speeds. image

I plot today's % cloud cover against latitude. latclo

I plot the current humidity level against latitude. lathum

I plot the current wind speed against latitude. latspe

I plot today's maximum temperature against latitude. As I would expect, I see temperatures peaking near the equator and decreasing towards each pole. lattem

Now, I search for correlations between all of the variables. These are r values. image

I constructed 8 plots breaking down the previous 4 scatter plots by hemisphere and adding linear regression lines to each. For each plot, one of the variables will be latitude. Here is the plot for maximum temperatures in the Northern Hemisphere. As I expected, temperatures decrease as latitude increases. image

Here is the plot for maximum temperatures in the Southern Hemisphere. As I expected, temperatures increase as latitude increases. image

Here is the plot for humidities in the Northern Hemisphere. As I expected, humidity decreases as latitude increases. image

Here is the plot for humidities in the Southern Hemisphere. As I expected, humidity increases as latitude increases. image

Here is the plot for cloud cover in the Northern Hemisphere. image

Here is the plot for cloud cover in the Southern Hemisphere. image

Here is the plot for wind speeds in the Northern Hemisphere. image

Here is the plot for wind speeds in the Southern Hemisphere. image