Time to sunburn ☀️
Summer is here, and the sun is up! But it's not always easy to know how long we can enjoy it while staying safe. In this article I'm using Python to calculate how long you can safely sunbath, based on your skin type, geographical location and sunscreen applied. Let's have a look!
Fitzpatrick Skin Types
Skin_type
Location
Location
Sun protection factor (sunscreen) 🏖
spf
# retrieve GPS coordinates
geolocator = Nominatim(user_agent="deepnote")
location = geolocator.geocode(Location)
if not location:
raise Exception('Location not found')
# fetch weather info
raw_response = requests.get(f'https://api.openweathermap.org/data/2.5/uvi?lat={location.latitude}&lon={location.longitude}&appid={os.environ["OPENWEATHER_API_KEY"]}')
if (raw_response.status_code != 200):
raise Exception('Failed to fetch weather data')
response = raw_response.json()
uvi = response['value']
# calculate exposure time
spf = max(int(spf), 1)
def get_exposure(coeff):
return (coeff * 8 / uvi)*spf