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
Admin message
Gitlab has been updated. More info
here
and
there
.
Show more breadcrumbs
IPSL
LMD
DPAO
Detection eddies
Commits
873f04c8
Commit
873f04c8
authored
6 months ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Process only one orientation per run
parent
97a162c1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Trajectories/Analysis/long_trajectories.py
+87
-91
87 additions, 91 deletions
Trajectories/Analysis/long_trajectories.py
Trajectories/Tests/tests.json
+2
-1
2 additions, 1 deletion
Trajectories/Tests/tests.json
with
89 additions
and
92 deletions
Trajectories/Analysis/long_trajectories.py
+
87
−
91
View file @
873f04c8
...
...
@@ -20,94 +20,90 @@ SHPC = util_eddies.SHPC_class(
)
dir_part
=
{
"
Anticyclones
"
:
"
Graph_anti
"
,
"
Cyclones
"
:
"
Graph_cyclo
"
}
min_duration
=
16
*
7
for
orientation
in
[
"
Anticyclones
"
,
"
Cyclones
"
]:
print
(
"
Orientation:
"
,
orientation
)
with
open
(
"
/data/guez/Oceanic_eddies/Eurec4A/
"
f
"
{
dir_part
[
orientation
]
}
/expanded_traj.json
"
)
as
f_obj
:
expanded_traj
=
json
.
load
(
f_obj
)
traj_list
=
expanded_traj
[
"
traj
"
].
values
()
duration_array
=
plot_traj
.
get_duration
(
traj_list
,
expanded_traj
[
"
e_overestim
"
]
)
# Create a mask for instantaneous eddies which are in trajectories
# longer than min_duration. With this mask, we can read through
# the shapefiles sequentially. This is faster than processing
# occurrences in the order of trajectories and jumping arouund the
# shapefiles to fetch corresponding information. The mask,
# `long_traj`, is a list of numpy arrays. Each element of the list
# corresponds to a slice of the SHPC. `long_traj` takes a lot of
# main memory, though: about 30 MiB.
t0
=
time
.
perf_counter
()
long_traj
=
[]
# Create the arrays in `long_traj` with the right size and
# initialize them to False. False means the instantaneous eddy is
# not in a long trajectory.
for
i_slice
in
range
(
SHPC
.
n_slices
):
n_shapes
=
SHPC
.
get_n_shapes
(
i_slice
,
orientation
)
x
=
np
.
full
(
n_shapes
,
False
)
long_traj
.
append
(
x
)
# Define `long_traj`. Note that we do not read the shapefiles
# here, so this should be fast.
for
traj
,
duration
in
zip
(
expanded_traj
[
"
traj
"
].
values
(),
duration_array
):
if
duration
>=
min_duration
:
for
n
in
traj
:
i_slice
,
ishape
=
SHPC
.
comp_ishape_n
(
n
,
expanded_traj
[
"
e_overestim
"
],
orientation
)
long_traj
[
i_slice
][
ishape
]
=
True
t1
=
time
.
perf_counter
()
print
(
f
"
Time to define long_traj:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
my_data
=
[]
# Now read the extremum shapefiles sequentially:
for
i_slice
in
range
(
SHPC
.
n_slices
):
reader
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
extremum
"
)
for
rec
in
reader
.
iterRecords
(
fields
=
[
"
speed
"
]):
if
long_traj
[
i_slice
][
rec
.
oid
]:
my_data
.
append
(
rec
[
"
speed
"
])
my_data
=
np
.
array
(
my_data
,
np
.
float32
)
fname
=
f
"
speed_
{
orientation
.
lower
()
}
"
np
.
save
(
fname
,
my_data
)
print
(
"
Created
"
,
fname
)
t1
=
time
.
perf_counter
()
print
(
f
"
Time to create
{
fname
}
:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
my_data
=
[]
# Read other shapefiles, max_speed_contour and outermost_contour,
# sequentially:
for
i_slice
in
range
(
SHPC
.
n_slices
):
reader_max
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
max_speed_contour
"
)
reader_out
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
outermost_contour
"
)
for
rec_max
,
rec_out
in
zip
(
reader_max
.
iterRecords
(
fields
=
[
"
r_eq_area
"
]),
reader_out
.
iterRecords
(
fields
=
[
"
r_eq_area
"
]),
):
if
long_traj
[
i_slice
][
rec_max
.
oid
]:
if
rec_max
.
r_eq_area
==
-
100
:
my_data
.
append
(
rec_out
.
r_eq_area
)
else
:
my_data
.
append
(
rec_max
.
r_eq_area
)
my_data
=
np
.
array
(
my_data
,
np
.
float32
)
fname
=
f
"
radius_
{
orientation
.
lower
()
}
"
np
.
save
(
fname
,
my_data
)
print
(
"
Created
"
,
fname
)
t1
=
time
.
perf_counter
()
print
(
f
"
Time to create
{
fname
}
:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
orientation
=
input
(
"
Orientation?
"
)
with
open
(
"
/data/guez/Oceanic_eddies/Eurec4A/
"
f
"
{
dir_part
[
orientation
]
}
/expanded_traj.json
"
)
as
f_obj
:
expanded_traj
=
json
.
load
(
f_obj
)
traj_list
=
expanded_traj
[
"
traj
"
].
values
()
duration_array
=
plot_traj
.
get_duration
(
traj_list
,
expanded_traj
[
"
e_overestim
"
])
# Create a mask for instantaneous eddies which are in trajectories
# longer than min_duration. With this mask, we can read through
# the shapefiles sequentially. This is faster than processing
# occurrences in the order of trajectories and jumping arouund the
# shapefiles to fetch corresponding information. The mask,
# `long_traj`, is a list of numpy arrays. Each element of the list
# corresponds to a slice of the SHPC. `long_traj` takes a lot of
# main memory, though: about 30 MiB.
t0
=
time
.
perf_counter
()
long_traj
=
[]
# Create the arrays in `long_traj` with the right size and
# initialize them to False. False means the instantaneous eddy is
# not in a long trajectory.
for
i_slice
in
range
(
SHPC
.
n_slices
):
n_shapes
=
SHPC
.
get_n_shapes
(
i_slice
,
orientation
)
x
=
np
.
full
(
n_shapes
,
False
)
long_traj
.
append
(
x
)
# Define `long_traj`. Note that we do not read the shapefiles
# here, so this should be fast.
for
traj
,
duration
in
zip
(
expanded_traj
[
"
traj
"
].
values
(),
duration_array
):
if
duration
>=
min_duration
:
for
n
in
traj
:
i_slice
,
ishape
=
SHPC
.
comp_ishape_n
(
n
,
expanded_traj
[
"
e_overestim
"
],
orientation
)
long_traj
[
i_slice
][
ishape
]
=
True
t1
=
time
.
perf_counter
()
print
(
f
"
Time to define long_traj:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
my_data
=
[]
# Now read the extremum shapefiles sequentially:
for
i_slice
in
range
(
SHPC
.
n_slices
):
reader
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
extremum
"
)
for
rec
in
reader
.
iterRecords
(
fields
=
[
"
speed
"
]):
if
long_traj
[
i_slice
][
rec
.
oid
]:
my_data
.
append
(
rec
[
"
speed
"
])
my_data
=
np
.
array
(
my_data
,
np
.
float32
)
fname
=
f
"
speed_
{
orientation
.
lower
()
}
"
np
.
save
(
fname
,
my_data
)
print
(
"
Created
"
,
fname
)
t1
=
time
.
perf_counter
()
print
(
f
"
Time to create
{
fname
}
:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
my_data
=
[]
# Read other shapefiles, max_speed_contour and outermost_contour,
# sequentially:
for
i_slice
in
range
(
SHPC
.
n_slices
):
reader_max
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
max_speed_contour
"
)
reader_out
=
SHPC
.
get_reader
(
i_slice
,
orientation
,
"
outermost_contour
"
)
for
rec_max
,
rec_out
in
zip
(
reader_max
.
iterRecords
(
fields
=
[
"
r_eq_area
"
]),
reader_out
.
iterRecords
(
fields
=
[
"
r_eq_area
"
]),
):
if
long_traj
[
i_slice
][
rec_max
.
oid
]:
if
rec_max
.
r_eq_area
==
-
100
:
my_data
.
append
(
rec_out
.
r_eq_area
)
else
:
my_data
.
append
(
rec_max
.
r_eq_area
)
my_data
=
np
.
array
(
my_data
,
np
.
float32
)
fname
=
f
"
radius_
{
orientation
.
lower
()
}
"
np
.
save
(
fname
,
my_data
)
print
(
"
Created
"
,
fname
)
t1
=
time
.
perf_counter
()
print
(
f
"
Time to create
{
fname
}
:
{
t1
-
t0
:
.
0
f
}
s
"
)
t0
=
t1
This diff is collapsed.
Click to expand it.
Trajectories/Tests/tests.json
+
2
−
1
View file @
873f04c8
...
...
@@ -314,6 +314,7 @@
]
},
"Long_trajectories"
:
{
"command"
:
"$src_dir/Trajectories/Analysis/long_trajectories.py"
"command"
:
"$src_dir/Trajectories/Analysis/long_trajectories.py"
,
"input"
:
"Anticyclones
\n
"
}
}
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