def determine_satellite_visibility(sat, gs, gs_tz, gs_start, gs_end, night): satnum = sat[0] saturl = "http://www.celestrak.com/cgi-bin/TLE.pl?CATNR=%s" % satnum st = SatelliteTle(satnum, tle_url=saturl) [suntimes, pentimes, umtimes] = st.compute_sun_times(gs_start, gs_end) ic = InviewCalculator(gs, st) inviews = ic.compute_inviews(gs_start, gs_end) intersections = [] for inview in inviews: i1 = intersect_times(night, inview) if (i1 is not None): #print_span(gs_tz, i1) for suntime in suntimes: i2 = intersect_times(i1, suntime) if (i2 is not None): #print_span(gs_tz, i2) i2startmjd = Time(i2[0]).mjd href = "http://www.heavens-above.com/passdetails.aspx?lat=%f&lng=%f&loc=%s&alt=%f&tz=%s&satid=%d&mjd=%f" % \ (gs.get_latitude(), gs.get_longitude(), gs.get_name(), gs.get_elevation_in_meters(), gs.get_tz().localize(datetime(i2[0].year, i2[0].month, i2[0].day)).tzname(), satnum, i2startmjd) intersections.append([ "<a href=%s>%s (mag:%s) %s %s-%s%s</a>" % (href, satnum, sat[1], st.get_satellite_name(), st.get_launch_year(), st.get_launch_year_number(), st.get_launch_piece()), i2 ]) #print_debug_times(gs_tz, satnum, night, suntimes, inviews) return intersections
def main(): """Main function... makes 'forward declarations' of helper functions unnecessary""" # Constants satnum = 25544 # ISS = 25544 saturl="http://www.celestrak.com/NORAD/elements/stations.txt" our_tzname = 'US/Eastern' # Times we need now = datetime.now() our_tz = timezone(our_tzname) our_today_start = our_tz.localize(datetime(now.year, now.month, now.day, \ 0, 0, 0)) our_today_end = our_tz.localize(datetime(now.year, now.month, now.day, \ 23, 59, 59)) st = SatelliteTle(satnum, tle_url=saturl) tables = st.compute_sun_times(our_today_start, our_today_end) print_sun_times_table(st, our_today_start, our_today_end, tables)
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)