4 days ago I decided to increase my Python knowledge by exploring JSON files. I found out that NASA give free access to data it collects (massive thank you to NASA!). I quickly signed up for an API key and decided that my first attempt at using the NASA data should be around NEOs. This was spurred on by the fact that 1) I used to do astronomy and 2) I watched Armageddon and Deep Impact a few too many times as a kid.
I hit a stumbling block whilst creating my NEO Python program in that I could not get my head around dictionaries, keys and lists. After some time (and a beer) this evening I made some head way (releasing V2 of my program) before finally getting it to do the majority of what of want in this (V3) release:
#Big thanks to NASA API (https://api.nasa.gov/api.html), get your API key from this site.
import json, requests
#I have an API Key but I don’t want to share it here!
#message to welcome the user
print(‘Hi and welcome to GeekTechStuff\’s NASA Near Earth Object (NEO) Python program’)
print(‘This programme uses NASA\’s open API system’)
print(‘This Python program searches a data for NEOs’)
#asks the users for dates, these must be in yyyy-mm-dd format
start_date=input(‘Please enter an eight digit date in yyyy-mm-dd format for the start date:’)
#end_date=input(‘Please enter an eight digit date in yyyy-mm-dd format for the end date:’)
#opens JSON file containing NEO data
print(‘Loading data from’,url)
#uses the json loaded from get_json
print(‘On’,start_date,’there were’,number_of_neo,’near Earth objects’)
for n in neo_range:
print(“Check out the NASA page for the NEO at:”)
if nd2[n][“is_potentially_hazardous_asteroid”] == False:
print(‘It was not potentially hazardous’)
print(‘It was potentially hazardous’)
One thought on “NASA NEO V3 (Python)”
Comments are closed.