Skip to content
Snippets Groups Projects
Commit c45cdd05 authored by Christoph.Fischer's avatar Christoph.Fischer
Browse files

cont tracking waves

parent 5fef7d7f
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,38 @@ class AEWTracking(ObjectComparisonTracking):
print("postprocess @ aew")
return
def adjust_track(self, track):
def get_downstream_nodes_after(self, time_delta, edges, start_index):
if time_delta < 0:
??
node_indices = [start_index]
obj_node_list = [e.parent for e in edges] # this up
co = edges[start_index]
node, connected_nodes = co.parent, co.childs
for c_node in connected_nodes:
dt = pb_str_to_datetime(c_node.time) - pb_str_to_datetime(node.time)
remaining_time_delta = time_delta - dt
# get index of connected node in graph
c_node_idx = obj_node_list.index(c_node)
# call recursively on this connected node
end_way_node_list = self.get_downstream_nodes_after(remaining_time_delta, edges, c_node_idx)
node_indices.extend(c_node_downstream_indices)
return [final node, nodes on the way]
def adjust_track(self, track): # TODO track should be graph?
# keep track if persists longer than duration_threshold
nodes = [edge.parent for edge in track.edges]
......@@ -78,43 +109,56 @@ class AEWTracking(ObjectComparisonTracking):
# TODO need general statement that nodes are part of exactly one track.
# init nodes as
# init nodes as False = should be discarded
keep_node = [False] * len(nodes)
# iterate over all nodes: if fast enough from this to this+dt, keep
for node_idx, node in enumerate(nodes):
node_time_plus_delta = pb_str_to_datetime(node.time) + self.config.delta48
# TODO v this should instantly return pairs (endnote, all nodes on path) for later
downstream_nodes = get_downstream_nodes_after(self.config.slow_duration_window, node_idx, track.edges)
# downstream_nodes_with_path = self.get_downstream_nodes_after(self.config.slow_duration_window, track.edges, node_idx)
# TODO if none? maybe skipped?
ds_nodes = AEWTracking.get_downstream_node_indices(nodes, node_idx, until_time=node_time_plus_delta)
end_nodes = ends_of(ds_nodes)
for end_node in end_nodes:
ds_node_lon_center = (ds.object.properties.bb.max.lon + ds.object.properties.bb.min.lon) / 2.0
deg_per_hr_avg = (ds_node_lon_center - center_lons[node_idx]) / self.config.slow_duration_window.hours
if abs(deg_per_hr_avg) > abs(self.config.avg_speed_thr):
if speed A->B is not fine:
continue
us_nodes = get_upstream_nodes_at_time(t)
nodes_in_path_ab = cut(ds_nodes, us_nodes)
keep_node[nodes_in_path_ab] = True
"""
# for each +48h node: check if avg speed fulfilled. if yes, mark this path.
for ds in downstream_nodes:
for ds, path_nodes in downstream_nodes_with_path:
ds_node_lon_center = (ds.object.properties.bb.max.lon + ds.object.properties.bb.min.lon) / 2.0
deg_per_hr_avg = (ds_node_lon_center - center_lons[node_idx]) / self.config.slow_duration_window.hours
if abs(deg_per_hr_avg) > abs(self.config.avg_speed_thr):
# fast enough, keep all nodes along this path.
keep_idxs = get_node_indices_between(node, ds, nodes)
for keep_idx in keep_idxs:
keep_node[keep_idx] = True
for path_node in path_nodes:
keep_node[path_node] = True
"""
kept_nodes = [node for x, node in enumerate(nodes) if keep_node[x]]
new_tracks = generate_tracks(kept_nodes) # regenerate tracks out of leftover edges.
# regenerate tracks out of leftover edges. this also splits a track etc, and removes short ones
new_tracks = generate_tracks(kept_nodes)
return new_tracks
#print(times)
#print(center_lons)
#exit()
"""
for x,x+48h
center point dist in deg?
if avg_48_speed < avg_speed_thr:
remove pts in between
recursive on two leftover tracks?
"""
# TODO for each 48h window:
# didnt move far enough -> trim start/end or split
# TODO
# redo clim, plot which WTs not considered
return track
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment