コード例 #1
0
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_now = our_tz.localize(datetime(now.year, now.month, now.day, \
                                       now.hour, now.minute, now.second))

    st = SatelliteTle(satnum, tle_url=saturl)
    print_tle_data(st)

    point = st.compute_ephemeris_point(our_now)
    print_ephemeris_point_now(st, point)

    llap = st.compute_lonlatalt_point(our_now)
    print_lonlatalt_now(st, llap)

    sun_state = st.get_satellite_sun_state(our_now)
    if (sun_state == st.InSun):
        in_sun = "in sun"
    elif (sun_state == st.InPenumbra):
        in_sun = "in penumbra"
    else:
        in_sun = "in umbra"

    print "Satellite is %s" % in_sun
コード例 #2
0
def main():
    """Main function... makes 'forward declarations' of helper functions unnecessary"""
    # Constants
    satnum = "06251"  # Delta 1 Deb

    # Times we need
    start = datetime(2006, 06, 25, 19, 46, 43, 980096)
    end = datetime(2006, 06, 26, 19, 46, 43, 980096)

    st = SatelliteTle(satnum, tle_file="../config/sgp4-ver.tle")
    table = st.compute_ephemeris_table(start, end, 7200)
    print_ephemeris_table(st, table)
コード例 #3
0
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()
コード例 #4
0
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
コード例 #5
0
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)
    table = st.compute_lonlatalt_table(our_today_start, our_today_end, 60)
    print_lonlatalt_table(st, table)
コード例 #6
0
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()
コード例 #7
0
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()
コード例 #8
0
def add_sat_data(satdata, tle_dir, date, year, month, day, tzone, satnum, gs):
    #print("adding sat on %s" % date)
    if (date not in satdata):
        elfile = glob.glob(tle_dir + "%s-%s-%s/*.tle" % (year, month, day))
        tle = SatelliteTle(satnum, tle_file=elfile[0])
        orb = Orbital(str(tle.get_satellite_number()),
                      line1=tle.get_line1(),
                      line2=tle.get_line2())
        ic = InviewCalculator(gs, tle)
        inviews = ic.compute_inviews(tzone.localize(datetime(int(year), int(month), int(day), 0, 0, 0)), \
     tzone.localize(datetime(int(year), int(month), int(day), 23, 59, 59)))
        plotinviews = []
        for i in range(len(inviews)):
            plotinviews.append(False)
        p = SatData()
        p.inviews = inviews
        p.plotinviews = plotinviews
        p.inview_computer = ic
        p.orb = orb
        satdata[date] = p
    else:
        p = satdata[date]

    return (p.inviews, p.plotinviews, p.orb)
コード例 #9
0
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)
コード例 #10
0
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()
コード例 #11
0
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()
コード例 #12
0
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
コード例 #13
0
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)
コード例 #14
0
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)
コード例 #15
0
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()