From b98be8d0bdcec0463740da6e5788fcdee65c8db0 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Thu, 1 Jul 2021 18:06:00 +0200 Subject: [PATCH] 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. --- Convert_Matlab/overlap_v6.py | 14 ++++++-------- Convert_Matlab/short_tests.json | 18 ++++++++++++------ Overlap/Analysis/tests.json | 5 +---- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Convert_Matlab/overlap_v6.py b/Convert_Matlab/overlap_v6.py index 2da4352a..c8c28464 100755 --- a/Convert_Matlab/overlap_v6.py +++ b/Convert_Matlab/overlap_v6.py @@ -1,8 +1,8 @@ #!/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): diff --git a/Convert_Matlab/short_tests.json b/Convert_Matlab/short_tests.json index 6b7a7a81..06502f5d 100644 --- a/Convert_Matlab/short_tests.json +++ b/Convert_Matlab/short_tests.json @@ -1,21 +1,27 @@ [ { "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" ] }, diff --git a/Overlap/Analysis/tests.json b/Overlap/Analysis/tests.json index 01c5becf..0463fa8a 100644 --- a/Overlap/Analysis/tests.json +++ b/Overlap/Analysis/tests.json @@ -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" ] } -- GitLab