Find Your Climate

Based on your current weather


Discover something new

The Project

Here is an app that tells you what country has a climate most similar to your weather.

You can see the source code that this is based off of below.

This, of course, uses a little bit more with some javascript magic to display a nice image based off of the result.

Tip: Most areas default to Malaysia because they are average temperature, high humidity, and no precipitation. Try a friends location :)





The code

The backend code for the original python project without any of the web server modifications can be found here:


#Aengus Patterson
#September 9th, 2023
#gathers data from Tomorrow.io and displays the most relavent country


import requests

#gathers weather informtation from tomorrow.io
def retrieve_data():
    # Define the API endpoint and query parameters
    url = "https://api.tomorrow.io/v4/weather/forecast"
    params = {
	#enter your coordinates and api key here.
        "location": "40.434868, -90.627046",
        "apikey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }

    # Make the GET request
    response = requests.get(url, params=params)

    # Check if the request was successful, otherwise return error.
    if response.status_code == 200:
        # Parse and return data
        data = response.json()
        return data
    else:
        return(f"Error: {response.status_code} - {response.text}")


data = retrieve_data()

#formats to just the current data
current_data = temperature = data['timelines']['minutely'][0]['values']

#gathers basic data
temp = current_data["temperature"]
precipitation = current_data["rainIntensity"] + current_data["sleetIntensity"] + current_data["snowIntensity"]
humidity = current_data["humidity"]

#prints off the data
print ("current tempurature in (C): " + str(temp))
print ("current precipitation intensity: " + str(precipitation))
print ("current humidity %: " + str(humidity))

#lists off all possible country combinations
countries_dict = {
    'Hot': {
        'High Humidity': {
            'High Precipitation': ['Singapore'],
            'Low Precipitation': ['Saudi Arabia'],
        },
        'Low Humidity': {
            'High Precipitation': ['India'],
            'Low Precipitation': ['Egypt'],
        },
    },
    'Cold': {
        'High Humidity': {
            'High Precipitation': ['Japan'],
            'Low Precipitation': ['Canada'],
        },
        'Low Humidity': {
            'High Precipitation': ['Russia'],
            'Low Precipitation': ['Mongolia'],
        },
    },
    'Average': {
        'High Humidity': {
            'High Precipitation': ['Brazil'],
            'Low Precipitation': ['Malaysia'],
        },
        'Low Humidity': {
            'High Precipitation': ['Ireland'],
            'Low Precipitation': ['Algeria'],
        },
    },
}

#determines which country should be chosen
simplified_temp = "Cold"
if temp > 10:
    simplified_temp = "Average"
if temp > 26.7:
    simplified_temp = "Hot"
simplified_precipitation = "Low Precipitation"
if precipitation > 2:
    simplified_precipitation = "High Precipitation"
simplified_humidity = "Low Humidity"
if humidity > 45:
    simplified_humidity = "High Humidity"

matched_country = countries_dict[simplified_temp][simplified_humidity][simplified_precipitation]

#prints off your data and matched country
print ("Your current weather is: " + simplified_temp + ", " + simplified_humidity + ", " + simplified_precipitation)
print ("If you like that weather, then you should check out this country: ")
print (matched_country)