Beispiel #1
0
def display_great_circle( a_latitude, a_longitude, b_latitude, b_longitude, units, unit_r):

    dist = distance.great_circle_distance(  a_latitude, a_longitude, b_latitude, b_longitude, unit_r )
    bearing = distance.great_circle_bearing( a_latitude, a_longitude, b_latitude, b_longitude )
    print( )
    print( "        Path between A  .....................................   {0}" .format( lat_lon_str(a_latitude, a_longitude) ) )
    print( "        Solar zone UTC{0}".format( int(a_longitude/15) ) )
    print( "                 and B  .....................................   {0}" .format( lat_lon_str(b_latitude, b_longitude) ) )
    print( "        Solar zone UTC{0}".format( int(b_longitude/15) ) )
    print( "        Great Circle distance ( {1:14s} ).... {0:6.1f}".format(dist, units.__doc__) )
    diff = int(b_longitude/15) - int(a_longitude/15)
    h, m = divmod( diff*60, 60 )
    print( "        Solar Time difference (hr:min)..........      {0:02d}:{1:02d}".format(h,m) )
    print( "                     Bearing from A .........................    {0:6.2f}°" .format(bearing))
    print( "                     Bearing from B .........................    {0:6.2f}°" .format(180-bearing))
    print( )
    print( " To A                         INTERMEDIATE  PLOTS                        To B")
    print( "   └─«{0:^11s}«─ Bearing«─ ┌── From Plot ──┐ ─»Bearing ─»{0:^11s}»─┘".format(units.__doc__) )
    total= 0
    r= dist/10
    for s in range(11):
        theta= distance.great_circle_bearing( a_latitude, a_longitude, b_latitude, b_longitude )
        pt= distance.great_circle_destination( a_latitude, a_longitude, r, theta, unit_r )
        print( "{0:9d}   {1:6.1f} {2:5.1f}°  «─  {3:^16s} ─» {4:5.1f}°   {5:6.1f}".format(s, total, bearing, lat_lon_str(*pt), (180+bearing)%180, dist-total ) )
        a_latitude, a_longitude = pt
        total += r
Beispiel #2
0
def grid_square():
    today = datetime.datetime.now(tz=solar.utc)

    home= None
    while home is None:
        mode= input( "Home QTH (c)oordinates, (g)rid, or (q)uit?     (c/g/q) " ).lower()
        if mode == 'q':
            return
        elif mode == 'c':
            lat= input_float( "ENTER: Latitude in decimal degrees (+° if North, -° if South)? " )
            lon= input_float( "ENTER: Longitude in decimal degrees (+° if East, -° if West)? " )
            if lat is None or lon is None: return
            grid= gridsq.latlon_2_grid( lat, lon )
            home= grid
            lat_home, lon_home= lat, lon
        elif mode == 'g':
            grid_raw= input( "ENTER: Grid square code (enter 2, 4, or all 6 characters)? " )
            lat, lon = gridsq.grid_2_latlon( grid_raw )
            home= grid_raw
            lat_home, lon_home= lat, lon

    rise, _, set = solar.rise_transit_set( lat, lon, today )
    print( "Home", home, gridsq.grid_2_latlon(home), rise, set )

    R= None
    while R is None:
        dist_choice= input( "Choose: DX in (k)ilometers, (s)tatute miles or (n)autical miles?   (k/s/n) " ).lower()
        if dist_choice == 'k':
            R = distance.KM
        elif dist_choice == 's':
            R = distance.SM
        elif dist_choice == 'n':
            R = distance.NM

    count= 0
    while True:
        mode= input( "Away QTH (c)oordinates, (g)rid, or (q)uit?     (c/g/q) " ).lower()
        if mode == 'q':
            break
        elif mode == 'c':
            lat= input_float( "ENTER: Latitude in decimal degrees (+° if North, -° if South)? " )
            lon= input_float( "ENTER: Longitude in decimal degrees (+° if East, -° if West)? " )
            if lat is None or lon is None: return
            grid= gridsq.latlon_2_grid( lat, lon )
        elif mode == 'g':
            grid= input( "ENTER: Grid square code (enter 2, 4, or all 6 characters)? " )
            lat, lon = gridsq.grid_2_latlon( grid )
        count += 1

        dx_range = distance.great_circle_distance( lat_home, lon_home, lat, lon, R )
        rx_bearing = distance.great_circle_bearing( lat_home, lon_home, lat, lon )

        rise, _, set = solar.rise_transit_set( lat, lon, today )
        print( count, grid, lat, lon, dx_range, rx_bearing, rise, set )