def main(): """Main function... makes 'forward declarations' of helper functions unnecessary""" # Constants groundstation_name = 'Wallops Antenna' groundstation_address = 'Radar Road, Temperanceville, VA 23442' satnum = 25544 # ISS = 25544 saturl="http://www.celestrak.com/NORAD/elements/stations.txt" gs_minimum_elevation_angle = 10.0 # Alternate constants gs_alt_lat = 37.854886 # Only needed if address not found gs_alt_lon = -75.512936 # Ditto gs_alt_el_meters = 3.8 # Ditto gs_alt_tz_offset_seconds = -18000.0 # Ditto gs_tzname = 'US/Eastern' # Construct the ground station info try: # Try to use the address... gs = GroundStation.from_address(groundstation_address, \ groundstation_name, \ gs_minimum_elevation_angle) except: # Otherwise, use explicit location data... gs = GroundStation.from_location(gs_alt_lat, gs_alt_lon, \ gs_alt_el_meters, \ gs_tzname, \ groundstation_name, \ gs_minimum_elevation_angle) # Times we need now = datetime.now() gs_today = gs.get_tz().localize(datetime(now.year, now.month, now.day)) gs_today_start = gs.get_tz().localize(datetime(now.year, now.month, now.day, \ 0, 0, 0)) gs_today_end = gs.get_tz().localize(datetime(now.year, now.month, now.day, \ 23, 59, 59)) # Get the InviewCalculator and compute the inviews st = SatelliteTle(satnum, tle_url=saturl) ic = InviewCalculator(gs, st) inviews = ic.compute_inviews(gs_today_start, gs_today_end) # Print the results print_satellite_header(st) print_inview_header(gs.get_minimum_elevation_angle(), gs_today, gs) print_inviews(gs, inviews) print_azeltables(inviews, ic)
def init_groundstation(): # Ground station stuff gs_lat = 39.50417 gs_lon = -80.218615 gs_el_meters = 359.664 gs_tzname = 'US/Eastern' groundstation_name = 'Fairmont' gs_minimum_elevation_angle = 10.0 gs_observer = Observer() gs_observer.lat = gs_lat * math.pi / 180.0 gs_observer.lon = gs_lon * math.pi / 180.0 gs_observer.elevation = gs_el_meters # Times we need now = datetime.now() tomorrow = now + timedelta(1) gs_observer.date = now #now += timedelta(hours=14) # testing #tomorrow = now + timedelta(hours=4) # testing gs_tz = timezone(gs_tzname) gs_start = gs_tz.localize(now) gs_end = gs_tz.localize(tomorrow) #print(gs_start) #print(gs_end) gs = GroundStation.from_location(gs_lat, gs_lon, \ gs_el_meters, \ gs_tzname, \ groundstation_name, \ gs_minimum_elevation_angle) return [gs, gs_observer, gs_tz, gs_start, gs_end]
def create_az_el_range_report(base_output_dir, tz, start_day, end_day, data): ground_station = GroundStation.from_config(data.get('ground_station', [])) sat_of_interest = SatelliteTle.from_config(data.get('satellite', [])) # sys.stderr.write(sat_of_interest.__repr__() + "\n") # debug time_step_seconds = Configuration.get_config_float( data.get('time_step_seconds', '15'), 1, 600, 15) aerg = AzElRangeReportGenerator(base_output_dir, ground_station, 0, sat_of_interest, tz, start_day, end_day, time_step_seconds) aerg.generate_report()
def create_satellite_overflight_report(base_output_dir, tz, data): sat_tle = SatelliteTle.from_config(data.get('satellite', [])) ground_station = GroundStation.from_config(data.get('ground_station', [])) common_sat_name = data.get('common_satellite_name', sat_tle.get_satellite_name()) common_gs_name = data.get('common_ground_station_name', ground_station.get_name()) sorg = SatelliteOverflightReportGenerator(base_output_dir, sat_tle, ground_station, tz, common_sat_name, common_gs_name) sorg.generate_report()
def create_angular_separation_report(base_output_dir, tz, start_day, end_day, data): ground_station = GroundStation.from_config(data.get('ground_station', [])) sat_of_interest = SatelliteTle.from_config( data.get('satellite_of_interest', [])) other_sats = [] other_sats_data = data.get('other_satellites', []) for sat in other_sats_data: other_sats.append(SatelliteTle.from_config(sat)) asrg = AngularSeparationReportGenerator(base_output_dir, ground_station, sat_of_interest, other_sats, tz, start_day, end_day) asrg.generate_report()
def create_satellite_html_report(base_output_dir, tz, inviews, contacts, insun, start_day, end_day, time_step_seconds, data): sat_tle = SatelliteTle.from_config(data.get('satellite', [])) ground_station_list = [] gs_list = data.get('ground_stations', []) for gs in gs_list: ground_station_list.append(GroundStation.from_config(gs)) aer_days = Configuration.get_config_int(data.get('num_aer_days', '0'), 0, 10, 0) shrg = SatelliteHtmlReportGenerator(base_output_dir, sat_tle, ground_station_list, tz, inviews, contacts, insun, aer_days, \ start_day, end_day, time_step_seconds) shrg.generate_report()
def create_ground_station_html_report(base_output_dir, tz, inviews, start_day, end_day, data): ground_station = GroundStation.from_config(data.get('ground_station', [])) sat_list = [] sat_data_list = data.get('satellites', []) for sat in sat_data_list: sat_list.append(SatelliteTle.from_config(sat)) aer_days = Configuration.get_config_int(data.get('num_aer_days', '0'), 0, 10, 0) gshrg = GroundStationHtmlReportGenerator(base_output_dir, ground_station, sat_list, tz, inviews, aer_days, start_day, end_day) gshrg.generate_report()
def main(): """Main function... makes 'forward declarations' of helper functions unnecessary""" conf_file = "config/sat_html_report.config" if (len(sys.argv) > 1): conf_file = sys.argv[1] #sys.stderr.write("conf_file: %s\n" % conf_file) with open(conf_file) as json_data_file: data = json.load(json_data_file) #base_output_dir = Configuration.get_config_directory(data.get('base_output_directory',tempfile.gettempdir())) tz = Configuration.get_config_timezone(data.get('timezone', 'US/Eastern')) inviews = Configuration.get_config_boolean(data.get('inviews', 'false')) contacts = Configuration.get_config_boolean(data.get('contacts', 'false')) insun = Configuration.get_config_boolean(data.get('insun', 'false')) start_day = Configuration.get_config_int(data.get('start_day', '0'), -180, 180, 0) end_day = Configuration.get_config_int(data.get('end_day', '0'), -180, 180, 0) time_step_seconds = Configuration.get_config_float( data.get('time_step_seconds', '15'), 1, 600, 15) sat_tle = SatelliteTle.from_config(data.get('satellite', [])) ground_station = GroundStation.from_config(data.get('ground_station', [])) # Determine the time range for the requested day day_date = datetime.now() + timedelta(days=start_day) day_year = day_date.year day_month = day_date.month day_day = day_date.day start_time = tz.localize(datetime(day_year, day_month, day_day, 0, 0, 0)) end_time = tz.localize(datetime(day_year, day_month, day_day, 23, 59, 59)) # Get the InviewCalculator and compute the inviews base_ic = InviewCalculator(ground_station, sat_tle) base_inviews = [] base_inviews = base_ic.compute_inviews(start_time, end_time) for iv in base_inviews: print(iv) # debug start_time = iv[0].astimezone(tz) end_time = iv[1].astimezone(tz) azels = base_ic.compute_azels(iv[0], iv[1], time_step_seconds) for azel in azels: #print(" %s, %7.2f, %6.2f, %7.1f\n" % (azel[0].astimezone(tz), azel[1], azel[2], azel[3])) # convert to specified time zone print(" %s, %7.2f, %6.2f, %7.1f" % (azel[0].astimezone(tz), azel[1], azel[2], azel[3])) # convert to specified time zone
def create_azel_cmd_telemetry_report(tz, tlmfile, cmdfile, pngfile, data): satnum = data.get('satellite', [])['number'] ground_station = GroundStation.from_config(data.get('ground_station', [])) tle = SatelliteTle.from_config(data.get('satellite', [])) show_track = Configuration.get_config_boolean( data.get('show_track', 'false')) aer = AzElRangeReportGenerator("", ground_station, 1, tle, tz, 0, time_step_seconds=15) (fig, ax) = aer.create_polar_fig_and_ax() aer.generate_azelrange_plot_groundconstraints(ax) satdata = {} tlmdata = {} if (tlmfile is not None): process_telem_file(tlmfile, tz, satnum, ground_station, data, satdata, tlmdata) hidata = {} lowdata = {} cleardata = {} nre = {} if (cmdfile is not None): hidata = process_cmd_file(cmdfile, tz, satnum, ground_station, data, satdata, re.compile("CADET_FIFO_REQUEST.*FLAGS [1H]"), True) lowdata = process_cmd_file( cmdfile, tz, satnum, ground_station, data, satdata, re.compile("CADET_FIFO_REQUEST.*FLAGS [^1H]"), True) cleardata = process_cmd_file(cmdfile, tz, satnum, ground_station, data, satdata, re.compile("CADET_FIFO_CLEAR"), True) nre = process_cmd_file(cmdfile, tz, satnum, ground_station, data, satdata, re.compile("CADET_FIFO"), False) if (show_track): for j in satdata.keys(): d = satdata[j] for i in range(len(d.plotinviews)): if (d.plotinviews[i]): icazels = d.inview_computer.compute_azels( d.inviews[i][0], d.inviews[i][1], 15) aer.generate_azelrange_plot_track( ax, "%s %s" % (tle.get_satellite_name(), j), icazels, 4) # Hardwire every 4 for i in tlmdata.keys(): aer.generate_azelrange_plot_points(ax, "Telemetry", "#00FF00", tlmdata[i]) for i in cleardata.keys(): aer.generate_azelrange_plot_points(ax, "Clear Data Cmd", "#FF0000", cleardata[i]) for i in hidata.keys(): aer.generate_azelrange_plot_points(ax, "High Data Request", "#0000FF", hidata[i]) for i in lowdata.keys(): aer.generate_azelrange_plot_points(ax, "Low Data Request", "#9900FF", lowdata[i]) for i in nre.keys(): aer.generate_azelrange_plot_points(ax, "NRE Cmd", "#FF6600", nre[i]) ax.legend(loc=1, bbox_to_anchor=(1.12, 1.12)) plt.figure(1) plt.savefig(pngfile)
def main(): ground_station = GroundStation() ground_station.main()
def main(): """Main function... makes 'forward declarations' of helper functions unnecessary""" parser = argparse.ArgumentParser() parser.add_argument("-s", "--satnum", help="Specify satellite number (e.g. 25544=ISS, 43852=STF-1)", \ type=int, metavar="[1-99999]", choices=range(1,99999), default=43852) parser.add_argument("-t", "--time", help="Specify date/time (UTC)", type=ArgValidator.validate_datetime, metavar="YYYY-MM-DDTHH:MM:SS", default=datetime.now()) parser.add_argument("-r", "--endtime", help="Specify date time range with this end date/time (UTC)", \ type=ArgValidator.validate_datetime, metavar="YYYY-MM-DDTHH:MM:SS", default=None) parser.add_argument("-d", "--timestep", help="Specify time step (delta) in seconds for tabular data", \ type=int, metavar="[1-86400]", choices=range(1,86400), default=60) parser.add_argument("-p", "--tle", help="Print TLE information", action="store_true") parser.add_argument("-u", "--sun", help="Print sun/umbra/penumbra information", action="store_true") parser.add_argument("-e", "--ecef", help="Print ECEF ephemeris", action="store_true") parser.add_argument("-i", "--eci", help="Print ECI ephemeris", action="store_true") parser.add_argument( "-l", "--lla", help= "Print latitude, longitude, altitude (geodetic degrees, altitude in km above WGS-84 ellipsoid) ephemeris", action="store_true") parser.add_argument( "-f", "--file", help="TLE file to use (instead of looking up the TLE on CelesTrak)", type=ArgValidator.validate_file, default=None) parser.add_argument("-m", "--mag", help="Print geomagnetic data", action="store_true") parser.add_argument("-a", "--aer", help="Print az/el/range from ground station", action="store_true") parser.add_argument("-x", "--longitude", help="Specify longitude (degrees) of ground station", \ type=float, default=-79.825518056) parser.add_argument("-y", "--latitude", help="Specify latitude (degrees) of ground station", \ type=float, default=38.43685028) parser.add_argument("-z", "--elevation", help="Specify elevation (meters) of ground station", \ type=float, default=842.0) parser.add_argument("-v", "--iirv", help="Print improved interrange vector (IIRV) format", action="store_true") args = parser.parse_args() if (args.file is not None): st = SatelliteTle(args.satnum, tle_file=args.file) else: saturl = "http://www.celestrak.com/cgi-bin/TLE.pl?CATNR=%s" % args.satnum st = SatelliteTle(args.satnum, tle_url=saturl) if (args.tle): print_tle_data(st) if (args.eci): if (args.endtime is None): point = st.compute_ephemeris_point(args.time) print_ephemeris_point(st, point) else: table = st.compute_ephemeris_table(args.time, args.endtime, args.timestep) print_ephemeris_table(st, table) if (args.ecef): #print "ECEF is not implemented" if (args.endtime is None): point = st.compute_ephemeris_point(args.time) print_ephemeris_point(st, point, False) else: table = st.compute_ephemeris_table(args.time, args.endtime, args.timestep) print_ephemeris_table(st, table, False) if (args.lla): if (args.endtime is None): llap = st.compute_lonlatalt_point(args.time) print_lonlatalt(st, llap) else: table = st.compute_lonlatalt_table(args.time, args.endtime, args.timestep) print_lonlatalt_table(st, table) if (args.mag): if (args.endtime is None): llap = st.compute_lonlatalt_point(args.time) print_mag(st, llap) else: table = st.compute_lonlatalt_table(args.time, args.endtime, args.timestep) print_mag_table(st, table) if (args.aer): gs = GroundStation(lat=args.latitude, lon=args.longitude, el_meters=args.elevation) ic = InviewCalculator(gs, st) if (args.endtime is None): args.endtime = args.time azels = ic.compute_azels(args.time, args.endtime, args.timestep) print_azelrange_table(azels) if (args.sun): if (args.endtime is None): sun_state = st.get_satellite_sun_state(args.time) if (sun_state == st.InSun): in_sun = "in sun" elif (sun_state == st.InPenumbra): in_sun = "in penumbra" else: in_sun = "in umbra" print("===== SUN =====") print("Satellite is %s" % in_sun) else: tables = st.compute_sun_times(args.time, args.endtime) print_sun_times_table(st, args.time, args.endtime, tables) if (args.iirv): if (args.endtime is None): point = st.compute_ephemeris_point(args.time) print_iirv_point(st, point) else: table = st.compute_ephemeris_table(args.time, args.endtime, args.timestep) print_iirv_points(st, table)
def create_inview_list_report(base_output_dir, tz, start_day, end_day, data): sat_tle = SatelliteTle.from_config(data.get('satellite', [])) ground_station = GroundStation.from_config(data.get('ground_station', [])) ilrg = InviewListReportGenerator(base_output_dir, sat_tle, ground_station, tz, start_day, end_day) ilrg.generate_report()