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
Authenticating with a password
with git over http
works again
. More information
here
.
Show more breadcrumbs
IPSL
LMD
DPAO
Detection eddies
Commits
0d8be0e5
Commit
0d8be0e5
authored
4 years ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Replace string argument by logical argument
parent
74d99145
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
Analysis/make_graph_from_Matlab_HDF5.py
+13
-11
13 additions, 11 deletions
Analysis/make_graph_from_Matlab_HDF5.py
with
13 additions
and
11 deletions
Analysis/make_graph_from_Matlab_HDF5.py
+
13
−
11
View file @
0d8be0e5
...
@@ -11,7 +11,7 @@ import h5py
...
@@ -11,7 +11,7 @@ import h5py
import
datetime
import
datetime
import
csv
import
csv
def
convert_id
(
orientati
on
,
eddy_index_Matlab
):
def
convert_id
(
cycl
on
e
,
eddy_index_Matlab
):
"""
Convert from Matlab eddy identification to eddy
"""
Convert from Matlab eddy identification to eddy
identification in shapefiles.
identification in shapefiles.
...
@@ -28,24 +28,24 @@ def convert_id(orientation, eddy_index_Matlab):
...
@@ -28,24 +28,24 @@ def convert_id(orientation, eddy_index_Matlab):
date
=
datetime
.
date
.
fromordinal
(
date_num
-
366
)
-
datetime
.
date
(
1950
,
1
,
1
)
date
=
datetime
.
date
.
fromordinal
(
date_num
-
366
)
-
datetime
.
date
(
1950
,
1
,
1
)
date
=
date
.
days
date
=
date
.
days
if
orientation
==
"
anticyclone
"
:
if
cyclone
:
eddy_index_F
=
eddy_index_Matlab
-
k
*
n_max
else
:
eddy_index_F
=
Nanti
[
k
]
+
eddy_index_Matlab
-
k
*
n_max
eddy_index_F
=
Nanti
[
k
]
+
eddy_index_Matlab
-
k
*
n_max
else
:
eddy_index_F
=
eddy_index_Matlab
-
k
*
n_max
return
date
,
eddy_index_F
return
date
,
eddy_index_F
def
print_edgelist
(
orientation
,
file
,
id_child
):
def
print_edgelist
(
file
,
id_child
,
cyclone
):
for
i1
,
id_child_1
in
enumerate
(
id_child
):
for
i1
,
id_child_1
in
enumerate
(
id_child
):
if
file
[
id_child_1
].
ndim
==
2
:
if
file
[
id_child_1
].
ndim
==
2
:
assert
file
[
id_child_1
].
shape
[
1
]
==
1
assert
file
[
id_child_1
].
shape
[
1
]
==
1
predecessor
=
(
orientati
on
,
k1
*
n_max
+
1
+
i1
)
predecessor
=
(
cycl
on
e
,
k1
*
n_max
+
1
+
i1
)
# file[id_child_1][:, 0] is a numpy array of successors.
# file[id_child_1][:, 0] is a numpy array of successors.
for
eddy_index_Matlab
in
file
[
id_child_1
][:,
0
]:
for
eddy_index_Matlab
in
file
[
id_child_1
][:,
0
]:
eddy_index_Matlab
=
int
(
eddy_index_Matlab
)
eddy_index_Matlab
=
int
(
eddy_index_Matlab
)
writer
.
writerow
(
convert_id
(
*
predecessor
)
writer
.
writerow
(
convert_id
(
*
predecessor
)
+
convert_id
(
orientati
on
,
eddy_index_Matlab
))
+
convert_id
(
cycl
on
e
,
eddy_index_Matlab
))
Assoc_eddies_Anti_max
=
h5py
.
File
(
"
Association_eddies_Anti_max.mat
"
,
"
r
"
)
Assoc_eddies_Anti_max
=
h5py
.
File
(
"
Association_eddies_Anti_max.mat
"
,
"
r
"
)
Assoc_eddies_Cyclo_max
=
h5py
.
File
(
"
Association_eddies_Cyclo_max.mat
"
,
"
r
"
)
Assoc_eddies_Cyclo_max
=
h5py
.
File
(
"
Association_eddies_Cyclo_max.mat
"
,
"
r
"
)
...
@@ -68,7 +68,9 @@ with open("edgelist.csv", "w", newline = '') as edgelist:
...
@@ -68,7 +68,9 @@ with open("edgelist.csv", "w", newline = '') as edgelist:
writer
.
writerow
([
"
k1
"
,
"
i1
"
,
"
k2
"
,
"
i2
"
])
writer
.
writerow
([
"
k1
"
,
"
i1
"
,
"
k2
"
,
"
i2
"
])
for
k1
in
range
(
n_dates
):
for
k1
in
range
(
n_dates
):
print_edgelist
(
"
anticyclone
"
,
Assoc_eddies_Anti_max
,
print_edgelist
(
Assoc_eddies_Anti_max
,
Assoc_eddies_Anti_max
[
"
id_child
"
][
k1
,
:
Nanti
[
k1
]])
Assoc_eddies_Anti_max
[
"
id_child
"
][
k1
,
:
Nanti
[
k1
]],
print_edgelist
(
"
cyclone
"
,
Assoc_eddies_Cyclo_max
,
cyclone
=
False
)
Assoc_eddies_Cyclo_max
[
"
id_child
"
][
k1
,
:
Ncyclo
[
k1
]])
print_edgelist
(
Assoc_eddies_Cyclo_max
,
Assoc_eddies_Cyclo_max
[
"
id_child
"
][
k1
,
:
Ncyclo
[
k1
]],
cyclone
=
True
)
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