Mars Weather Service
Nasa’s Mars Weather API will provide weather data from Elysium Planitia region of Mars continously in terms of temperature, wind and pressure.
Here is a simply code that uses requests and json libraries.
Below you can find a simple code to extract temperature and wind data from Mars.
import requests
import json
import webbrowser
def marsweather():
f = r"https://api.nasa.gov/insight_weather/?api_key=DEMO_KEY&feedtype=json&ver=1.0"
data = requests.get(f)
tt = json.loads(data.text)
for i in tt:
return tt[i]["AT"], tt[i]["HWS"]
print(marsweather())
Output example:
Mars Weather
Nasa’s InSight robot takes continous weather data from Mars surface at Elysium Planitia.
Sol 349
Sol 350
High
1
F
Low
0
F
Max Wind
0.88
If you need a refresher on user defined functions lesson in Python here is a link to our Defining Functions Lesson.
Source of API: Nasa API Webpage
Documentation: PDF