โ† Back to home

ISS Overhead Notifier

ยท

Python implementation of International Space Station overhead

Open-Notify is an open source project to provide programming interface for NASA's data.

Outline

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#http://open-notify.org/Open-Notify-API/ISS-Location-Now/
#http://api.open-notify.org/iss-now.json
#https://www.latlong.net/

import requests
from datetime import datetime as dt
import time

def is_iss_overhead():
    response=requests.get(url="http://api.open-notify.org/iss-now.json")
    response.raise_for_status()
    response_data=response.json()
    iss_lat=float(response_data["iss_position"]["latitude"])
    iss_longitude=float(response_data["iss_position"]["longitude"])
    #Your position is within +5 or -5 degrees of the ISS position
    if parameters["lat"]-5<=iss_lat<=parameters["lat"]+5 and parameters["lng"]-5<=iss_longitude<=parameters["lng"]+5:
        return True


def is_night():
    parameters={
        "lat":12.971599,
        "lng":77.594566,
        "formatted":0
    }

    response=requests.get("https://api.sunrise-sunset.org/json",params=parameters)
    response.raise_for_status()
    response_data=response.json()
    sunrise=response_data["results"]["sunrise"].split("T")[1].split(":")[0]
    sunset=response_data["results"]["sunset"].split("T")[1].split(":")[0]

    time_now=dt.now().hour()

    if time_now>=sunset or time_now<=sunrise:
        return True     


while True:
    time.sleep(60)
    if is_iss_overhead() and is_night():
        #TODO: send email function
        pass
This is the intentional end of this page.
โ† Previous Next โ†’