diff --git a/Inst_eddies/Analysis/anim_eddy_contours.py b/Inst_eddies/Analysis/anim_eddy_contours.py index 8601f89c94d2fa7808912ad65474032c3b59712e..0f46e01bc514b18fae24e2621259df51f50cc075 100755 --- a/Inst_eddies/Analysis/anim_eddy_contours.py +++ b/Inst_eddies/Analysis/anim_eddy_contours.py @@ -25,7 +25,7 @@ def compute_bbox(ishape_list, reader_outer): 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 function. ishape_lists_all is a dictionary. @@ -37,7 +37,7 @@ def func(d, ax, ishape_lists_all, SHPC, bbox, light): for orientation in ["Anticyclones", "Cyclones"]: 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.coastlines() @@ -47,12 +47,16 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light): """SHPC is an instance of SHPC_class.""" 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"]: ishape_lists_all[orientation] = {} 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) if window is None: @@ -61,14 +65,14 @@ def anim_eddies(fig, ax, SHPC, window, d_min, d_max, light): for orientation in ["Anticyclones", "Cyclones"]: for d in range(d_min, d_max + 1): b2 = compute_bbox(ishape_lists_all[orientation][d], - SHPC.get_reader(0, orientation, + SHPC.get_reader(i_slices[d], orientation, "outermost_contour")) bbox = bbox_union(bbox, b2) else: bbox = window 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) return ani @@ -104,8 +108,8 @@ if __name__ == "__main__": d_min = args.dates[0] d_max = args.dates[1] - if not SHPC.d_init[0] <= d_min < d_max <= SHPC.d_init[0] \ - + SHPC.get_n_dates(0) - 1: + if not SHPC.d_init[0] <= d_min < d_max <= SHPC.d_init[- 1] \ + + SHPC.get_n_dates(SHPC.n_slices - 1) - 1: sys.exit("Bad dates specified") else: d_min = SHPC.d_init[0]