예제 #1
0
    #GRAD = np.ma.masked_where(GRAD==0,GRAD)

    H_avg1 = np.average(H)
    grad_check1 = np.std(GRAD)

    #-------------------------------------------------------------------------
    # Find coordinates of high density within path density field.
    #-------------------------------------------------------------------------
    
    search = np.where(H > 0.50 * np.max(H))
    # Scale these points with respect to the lat-lon limits!
    Hmaxx, Hmaxy =  search[1], search[0]    
    Hmaxx = (lonmax-lonmin)/(nbins) * Hmaxx + lonmin
    Hmaxy = (latmax-latmin)/(nbins) * Hmaxy + latmin
    # Make sure all low density coordinates ARE within shapefile!
    highest_density_coords = ps.paths_in_shape(np.column_stack((Hmaxx, Hmaxy)))
    
    WHERE = np.where(H < perc_high*H_avg1)
    if 0 < rand_indicator <= 3: 
    #half the time move the coordinates to low density locations.

        #scale these points with respect to the lat-lon limits!
    
        Hminx, Hminy =  WHERE[1], WHERE[0]    
        Hminx = (lonmax-lonmin)/(nbins) * Hminx + lonmin
        Hminy = (latmax-latmin)/(nbins) * Hminy + latmin

        # Make sure all low density coordinates ARE within shapefile!
        low_density_coords = ps.paths_in_shape(np.column_stack((Hminx, Hminy)))
        
        # Low_density_coords = many_points(shape, np.column_stack((Hminx, Hminy)))
예제 #2
0
    H, xedges, yedges = DENSITY.hist2d(paths=paths1)
    grad = DENSITY.hgrad(H=H)

    H_avg1 = np.average(H)
    grad_check1 = np.std(grad)

    H_masked = DENSITY.transform_h(H=H)
    grad = DENSITY.transform_grad(grad=grad)

    search = np.where(H < 0.1 * np.average(H))
    Hmaxx, Hmaxy = search[1], search[0]
    Hmaxx = (lonmax - lonmin) / (nbins) * Hmaxx + lonmin
    Hmaxy = (latmax - latmin) / (nbins) * Hmaxy + latmin
    # Make sure all low density coordinates ARE within shapefile!
    low_density_coords = ps.paths_in_shape(np.column_stack((Hmaxx, Hmaxy)))

    #N_cluster_points = kmeans(low_density_coords, N)[0]

    density_coords = DENSITY.select_points()
    # make sure that your density coords are within the boundary shape
    density_coords = INPOLY.points_in(density_coords)
    #cluster = True

    if counter == 0:
        grad_ideal = 1e6
        avg_ideal = 0

    if grad_check1 < grad_ideal and avg_ideal < H_avg1:

        with open(u'ideal_coordinates.pickle', 'wb') as f: