def main(): db = OccurrencesDB() #define animation period current_start_date = datetime(1996,3,1,0,0,0) current_end_date = datetime(1999,8,1,0,0,0) future_start_date = datetime(2067,3,1,0,0,0) future_end_date = datetime(2070,8,1,0,0,0) simulation_step = timedelta(days = 5) #domain properties xs = polar_stereographic.xs ys = polar_stereographic.ys basemap = polar_stereographic.basemap positions = db.get_all_positions() i_indices = db.i_indices j_indices = db.j_indices index_zip = zip(i_indices, j_indices, positions) basin_patches = get_features_from_shape(basemap,linewidth = 0.5) #plot plots i = 0 current_time = current_start_date future_time = future_start_date while current_time < current_end_date: to_plot_current = np.ma.masked_all(xs.shape) to_plot_future = np.ma.masked_all(xs.shape) for x, y, position in index_zip: current_year_pos = YearPositionObject(current_time.year, position) future_year_pos = YearPositionObject(future_time.year, position) to_plot_current[x, y] = \ db.get_measure_of_distance_to_high_event(current_year_pos, current_time, current = True) to_plot_future[x, y] = \ db.get_measure_of_distance_to_high_event(future_year_pos, future_time, current = False) #actual plotting plt.figure() plt.subplot(1,2,1) basemap.pcolormesh(xs, ys, to_plot_current, vmin = 0, vmax = 1, cmap = 'Blues') basemap.drawcoastlines(linewidth = 0.3) # plot_basin_boundaries_from_shape(basemap, plotter = plt, linewidth = 0.5) plot_patches(plt, get_copies(basin_patches)) zoom_to_qc() plt.title(current_time.strftime('current: %Y-%m-%d')) plt.subplot(1,2,2) basemap.pcolormesh(xs, ys, to_plot_future, vmin = 0, vmax = 1, cmap = 'Blues', linewidth = 0.5) basemap.drawcoastlines(linewidth = 0.3) zoom_to_qc() plot_patches(plt, get_copies(basin_patches)) # plot_basin_boundaries_from_shape(basemap, plotter = plt) plt.title(future_time.strftime('future: %Y-%m-%d')) plt.savefig('frame_%010d.png' % i) i += 1 current_time += simulation_step future_time += simulation_step if current_time.month > current_end_date.month: current_time = datetime(current_time.year + 1, current_start_date.month, current_start_date.day) future_time = datetime(future_time.year + 1, future_start_date.month, future_start_date.day) pass