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

Use `e_overestim.txt`

Use `e_overestim.txt` instead of `node_id_param.json`. Since commit
43d2eff6, we wrote only `e_overestim` to the JSon file. Simpler to
write the value alone in a text file.
parent a794a866
No related branches found
No related tags found
No related merge requests found
......@@ -55,9 +55,7 @@ if __name__ == "__main__":
e_overestim = id_child.shape[0]
print("e_overestim =", e_overestim)
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("e_overestim.txt", "w") as f: f.write(str(e_overestim) + "\n")
with open("edgelist.csv", "w", newline = '') as edgelist:
writer = csv.writer(edgelist, delimiter = ' ', lineterminator = "\n")
......
......@@ -27,9 +27,9 @@ if args.ishape:
ishape = args.ishape
else:
if args.node:
with open("node_id_param.json") as f: node_id_param = json.load(f)
date, eddy_index = report_graph\
.node_to_date_eddy(args.node, node_id_param["e_overestim"])
with open("e_overestim.txt") as f: e_overestim = int(f.read())
date, eddy_index = report_graph.node_to_date_eddy(args.node,
e_overestim)
else:
reply = input("date, eddy_index = ? ").split(",")
date = int(reply[0])
......
......@@ -70,9 +70,8 @@ program test_overlap
< hshp%d0 + n_dates, "test_overlap k_test_1, k_test_2")
e_overestim = maxval([hshp%ishape_last(hshp%d0) + 1, &
ediff1d(hshp%ishape_last)])
open(unit, file = "node_id_param.json", status = "replace", &
action = "write")
write(unit, fmt = *) '{"e_overestim": ', e_overestim, '}'
open(unit, file = "e_overestim.txt", status = "replace", action = "write")
write(unit, fmt = *) e_overestim
close(unit)
call read_snapshot(flow(1), [hshp], nlon, nlat, k_test_1, corner, step, copy)
call read_snapshot(flow(max_delta + 1), [hshp], nlon, nlat, k_test_2, &
......
......@@ -112,9 +112,8 @@ program eddy_graph
"eddy_graph: n_proc should be <= n_dates / (max_delta + 1)")
e_overestim = maxval([(hshpc(i)%ishape_last(hshpc(i)%d0) + 1, &
ediff1d(hshpc(i)%ishape_last), i = 1, n_shpc)])
open(unit, file = "node_id_param.json", status = "replace", &
action = "write")
write(unit, fmt = *) '{"e_overestim": ', e_overestim, '}'
open(unit, file = "e_overestim.txt", status = "replace", action = "write")
write(unit, fmt = *) e_overestim
close(unit)
corner = corner_deg * deg_to_rad
step = step_deg * deg_to_rad
......
......@@ -34,4 +34,4 @@ sort --key=1,1 --key=2,2 --numeric-sort --output=edgelist.csv \
rm edgelist_unsorted.csv
echo "Created files \"edgelist.csv\", \"isolated_nodes.txt\" and " \
"\"node_id_param.json\"."
"\"e_overestim.txt\"."
......@@ -32,9 +32,8 @@ def read_eddy_graph(edgelist, shpc_dir = None):
G = nx.read_edgelist(edgelist, create_using = nx.DiGraph,
nodetype = int)
dir_edgelist = path.dirname(edgelist)
node_id_param_file = path.join(dir_edgelist, "node_id_param.json")
with open(node_id_param_file) as f: node_id_param = json.load(f)
G.graph["e_overestim"] = node_id_param["e_overestim"]
e_overestim_file = path.join(dir_edgelist, "e_overestim.txt")
with open(e_overestim_file) as f: G.graph["e_overestim"] = int(f.read())
if shpc_dir is not None:
# Read and set attributes of eddies:
......
......@@ -5,7 +5,7 @@ computes the non-local cost functions applied to edges.
Input:
- "node_id_param.json", expected to be in the current directory
- "e_overestim.txt", expected to be in the current directory
- the graph of segments without cost functions, "segments.gt" or
"segments.graphml", expected to be in the current directory
......@@ -95,10 +95,7 @@ parser.add_argument("SHPC_dir", nargs='+')
parser.add_argument("--graphml", action = "store_true",
help = "save to graphml format")
args = parser.parse_args()
# Grab e_overestim:
with open("node_id_param.json") as f: node_id_param = json.load(f)
e_overestim = node_id_param["e_overestim"]
with open("e_overestim.txt") as f: e_overestim = int(f.read())
# Set some values needed for the cost function:
......
......@@ -17,7 +17,7 @@
"env": {"PYTHONPATH": "$src_dir/Overlap:$src_dir/Common"},
"symlink":
[
"$tests_old_dir/EGr2nd15md4/node_id_param.json",
"$tests_old_dir/EGr2nd15md4/e_overestim.txt",
"$tests_old_dir/Segments/segments.graphml"
],
"exclude_cmp": ["timings.txt"]
......@@ -44,7 +44,7 @@
"env": {"PYTHONPATH": "$src_dir/Overlap:$src_dir/Common"},
"symlink":
[
"$tests_old_dir/Greece_graph/node_id_param.json",
"$tests_old_dir/Greece_graph/e_overestim.txt",
"$tests_old_dir/Greece_segments/segments.graphml"
]
},
......
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