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

Add argument to read interpolated eddies

Add argument to function `read_eddy_graph` to separately control the
reading and setting of attributes of interpolated eddies.  This is in
preparation for a transfer of this task from the main part of the
script to function `read_eddy_graph`.
parent c73f6449
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import csv
import shapefile
from os import path
def read_eddy_graph(edgelist, shp_tr_dir = None):
def read_eddy_graph(edgelist, shp_tr_dir = None, read_interp = True):
G = nx.DiGraph()
with open(edgelist) as f:
......@@ -20,10 +20,8 @@ def read_eddy_graph(edgelist, shp_tr_dir = None):
int(row[3]), float(row[4])
G.add_edge((k1, i1), (k2, i2), weight = weight)
if shp_tr_dir is not None:
# Read attributes of nodes:
# Interpolated eddies:
if read_interp:
# Read and set attributes of interpolated eddies:
# Assuming that the directory containing the interpolated
# eddies is in the same location as edgelist:
......@@ -37,7 +35,8 @@ def read_eddy_graph(edgelist, shp_tr_dir = None):
interpolat = True, speed = shape_rec.record.speed,
ssh = shape_rec.record.ssh)
# Visible eddies:
if shp_tr_dir is not None:
# Read and set attributes of Visible eddies:
extremum = path.join(shp_tr_dir, "extremum")
......@@ -74,7 +73,7 @@ if __name__ == "__main__":
type = int, metavar = ("date_index", "eddy_index"))
args = parser.parse_args()
G = read_eddy_graph("edgelist.csv")
G = read_eddy_graph("edgelist.csv", read_interp = False)
if args.node is None:
H = G
......
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