def wpr(params, partitions): return gsgp.mine_patterns(partitions, *params)[0]
print(f'Loading Partition #{i+1}') con = psycopg2.connect(database=db_name, user=uname, password=pw, host=host, port = port) # traj = gpd.GeoDataFrame.from_postgis(traj_sql, con) traj = pd.read_sql_query(traj_sql,con=con) # ports = gpd.GeoDataFrame.from_postgis(ports_sql, con, geom_col='geom' ) # ports.geom = ports.geom.apply(lambda x: x[0]) con.close() print(f'Starting Partition #{i+1} ---- {traj.datetime.max()}, {traj.datetime.min()}') mined_patterns, start, last_ts = gsgp.mine_patterns(df = traj, mode = gp_type, min_diameter=distance, min_cardinality=cardinality, time_threshold=dt, checkpoints=False, checkpoints_freq=0.1, total=total, start=start, last_ts=last_ts, mined_patterns=mined_patterns) print('Saving Result...') mined_patterns.to_csv(save_name, index=False) else: dt_sql = 'SELECT datetime FROM ais_data.dynamic_ships_segmented_12h_resampled_1min ' con = psycopg2.connect(database=db_name, user=uname, password=pw, host=host, port = port) print('loading data') # traj = gpd.GeoDataFrame.from_postgis(traj_sql, con) datet = pd.read_sql_query(dt_sql,con=con) total = datet.datetime.nunique()