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

Rename keys of readers

Make them equal to basenames of shapefiles. Clearer and allows a
little simplification in programming.
parent d56812eb
No related branches found
No related tags found
No related merge requests found
......@@ -65,11 +65,11 @@ def snapshot(ax, ishape_list, readers, *, dashed = False, light = False,
dashed: boolean."""
for ishape in ishape_list:
shape_rec_extr = readers["extr"].shapeRecord(ishape)
shape_outer = readers["outer"].shape(ishape)
shape_rec_extr = readers["extremum"].shapeRecord(ishape)
shape_outer = readers["outermost_contour"].shape(ishape)
if "m_s" in readers:
shape_m_s = readers["m_s"].shape(ishape)
if "max_speed_contour" in readers:
shape_m_s = readers["max_speed_contour"].shape(ishape)
else:
shape_m_s = None
......@@ -184,12 +184,12 @@ def compute_bbox(ishape_lists, reader_outer):
def make_animation(fig, ax, k1, ishape_last, readers, window, k_min, k_max,
light):
ishape_lists = {k: select_ishapes(k, k1, ishape_last, readers["extr"],
ishape_lists = {k: select_ishapes(k, k1, ishape_last, readers["extremum"],
window)
for k in range(k_min, k_max + 1)}
if window is None:
bbox = compute_bbox(ishape_lists, readers["outer"])
bbox = compute_bbox(ishape_lists, readers["outermost_contour"])
else:
bbox = window
......@@ -200,18 +200,15 @@ def make_animation(fig, ax, k1, ishape_last, readers, window, k_min, k_max,
return ani
def open_shpt(shp_coll_dir):
readers = {"extr": shapefile.Reader(path.join(shp_coll_dir, "extremum")),
"outer":
shapefile.Reader(path.join(shp_coll_dir, "outermost_contour"))}
try:
readers["m_s"] = shapefile.Reader(path.join(shp_coll_dir,
"max_speed_contour"))
except shapefile.ShapefileException:
print("Shapefile max_speed_contour not found. "
"Max-speed contours will not be plotted.")
readers = {}
for layer in ["extremum", "outermost_contour", "max_speed_contour"]:
try:
readers[layer] = shapefile.Reader(path.join(shp_coll_dir, layer))
except shapefile.ShapefileException:
print(f"Shapefile {layer} not found.")
k1 = readers["extr"].record(0).date_index
k1 = readers["extremum"].record(0).date_index
fname = path.join(shp_coll_dir, "ishape_last.txt")
try:
......@@ -219,7 +216,7 @@ def open_shpt(shp_coll_dir):
except OSError:
print("Could not read", fname)
print("We will use all the shapes.")
ishape_last = [len(readers["extr"]) - 1]
ishape_last = [len(readers["extremum"]) - 1]
return readers, k1, ishape_last
......@@ -302,7 +299,7 @@ if __name__ == "__main__":
marker = "+", color = "gray", linestyle = "None")
if args.window is None: plot_grid_bb(args.shp_coll_dir, ax)
ishape_list = select_ishapes(k, k1, ishape_last, readers["extr"],
ishape_list = select_ishapes(k, k1, ishape_last, readers["extremum"],
args.window)
ax.set_title(f"k = {k}", y = 1.05)
snapshot(ax, ishape_list, readers, dashed = args.dashed,
......
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