Esempio n. 1
0
def plot_SF(
    sfa_flow, sensor_dirs, x_width, y_width, sensor_info="", N_sensors=4, orthogonal=False, grid_resolution=10.0
):

    g_w, len_x, len_y = bat.grid_walk(x_width, y_width)
    inscts, grid_sense, sens_dirs = bat.sense_the_walls(
        g_w, x_width=x_width, y_width=y_width, sensor_dirs=sensor_dirs, orthogonal=orthogonal
    )
    sf_grid = bat.back_to_grid(sfa_flow(grid_sense), len_x, len_y)

    n_sf = min(np.shape(sf_grid)[2], 8)

    # if num_features > 8:
    #    n_sf = 8
    #    features_vis = np.hstack((np.arange(0,3),np.arange(3,num_features, \
    #                                      int(round(num_features-3)/4.))))[:8]
    # else:
    features_vis = np.arange(n_sf)

    plt.figure()
    plt.suptitle("Slow Features" + sensor_info)
    for sf in range(n_sf):

        sf_vis = features_vis[sf]

        x_ticks_loc = np.linspace(0, grid_resolution * x_width, x_width + 1)
        y_ticks_loc = np.linspace(0, grid_resolution * y_width, y_width + 1)

        plt.subplot(2, int(n_sf / 2.0), sf + 1)
        plt.title("feature %i" % (sf_vis + 1))
        # plt.plot([0,x_width,x_width,0,0],[0,0,y_width,y_width,0],'k')
        plt.imshow(sf_grid[:, :, sf_vis].T, origin="lower")
        # plt.scatter(random_walk[:,0],random_walk[:,1],c = sfa_data[:,sf])
        plt.xticks(x_ticks_loc, np.arange(0, x_width + 1))
        plt.yticks(y_ticks_loc, np.arange(0, y_width + 1))
        plt.xlabel("x position")
        plt.ylabel("y position")
    plt.show()
Esempio n. 2
0
def plot_SF(sfa_flow, sensor_dirs, x_width, y_width, sensor_info = '', \
                     N_sensors = 4, orthogonal = False, grid_resolution = 10.):

    g_w, len_x, len_y = bat.grid_walk(x_width, y_width)
    inscts, grid_sense, sens_dirs = bat.sense_the_walls(g_w,x_width = x_width,\
                y_width = y_width, sensor_dirs = sensor_dirs, orthogonal = orthogonal)
    sf_grid = bat.back_to_grid(sfa_flow(grid_sense), len_x, len_y)

    n_sf = min(np.shape(sf_grid)[2], 8)

    #if num_features > 8:
    #    n_sf = 8
    #    features_vis = np.hstack((np.arange(0,3),np.arange(3,num_features, \
    #                                      int(round(num_features-3)/4.))))[:8]
    #else:
    features_vis = np.arange(n_sf)

    plt.figure()
    plt.suptitle('Slow Features' + sensor_info)
    for sf in range(n_sf):

        sf_vis = features_vis[sf]

        x_ticks_loc = np.linspace(0, grid_resolution * x_width, x_width + 1)
        y_ticks_loc = np.linspace(0, grid_resolution * y_width, y_width + 1)

        plt.subplot(2, int(n_sf / 2.), sf + 1)
        plt.title('feature %i' % (sf_vis + 1))
        #plt.plot([0,x_width,x_width,0,0],[0,0,y_width,y_width,0],'k')
        plt.imshow(sf_grid[:, :, sf_vis].T, origin='lower')
        #plt.scatter(random_walk[:,0],random_walk[:,1],c = sfa_data[:,sf])
        plt.xticks(x_ticks_loc, np.arange(0, x_width + 1))
        plt.yticks(y_ticks_loc, np.arange(0, y_width + 1))
        plt.xlabel('x position')
        plt.ylabel('y position')
    plt.show()
Esempio n. 3
0
x_width = 3
y_width = 5
r_w = bat.random_walk(x_width,y_width, 500)
sfap.plot_random_walk(r_w,x_width,y_width,', Trajectory',trajectory = True,\
                                                            color_code = True)


### 3. orthogonal sensors

# a) rectangular room
x_width = 3
y_width = 5
r_w = bat.random_walk(x_width,y_width, len_walk = 10000)

intersects, sensory_data, sensor_dirs = bat.sense_the_walls(r_w, x_width = x_width,\
                                               y_width = y_width, orthogonal = True)                                                                                    
sfa_flow = analysis.sfa(sensory_data,x_width,y_width, N_sensors = 2,\
                                        orthogonal = True, poly_degree = 1)
sfap.plot_SF(sfa_flow, sensor_dirs, x_width, y_width, N_sensors = 2, orthogonal = True,\
                        sensor_info = ', orthogonal sensors, rectangular room')

# b) quadratic room

x_width = 5
y_width = 5
r_w = bat.random_walk(x_width,y_width, len_walk = 10000)

intersects, sensory_data, sensor_dirs = bat.sense_the_walls(r_w, x_width = x_width,\
                                               y_width = y_width, orthogonal = True)                                                                                    
sfa_flow = analysis.sfa(sensory_data,x_width,y_width, N_sensors = 2,\
                                        orthogonal = True, poly_degree = 1)
Esempio n. 4
0
# plot trajectory

x_width = 3
y_width = 5
r_w = bat.random_walk(x_width, y_width, 500)
sfap.plot_random_walk(r_w,x_width,y_width,', Trajectory',trajectory = True,\
                                                            color_code = True)

### 3. orthogonal sensors

# a) rectangular room
x_width = 3
y_width = 5
r_w = bat.random_walk(x_width, y_width, len_walk=10000)

intersects, sensory_data, sensor_dirs = bat.sense_the_walls(r_w, x_width = x_width,\
                                               y_width = y_width, orthogonal = True)
sfa_flow = analysis.sfa(sensory_data,x_width,y_width, N_sensors = 2,\
                                        orthogonal = True, poly_degree = 1)
sfap.plot_SF(sfa_flow, sensor_dirs, x_width, y_width, N_sensors = 2, orthogonal = True,\
                        sensor_info = ', orthogonal sensors, rectangular room')

# b) quadratic room

x_width = 5
y_width = 5
r_w = bat.random_walk(x_width, y_width, len_walk=10000)

intersects, sensory_data, sensor_dirs = bat.sense_the_walls(r_w, x_width = x_width,\
                                               y_width = y_width, orthogonal = True)
sfa_flow = analysis.sfa(sensory_data,x_width,y_width, N_sensors = 2,\
                                        orthogonal = True, poly_degree = 1)