From 53cd4094089e310405f00dc4bf9f54c6ab459bc5 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Tue, 26 Apr 2022 12:15:44 +0200
Subject: [PATCH] Add option `--node` to `eddy_dump.py`

---
 Inst_eddies/Analysis/eddy_dump.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/Inst_eddies/Analysis/eddy_dump.py b/Inst_eddies/Analysis/eddy_dump.py
index 9b83aedc..b4b12ae0 100755
--- a/Inst_eddies/Analysis/eddy_dump.py
+++ b/Inst_eddies/Analysis/eddy_dump.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
 """Dumps to standard output all information on a particular eddy,
-specified by date and eddy_index, or by shape index.
+specified by date and eddy_index, or by node index, or by shape index.
 
 """
 
@@ -12,10 +12,14 @@ import pprint
 import sys
 sys.path.append(path.join(sys.path[0], "../../Common"))
 import util_eddies
+import report_graph
+import json
 
 parser = argparse.ArgumentParser()
 parser.add_argument("directory", help = "containing the three shapefiles")
-parser.add_argument("-i", "--ishape", type = int)
+group = parser.add_mutually_exclusive_group()
+group.add_argument("-i", "--ishape", type = int)
+group.add_argument("-n", "--node", type = int)
 args = parser.parse_args()
 
 handler = util_eddies.open_shpc(args.directory)
@@ -23,9 +27,14 @@ handler = util_eddies.open_shpc(args.directory)
 if args.ishape:
     ishape = args.ishape
 else:
-    reply = input("date, eddy_index = ? ").split(",")
-    date = int(reply[0])
-    eddy_index = int(reply[1])
+    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"])
+    else:
+        reply = input("date, eddy_index = ? ").split(",")
+        date = int(reply[0])
+        eddy_index = int(reply[1])
 
     # Find ishape:
     if handler["ishape_last"] is None:
-- 
GitLab