Skip to content
Snippets Groups Projects
Commit b98be8d0 authored by Lionel GUEZ's avatar Lionel GUEZ
Browse files

Read and write fixed filenames in `overlap_v6.py`

Instead of filenames constructed from the orientation. So we need to
create symlinks before running the script. It is clearer this way that
the script processes a single orientation, and that the processing
does not depend on the orientation. The script does not take a command
line argument any longer.
parent 52e524b1
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
"""This script reads the eddy graph from Matlab v6 files
id_child_(anti|cyclo).mat and N(anti|cyclo).mat, and writes the
graph to a new file in edgelist format.
"""This script reads the eddy graph from Matlab v6 files id_child.mat
and N_eddies.mat, for a given orientation and writes the graph to
a new file in edgelist format.
"""
......@@ -25,10 +25,8 @@ def adjust_n(n_Matlab):
k = date_num[k_Matlab] - date_num[0]
return n_Matlab + (k - k_Matlab) * e_overestim
orientation = sys.argv[1] # "cyclo" or "anti"
id_child = sio.loadmat(f"id_child_{orientation}.mat", squeeze_me=True)\
["id_child"]
n_eddies = sio.loadmat(f"N{orientation}.mat", squeeze_me = True)["N_eddies"]\
id_child = sio.loadmat("id_child.mat", squeeze_me=True)["id_child"]
n_eddies = sio.loadmat("N_eddies.mat", squeeze_me = True)["N_eddies"]\
.astype(int, casting = "safe", copy = False)
date_num = sio.loadmat("date_num.mat", squeeze_me = True)["date_num"]
n_dates = n_eddies.size
......@@ -40,7 +38,7 @@ d_init = to_days_1950(date_num[0])
with open("node_id_param.json", "w") as f:
json.dump({"e_overestim": e_overestim, "d_init": d_init}, f)
with open(f"edgelist_{orientation}.csv", "w", newline = '') as edgelist:
with open(f"edgelist.csv", "w", newline = '') as edgelist:
writer = csv.writer(edgelist, delimiter = ' ', lineterminator = "\n")
for j1 in range(n_dates):
......
[
{
"title": "Graph_from_Matlab_v6_cyclo",
"command": ["$src_dir/Convert_Matlab/overlap_v6.py", "cyclo"],
"command": "$src_dir/Convert_Matlab/overlap_v6.py",
"required":
[
"$src_dir/Convert_Matlab/Eurec4A_OA/id_child_cyclo.mat",
"$src_dir/Convert_Matlab/Eurec4A_OA/Ncyclo.mat",
[
"$src_dir/Convert_Matlab/Eurec4A_OA/id_child_cyclo.mat",
"id_child.mat"
],
["$src_dir/Convert_Matlab/Eurec4A_OA/Ncyclo.mat", "N_eddies.mat"],
"$src_dir/Convert_Matlab/Eurec4A_OA/date_num.mat"
]
},
{
"title": "Graph_from_Matlab_v6_anti",
"command": ["$src_dir/Convert_Matlab/overlap_v6.py", "anti"],
"command": "$src_dir/Convert_Matlab/overlap_v6.py",
"required":
[
"$src_dir/Convert_Matlab/Eurec4A_OA/id_child_anti.mat",
"$src_dir/Convert_Matlab/Eurec4A_OA/Nanti.mat",
[
"$src_dir/Convert_Matlab/Eurec4A_OA/id_child_anti.mat",
"id_child.mat"
],
["$src_dir/Convert_Matlab/Eurec4A_OA/Nanti.mat", "N_eddies.mat"],
"$src_dir/Convert_Matlab/Eurec4A_OA/date_num.mat"
]
},
......
......@@ -34,10 +34,7 @@
],
"required":
[
[
"$tests_old_dir/Graph_from_Matlab_v6_anti/edgelist_anti.csv",
"edgelist.csv"
],
"$tests_old_dir/Graph_from_Matlab_v6_anti/edgelist.csv",
"$tests_old_dir/Graph_from_Matlab_v6_anti/node_id_param.json"
]
}
......
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