From 518de69251184b3b361819371649a6252912fa2b Mon Sep 17 00:00:00 2001 From: horsaen Date: Sun, 27 Aug 2023 11:50:14 -0500 Subject: [PATCH 1/4] ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e1342c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +polrschd.txt \ No newline at end of file From 17e703378d409f2e89598a04379e2d7eca74ed8f Mon Sep 17 00:00:00 2001 From: horsaen Date: Sun, 27 Aug 2023 11:50:49 -0500 Subject: [PATCH 2/4] local time support --- README.md | 6 +++--- polrschd.py3 => polrschd.py | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) rename polrschd.py3 => polrschd.py (87%) diff --git a/README.md b/README.md index 00e5936..811a4f6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # polrschd Python script for predicting NOAA POES GAC transmissions. -The script will access the public NOAA schedule file at https://noaasis.noaa.gov/cemscs/polrschd.txt and parse events related to POES GAC (NOAA-15, NOAA-18, NOAA-19). It will then display the UTC time and date at which a satellite begins and ends its GAC transmission, as well as the frequency, polarization, and elevation of the satellite. +The script will access the public NOAA schedule file at https://noaasis.noaa.gov/cemscs/polrschd.txt and parse events related to POES GAC (NOAA-15, NOAA-18, NOAA-19). It will then display the UTC/local time and date at which a satellite begins and ends its GAC transmission, as well as the frequency, polarization, and elevation of the satellite. GAC transmissions can be subsequently demodulated and decoded by [LeanHRPT-Demod](https://github.com/Xerbo/LeanHRPT-Demod/) and [LeanHRPT-Decode](https://github.com/Xerbo/LeanHRPT-Decode/tree/gac) respectively. @@ -10,5 +10,5 @@ GAC transmissions can be subsequently demodulated and decoded by [LeanHRPT-Demod The script uses urllib, datetime and pyorbital. Only pyorbital is a non-default library and can be installed with pip ## Usage -Very basic usage for now; open polrschd.py3 and change the four parameters at the beginning of the file (input your latitude, longitude, altitude ASL and minimum satellite elevation). -Once configured, you can run the script and get a list of GAC transmissions available for your area. Make sure to then check the full pass with your normal prediction app (such as gpredict, Look4sat, etc.) +Very basic usage for now; open polrschd.py and change the four parameters at the beginning of the file (input your latitude, longitude, altitude ASL, minimum satellite elevation, and timezone (optional)). +Once configured, you can run the script and get a list of GAC transmissions available for your area. Make sure to then check the full pass with your normal prediction app (such as gpredict, Look4sat, etc.) \ No newline at end of file diff --git a/polrschd.py3 b/polrschd.py similarity index 87% rename from polrschd.py3 rename to polrschd.py index f6ab4b3..30629b9 100644 --- a/polrschd.py3 +++ b/polrschd.py @@ -1,22 +1,23 @@ +import urllib.request, os, time +from datetime import datetime +from dateutil import tz +from pyorbital.orbital import Orbital ######################################################################## ########################### PREDICT SETTINGS ########################### ########################### (change these!) ########################### ######################################################################## -yourLat = 78.22 # Your latitude -yourLon = 15.39 # Your longitude -yourAlt = 400 # Your altitude (meters above sea level) -minElevation = -2 # Minimum elevation of the GAC event (can be negative) +yourLat = 41.42 # Your latitude +yourLon = -92.22 # Your longitude +yourAlt = 230 # Your altitude (meters above sea level) +minElevation = 0 # Minimum elevation of the GAC event (can be negative) +utcTime = tz.gettz('UTC') # UTC timezone +localTime = tz.gettz('UTC') # Your local timezone ######################################################################## ######################################################################## - -import urllib.request, os, time -from datetime import datetime -from pyorbital.orbital import Orbital - # https://code.it4i.cz/blender/blender-embree3/-/blob/sculpt25/tools/bcolors.py class bcolors: HEADER = '\033[95m' @@ -57,7 +58,9 @@ class bcolors: for line in open(polrschdLocal, 'r'): # open txt, read each line text = line[:-1] # strip newline date = text[0:17] # get date from line - dateParsed = datetime.strptime(date, '%Y/%j/%H:%M:%S') # parse date from weird format YYYY/DDD/HH:MM:SS + utc = datetime.strptime(date, '%Y/%j/%H:%M:%S') # parse date from weird format YYYY/DDD/HH:MM:SS + utc = utc.replace(tzinfo=utcTime) # set timezone to UTC + dateParsed = utc.astimezone(localTime) # convert to local time satID = text[23:25] # get satellite number from line # parse satellite number ID into name From 64a9215ca0329fece87c64d8ead4fda4ace6e11c Mon Sep 17 00:00:00 2001 From: Roger van Bommel Date: Sun, 27 Aug 2023 19:25:22 +0200 Subject: [PATCH 3/4] clarify timezone format, add requirements.txt --- polrschd.py | 2 +- requirements.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 requirements.txt diff --git a/polrschd.py b/polrschd.py index 30629b9..b173a2d 100644 --- a/polrschd.py +++ b/polrschd.py @@ -13,7 +13,7 @@ yourAlt = 230 # Your altitude (meters above sea level) minElevation = 0 # Minimum elevation of the GAC event (can be negative) utcTime = tz.gettz('UTC') # UTC timezone -localTime = tz.gettz('UTC') # Your local timezone +localTime = tz.gettz('UTC') # Your local timezone(as abbreviation) ######################################################################## ######################################################################## diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f184992 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyorbital \ No newline at end of file From d6458ea6a79d80509e25b5650d920bf97fb68a52 Mon Sep 17 00:00:00 2001 From: horsaen Date: Tue, 28 Nov 2023 12:28:19 -0600 Subject: [PATCH 4/4] move to main, readme --- README.md | 20 ++++++-- main.py | 130 +++++++++++++++++++++++++++++++++++++++++++++++ polrschd.py | 122 -------------------------------------------- requirements.txt | 4 +- 4 files changed, 149 insertions(+), 127 deletions(-) create mode 100644 main.py delete mode 100644 polrschd.py diff --git a/README.md b/README.md index 811a4f6..aa53255 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,21 @@ GAC transmissions can be subsequently demodulated and decoded by [LeanHRPT-Demod ![thumbnail](https://github.com/sgcderek/polrschd/blob/main/thumbnail.jpeg?raw=true) -## Requirements -The script uses urllib, datetime and pyorbital. Only pyorbital is a non-default library and can be installed with pip +## Installation + +Clone repository +```bash +git clone https://github.com/horsaen/polrschd.git && cd polrschd +``` + +Install dependencies +```bash +pip3 install -r requirements.txt +``` ## Usage -Very basic usage for now; open polrschd.py and change the four parameters at the beginning of the file (input your latitude, longitude, altitude ASL, minimum satellite elevation, and timezone (optional)). -Once configured, you can run the script and get a list of GAC transmissions available for your area. Make sure to then check the full pass with your normal prediction app (such as gpredict, Look4sat, etc.) \ No newline at end of file + +Edit [main.py](main.py) to set required parameters, then simply run the script +```bash +python3 main.py +``` diff --git a/main.py b/main.py new file mode 100644 index 0000000..aa417f9 --- /dev/null +++ b/main.py @@ -0,0 +1,130 @@ +import requests, os, time +from datetime import datetime +from dateutil import tz +from pyorbital.orbital import Orbital + +######################################################################## +########################### PREDICT SETTINGS ########################### +########################### (change these!) ########################### +######################################################################## + +yourLat = 0 # Your latitude +yourLon = 0 # Your longitude +yourAlt = 0 # Your altitude (meters above sea level) +minElevation = 0 # Minimum elevation of the GAC event (can be negative) +utcTime = tz.gettz('UTC') # UTC timezone +localTime = tz.gettz('UTC') # Your local timezone(as abbreviation) + +######################################################################## +######################################################################## + + +# global declarations + +# # https://code.it4i.cz/blender/blender-embree3/-/blob/sculpt25/tools/bcolors.py +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKCYAN = '\033[96m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +url = "https://noaasis.noaa.gov/cemscs/polrschd.txt" # polrschd.txt URL +local = "polrschd.txt" +expire = 260000 + +orbitalNOAA15 = Orbital("NOAA-15") +orbitalNOAA18 = Orbital("NOAA-18") +orbitalNOAA19 = Orbital("NOAA-19") + +def main(): + print(f"{bcolors.OKCYAN}{bcolors.BOLD}Calculating GAC events for following conditions;{bcolors.ENDC}") + print(f"{bcolors.OKCYAN}Receiver latitude: ",yourLat,"˚") + print("Receiver longitude: ",yourLon,"˚") + print("Receiver altitude: ",yourAlt,"m") + print("Min. sat. elevation:", minElevation,f"˚{bcolors.ENDC}") + + if (os.path.isfile(local)): + if (time.time() - os.path.getmtime(local)) > expire: + print("Local file expired, will download") + with open(local, 'wb') as f: + f.write(requests.get(url).content) + else: + print("Using local file") + else: + print("Local file not found, will download") + with open(local, 'wb') as f: + f.write(requests.get(url).content) + + for line in open(local, 'r'): # open txt, read each line + text = line[:-1] # strip newline + date = text[0:17] # get date from line + utc = datetime.strptime(date, '%Y/%j/%H:%M:%S') # parse date from weird format YYYY/DDD/HH:MM:SS + utc = utc.replace(tzinfo=utcTime) # set timezone to UTC + dateParsed = utc.astimezone(localTime) # convert to local time + satID = text[23:25] # get satellite number from line + + # parse satellite number ID into name + if (satID == "01"): + satIDParsed = "MetOp-B" + elif (satID == "02"): + satIDParsed = "MetOp-A" + elif (satID == "03"): + satIDParsed = "MetOp-C" + elif (satID == "15"): + satIDParsed = "NOAA-15" + satellite = orbitalNOAA15 + elif (satID == "18"): + satIDParsed = "NOAA-18" + satellite = orbitalNOAA18 + elif (satID == "19"): + satIDParsed = "NOAA-19" + satellite = orbitalNOAA19 + else: + satIDParsed = satID + + # Determine frequency from transmitter ID + if "LSB" in text: + txFreq = "1698.0 MHz RHCP" + elif "MSB" in text: + txFreq = "1702.5 MHz LHCP" + elif "HSB" in text: + txFreq = "1707.0 MHz RHCP" + elif "ESB" in text: + txFreq = "2247.5 MHz RHCP" + else: + txFreq = "Unknown Frequency" + + # Determine type of event + if "PBK,START,GAC" in text: + eventType = "Start of GAC transmission" + elif "PBK,END,GAC" in text: + eventType = "End of GAC transmission " + else: + eventType = "other" + + if ((eventType == "Start of GAC transmission") | (eventType == "End of GAC transmission ")): + + # Compute observed elevation of satellite during event + elevation = (round(satellite.get_observer_look(dateParsed, yourLon, yourLat, yourAlt/1000)[1])) + elStr = str(elevation)+"°" + + # Set print color + if ((elevation > 5) & (eventType == "Start of GAC transmission")): + printCol = f"{bcolors.BOLD}{bcolors.OKGREEN}" + elif ((elevation >= 0) & (eventType == "Start of GAC transmission")): + printCol = f"{bcolors.OKGREEN}" + elif ((elevation >= 0) & (eventType == "End of GAC transmission ")): + printCol = f"{bcolors.WARNING}" + else: + printCol = f"{bcolors.FAIL}" + + if (elevation >= minElevation): + print(printCol, dateParsed, satIDParsed, eventType, txFreq, elStr, f"{bcolors.ENDC}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/polrschd.py b/polrschd.py deleted file mode 100644 index b173a2d..0000000 --- a/polrschd.py +++ /dev/null @@ -1,122 +0,0 @@ -import urllib.request, os, time -from datetime import datetime -from dateutil import tz -from pyorbital.orbital import Orbital - -######################################################################## -########################### PREDICT SETTINGS ########################### -########################### (change these!) ########################### -######################################################################## - -yourLat = 41.42 # Your latitude -yourLon = -92.22 # Your longitude -yourAlt = 230 # Your altitude (meters above sea level) -minElevation = 0 # Minimum elevation of the GAC event (can be negative) -utcTime = tz.gettz('UTC') # UTC timezone -localTime = tz.gettz('UTC') # Your local timezone(as abbreviation) - -######################################################################## -######################################################################## - -# https://code.it4i.cz/blender/blender-embree3/-/blob/sculpt25/tools/bcolors.py -class bcolors: - HEADER = '\033[95m' - OKBLUE = '\033[94m' - OKCYAN = '\033[96m' - OKGREEN = '\033[92m' - WARNING = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - -polrschdURL = "https://noaasis.noaa.gov/cemscs/polrschd.txt" # polrschd.txt URL -polrschdLocal = "polrschd.txt" -polrschdExpire = 260000 - -print(f"{bcolors.OKCYAN}{bcolors.BOLD}Calculating GAC events for following conditions;{bcolors.ENDC}") -print(f"{bcolors.OKCYAN}Receiver latitude: ",yourLat,"˚") -print("Receiver longitude: ",yourLon,"˚") -print("Receiver altitude: ",yourAlt,"m") -print("Min. sat. elevation:", minElevation,f"˚{bcolors.ENDC}") - -orbitalNOAA15 = Orbital("NOAA-15") -orbitalNOAA18 = Orbital("NOAA-18") -orbitalNOAA19 = Orbital("NOAA-19") - -# Use local file if recent enough (to reduce number of requests) -if (os.path.isfile(polrschdLocal)): - if (time.time() - os.path.getmtime(polrschdLocal)) > polrschdExpire: - print("Local file expired, will download") - urllib.request.urlretrieve(polrschdURL, polrschdLocal) - else: - print("Using local file") -else: - print("Local file not found, will download") - urllib.request.urlretrieve(polrschdURL, polrschdLocal) - -for line in open(polrschdLocal, 'r'): # open txt, read each line - text = line[:-1] # strip newline - date = text[0:17] # get date from line - utc = datetime.strptime(date, '%Y/%j/%H:%M:%S') # parse date from weird format YYYY/DDD/HH:MM:SS - utc = utc.replace(tzinfo=utcTime) # set timezone to UTC - dateParsed = utc.astimezone(localTime) # convert to local time - satID = text[23:25] # get satellite number from line - - # parse satellite number ID into name - if (satID == "01"): - satIDParsed = "MetOp-B" - elif (satID == "02"): - satIDParsed = "MetOp-A" - elif (satID == "03"): - satIDParsed = "MetOp-C" - elif (satID == "15"): - satIDParsed = "NOAA-15" - satellite = orbitalNOAA15 - elif (satID == "18"): - satIDParsed = "NOAA-18" - satellite = orbitalNOAA18 - elif (satID == "19"): - satIDParsed = "NOAA-19" - satellite = orbitalNOAA19 - else: - satIDParsed = satID - - # Determine frequency from transmitter ID - if "LSB" in text: - txFreq = "1698.0 MHz RHCP" - elif "MSB" in text: - txFreq = "1702.5 MHz LHCP" - elif "HSB" in text: - txFreq = "1707.0 MHz RHCP" - elif "ESB" in text: - txFreq = "2247.5 MHz RHCP" - else: - txFreq = "Unknown Frequency" - - # Determine type of event - if "PBK,START,GAC" in text: - eventType = "Start of GAC transmission" - elif "PBK,END,GAC" in text: - eventType = "End of GAC transmission " - else: - eventType = "other" - - if ((eventType == "Start of GAC transmission") | (eventType == "End of GAC transmission ")): - - # Compute observed elevation of satellite during event - elevation = (round(satellite.get_observer_look(dateParsed, yourLon, yourLat, yourAlt/1000)[1])) - elStr = str(elevation)+"°" - - # Set print color - if ((elevation > 5) & (eventType == "Start of GAC transmission")): - printCol = f"{bcolors.BOLD}{bcolors.OKGREEN}" - elif ((elevation >= 0) & (eventType == "Start of GAC transmission")): - printCol = f"{bcolors.OKGREEN}" - elif ((elevation >= 0) & (eventType == "End of GAC transmission ")): - printCol = f"{bcolors.WARNING}" - else: - printCol = f"{bcolors.FAIL}" - - if (elevation >= minElevation): - print(printCol, dateParsed, satIDParsed, eventType, txFreq, elStr, f"{bcolors.ENDC}") diff --git a/requirements.txt b/requirements.txt index f184992..fb18a98 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -pyorbital \ No newline at end of file +pyorbital +requests +certifi \ No newline at end of file