import geopandas as gpd import scipy as sp import matplotlib.pyplot as plt sys.path.append(os.environ['LAV_DIR'] + '/src/') baseDir = os.environ['LAV_DIR'] import geomadi.lib_graph as gra import geomadi.geo_octree as g_o import geomadi.train_viz as t_v import shapely as sh from shapely.geometry.polygon import Polygon metric = "speed" if (len(sys.argv) > 1): metric = sys.argv[1] projDir = baseDir + "raw/gps/" + metric + "/" dL = os.listdir(projDir) gO = g_o.octree(BoundBox=[5.866, 47.2704, 15.0377, 55.0574]) for d in dL: print(d) den = pd.read_csv(projDir + d) if 'dens' not in locals(): dens = den else: dens = dens.merge(den, on="octree", how="outer") dens = dens.replace(float('nan'), 0.) tLx = [x for x in dens.columns if bool(re.search("_x", x))] tLy = [x for x in dens.columns if bool(re.search("_y", x))] dens.loc[:, tLx] = dens[tLx].values + dens[tLy].values for i in tLy: del dens[i] dens.columns = ['octree'] + [x.split("_")[0] for x in tLx]
norm = 1. / (df['n'].values) df.loc[:, tLx] = np.multiply(tX + tY, norm[:, np.newaxis]) for i in tLy + ['n_x', 'n_y']: del df[i] for i in tLx: df.rename(columns={i: i.split("_")[0]}, inplace=True) return df if False: #library testing print("x | y | dx | dy") import geomadi.geo_octree as g_o import importlib importlib.reload(g_o) gO = g_o.octree(BoundBox=[5.866, 47.2704, 15.0377, 55.0574], padding=0.1) g2 = gO.encode(14.989551, 48.218262, 10) print(gO.decode(gO.encode(14.989551, 48.218262, 10))) print("de center %s" % (gO.encode(10.28826401, 51.13341344, 15))) if False: #choose algebra base l = np.array([1, 2, 4, 8]) comb = [i - j for i in l for j in l] base, count = np.unique(comb, return_counts=True) print(base, count) print(len(count) / sum(count)) print(sum(l)) plt.bar(range(len(comb)), sorted(comb)) plt.show() l2 = [-1, 0, 1]