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

Add the possibility of dates in any slice

Previously the script worked only for dates in slice 0.
parent cbdf0461
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ def compute_bbox(ishape_list, reader_outer): ...@@ -25,7 +25,7 @@ def compute_bbox(ishape_list, reader_outer):
return bbox return bbox
def func(d, ax, ishape_lists_all, SHPC, bbox, light): def func(d, ax, i_slices, ishape_lists_all, SHPC, bbox, light):
"""To be passed as argument to the animation """To be passed as argument to the animation
function. ishape_lists_all is a dictionary. function. ishape_lists_all is a dictionary.
...@@ -37,7 +37,7 @@ def func(d, ax, ishape_lists_all, SHPC, bbox, light): ...@@ -37,7 +37,7 @@ def func(d, ax, ishape_lists_all, SHPC, bbox, light):
for orientation in ["Anticyclones", "Cyclones"]: for orientation in ["Anticyclones", "Cyclones"]:
plot_eddy_contours.snapshot(ax, ishape_lists_all[orientation][d], SHPC, plot_eddy_contours.snapshot(ax, ishape_lists_all[orientation][d], SHPC,
0, orientation, light = light) i_slices[d], orientation, light = light)
ax.gridlines(draw_labels = True) ax.gridlines(draw_labels = True)
ax.coastlines() ax.coastlines()
...@@ -47,12 +47,16 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light): ...@@ -47,12 +47,16 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light):
"""SHPC is an instance of SHPC_class.""" """SHPC is an instance of SHPC_class."""
ishape_lists_all = {} ishape_lists_all = {}
i_slices = {}
for d in range(d_min, d_max + 1):
i_slices[d] = SHPC.get_slice(d)
for orientation in ["Anticyclones", "Cyclones"]: for orientation in ["Anticyclones", "Cyclones"]:
ishape_lists_all[orientation] = {} ishape_lists_all[orientation] = {}
for d in range(d_min, d_max + 1): for d in range(d_min, d_max + 1):
ishape_lists_all[orientation][d] = plot_eddy_contours.select_ishapes(d, SHPC, 0, orientation, ishape_lists_all[orientation][d] = plot_eddy_contours.select_ishapes(d, SHPC, i_slices[d], orientation,
window) window)
if window is None: if window is None:
...@@ -61,14 +65,14 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light): ...@@ -61,14 +65,14 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light):
for orientation in ["Anticyclones", "Cyclones"]: for orientation in ["Anticyclones", "Cyclones"]:
for d in range(d_min, d_max + 1): for d in range(d_min, d_max + 1):
b2 = compute_bbox(ishape_lists_all[orientation][d], b2 = compute_bbox(ishape_lists_all[orientation][d],
SHPC.get_reader(0, orientation, SHPC.get_reader(i_slices[d], orientation,
"outermost_contour")) "outermost_contour"))
bbox = bbox_union(bbox, b2) bbox = bbox_union(bbox, b2)
else: else:
bbox = window bbox = window
ani = animation.FuncAnimation(fig, func, range(d_min, d_max + 1), ani = animation.FuncAnimation(fig, func, range(d_min, d_max + 1),
fargs = (ax, ishape_lists_all, SHPC, bbox, fargs = (ax, i_slices, ishape_lists_all, SHPC, bbox,
light), interval = 500) light), interval = 500)
return ani return ani
...@@ -104,8 +108,8 @@ if __name__ == "__main__": ...@@ -104,8 +108,8 @@ if __name__ == "__main__":
d_min = args.dates[0] d_min = args.dates[0]
d_max = args.dates[1] d_max = args.dates[1]
if not SHPC.d_init[0] <= d_min < d_max <= SHPC.d_init[0] \ if not SHPC.d_init[0] <= d_min < d_max <= SHPC.d_init[- 1] \
+ SHPC.get_n_dates(0) - 1: + SHPC.get_n_dates(SHPC.n_slices - 1) - 1:
sys.exit("Bad dates specified") sys.exit("Bad dates specified")
else: else:
d_min = SHPC.d_init[0] d_min = SHPC.d_init[0]
......
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