t0 = dt.datetime.now() #----------------------------------------------------------------------------- # INITIALISE CLASS STATES #----------------------------------------------------------------------------- # Generate InShape class SHAPE = InShape(shape_path) # Create shapely polygon from imported shapefile UNIQUE_SHAPE = SHAPE.shape_poly() print type(UNIQUE_SHAPE) # Generate InPoly class INPOLY = InPoly(shape_path) GEODESIC = Geodesic() COORDS = Coordinates() INPOLY = InPoly(shape_path) POLY_NODES = INPOLY.poly_nodes() # decluster the points to desired specifications. coords = COORDS.decluster(inputs=coords, degree_dist=0.5) lonmin, lonmax = np.floor(min(coords[:, 0])), np.ceil(max(coords[:, 0])) latmin, latmax = np.floor(min(coords[:, 1])), np.ceil(max(coords[:, 1])) print lonmin, lonmax, latmin, latmax plt.figure() plt.scatter(coords[:, 0], coords[:, 1]) plt.show()
#cd Desktop/Link\ to\ SIMULATIONS/Network_Tracks/smarter_model/ grad_ideal, grad_check1, grad_check2, H_avg1, H_avg2 = 0, 0, 0, 0, 0 SHAPE = (1,1) perc_high = 0.01 low_counter = 0 random_counter = 0 #new_coord = 0 infinite_counter = 0 find_it = [] check_coord = None use_old_path = False searches_per_point = 3 factor = 0.05 cluster = False COORDS = Coordinates() INPOLY = InPoly(shape_path) while infinite_counter <= 1: t0 = datetime.datetime.now() #---------------------------------------------------------------------- # Generate N new point coordinates #---------------------------------------------------------------------- if cluster: new_coords = N_cluster_points else: new_coords = ps.points_in_shape(shape_path, N) coords = np.append(coords, new_coords, axis=0)
#connect SQL database SQL_db = os.path.join(DATABASE_DIR, 'timeline.db') stations, subdir_len = psstationSQL.get_stationsSQL(SQL_db, xml_inventories=xml_inventories, dataless_inventories=dataless_inventories, startday=FIRSTDAY, endday=LASTDAY, verbose=False) DECLUSTER = False if DECLUSTER: stat_coords = np.asarray([station.coord for station in stations]) COORDS = Coordinates(input_list=stat_coords) declustered_coords = COORDS.decluster(degree_dist=0.1) stations = [station for station in stations if station.coord in declustered_coords] # Loop on time interval #number of time steps N = int(((LASTDAY - FIRSTDAY).days + 1)*60*24 / XCORR_INTERVAL) dates = [FIRSTDAY + dt.timedelta(minutes=i) for i in \ [j*XCORR_INTERVAL for j in range(N)]] #begin = raw_input("\nPress enter to begin the program ")
DENSITY = Density(paths=paths1) 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) DENSITY.plot_field(SHAPE=UNIQUE_SHAPE) quit() COORDS = Coordinates() for i in [0]: t0 = datetime.datetime.now() #---------------------------------------------------------------------- # Generate N new point coordinates #---------------------------------------------------------------------- #new_coords = N_cluster_points # if cluster: # new_coords = N_cluster_points # else: # new_coords = ps.points_in_shape(shape_path, N)
t0 = dt.datetime.now() # ----------------------------------------------------------------------------- # INITIALISE CLASS STATES # ----------------------------------------------------------------------------- # Generate InShape class SHAPE = InShape(shape_path) # Create shapely polygon from imported shapefile UNIQUE_SHAPE = SHAPE.shape_poly() print type(UNIQUE_SHAPE) # Generate InPoly class INPOLY = InPoly(shape_path) GEODESIC = Geodesic() COORDS = Coordinates() INPOLY = InPoly(shape_path) POLY_NODES = INPOLY.poly_nodes() # decluster the points to desired specifications. coords = COORDS.decluster(inputs=coords, degree_dist=0.5) lonmin, lonmax = np.floor(min(coords[:, 0])), np.ceil(max(coords[:, 0])) latmin, latmax = np.floor(min(coords[:, 1])), np.ceil(max(coords[:, 1])) print lonmin, lonmax, latmin, latmax plt.figure() plt.scatter(coords[:, 0], coords[:, 1])
DENSITY = Density(paths=paths1) 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) DENSITY.plot_field(SHAPE=UNIQUE_SHAPE) quit() COORDS = Coordinates() for i in [0]: t0 = datetime.datetime.now() #---------------------------------------------------------------------- # Generate N new point coordinates #---------------------------------------------------------------------- #new_coords = N_cluster_points # if cluster: # new_coords = N_cluster_points # else: # new_coords = ps.points_in_shape(shape_path, N) #coords = np.append(coords, new_coords, axis=0)