Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enstools-feature
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph.Fischer
enstools-feature
Commits
c45cdd05
Commit
c45cdd05
authored
2 years ago
by
Christoph.Fischer
Browse files
Options
Downloads
Patches
Plain Diff
cont tracking waves
parent
5fef7d7f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
enstools/feature/tracking/african_easterly_waves/tracking.py
+64
-20
64 additions, 20 deletions
enstools/feature/tracking/african_easterly_waves/tracking.py
with
64 additions
and
20 deletions
enstools/feature/tracking/african_easterly_waves/tracking.py
+
64
−
20
View file @
c45cdd05
...
...
@@ -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
_
in
dices_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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment