Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Detection eddies
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
IPSL
LMD
DPAO
Detection eddies
Commits
9b44e485
Commit
9b44e485
authored
1 year ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Give special treatment to phantom patterns
This is case 2 correction in the Matlab program of Rémi Laxenaire.
parent
044f30a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Trajectories/trajectories.py
+51
-0
51 additions, 0 deletions
Trajectories/trajectories.py
with
51 additions
and
0 deletions
Trajectories/trajectories.py
+
51
−
0
View file @
9b44e485
...
...
@@ -16,6 +16,8 @@ import graph_tool
from
graph_tool
import
topology
import
json
import
sys
import
report_graph
import
numpy
as
np
def
new_traj
(
ind_traj
,
traj_prop
,
n
,
traj_vert_ind
):
"""
Assign new trajectory to vertex index n.
"""
...
...
@@ -61,6 +63,55 @@ traj_vert_ind = []
# of vertex indices.
for
n
in
topology
.
topological_sort
(
g
):
# First, we check whether we have a phantom pattern. Phantom
# eddies may appear in altimetric data because of
# interpolation. In a phantom pattern, we have splitting
# immediately followed by merging. We do not want to let phantom
# patterns interrupt trajectories.
if
g
.
vertex
(
n
).
in_degree
()
==
2
:
pred
=
g
.
get_in_neighbors
(
n
)
if
np
.
all
(
g
.
get_in_degrees
(
pred
)
==
1
)
\
and
np
.
all
(
g
.
get_out_degrees
(
pred
)
==
1
):
n1
=
g
.
get_in_neighbors
(
pred
[
0
])[
0
]
n2
=
g
.
get_in_neighbors
(
pred
[
1
])[
0
]
if
n1
==
n2
and
g
.
vertex
(
n1
).
out_degree
()
==
2
:
# We have a splitting event at n1 immediately followed
# by a merging at n. Check the time interval between
# splitting and merging. The date of merging is the
# date of the first eddy in segment n and the date of
# splitting is the date of the last eddy in segment
# n1.
date_merging
=
report_graph
.
node_to_date_eddy
(
g
.
vp
.
name
[
n
],
g
.
gp
.
e_overestim
,
only_date
=
True
)
date_splitting
=
report_graph
.
node_to_date_eddy
(
g
.
vp
.
inst_eddies
[
n1
][
-
1
],
g
.
gp
.
e_overestim
,
only_date
=
True
)
if
date_merging
-
date_splitting
<=
6
:
# We have a phantom pattern. Get the vertex on the
# side of the shortest path:
v_short
=
topology
.
shortest_path
(
g
,
n1
,
n
,
weights
=
g
.
ep
.
cost_function
,
dag
=
True
)[
0
][
1
]
if
traj_prop
[
v_short
]
!=
traj_prop
[
n1
]:
# Correct the trajectories that were assigned
# according to closest successor, that is:
# swap the trajectories of pred[0] and
# pred[1]:
traj_prop
[
pred
[
0
]],
traj_prop
[
pred
[
1
]]
\
=
traj_prop
[
pred
[
1
]],
traj_prop
[
pred
[
0
]]
traj_vert_ind
[
traj_prop
[
pred
[
0
]]][
-
1
],
\
traj_vert_ind
[
traj_prop
[
pred
[
1
]]][
-
1
]
\
=
traj_vert_ind
[
traj_prop
[
pred
[
1
]]][
-
1
],
\
traj_vert_ind
[
traj_prop
[
pred
[
0
]]][
-
1
]
traj_prop
[
n
]
=
traj_prop
[
n1
]
traj_vert_ind
[
traj_prop
[
n1
]].
append
(
n
)
if
traj_prop
[
n
]
==
-
1
:
if
g
.
vertex
(
n
).
in_degree
()
>=
1
:
# Find the index of the closest direct predecessor of a node:
...
...
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