https://deepnote.com/@daniel-zvara-036a/Time-to-sunburn-73Bmeo76QwO33IxA3GYGcQ HomeExploreCommunity Sign in This is a published Deepnote notebook. Hit Launch in Deepnote to try an interactive version that you can edit [?][?] Time to sunburn by Daniel ZvaraDaniel ZvaraJun 15, 2021 Launch in Deepnote 10 likes28 duplicates Share Twitter Facebook Linkedin Email Copy link Save as PDF 1. Time to sunburn [?] 1. 1. Fitzpatrick Skin Types 2. Location 3. Sun protection factor (sunscreen) 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 [Type II ] Location Location [San Francisco ] from geopy.geocoders import Nominatim import requests import pandas as pd import os skin_type_coeff = { 'Type I': 5, 'Type II': 10, 'Type III': 15, 'Type IV': 25, 'Type V': 45, 'Type VI': 90, } # retrieve GPS coordinates geolocator = Nominatim(user_agent="deepnote") location = geolocator.geocode(Location) if not location: raise Exception('Location not found') location Sun protection factor (sunscreen) spf [15] import os import requests OPENCAGEDATA_API_KEY = os.environ[ 'OPENCAGEDATA_API_KEY'] # retrieve GPS coordinates location_response = requests.get(f'https://api.opencagedata.com/geocode/v1/json?key={ OPENCAGEDATA_API_KEY}&q={Location}&no_annotations=1&limit=1') if not location_response.ok: raise Exception('Location not found') location_json = location_response.json() coordinates = location_json[ 'results'][0]['bounds']['northeast'] # fetch weather info raw_response = requests.get(f'https://api.openweathermap.org/data/2.5 /onecall?lat={coordinates["lat"]}&lon={coordinates["lng"]}&exclude= minutely,hourly,daily,alerts&appid={os.environ["OPENWEATHER_API_KEY"] }') if not raw_response.ok: raise Exception('Failed to fetch weather data') response = raw_response.json() uvi = response['current']['uvi' ] # calculate exposure time spf = max(int(spf), 1) def get_exposure( coeff): return (coeff * 8 / max(1, uvi))*spf Visualization ofsafe_exposure_times [ ]Bar Chart X axis [ ]safe exposure (minutes) Y axis [ ]skin type Color [ ]safe exposure (minutes) Recommended on Deepnote Stock market analysis - image Stock market analysis Last updated 14 hours ago 10 ways to create NumPy arrays - image 10 ways to create NumPy arrays Last updated 6 months ago Wide Residual Networks - image Wide Residual Networks Last updated 6 months ago