def get_unused_data(self, raw_data=False): """ Add in track object all the observations which aren't selected Returns: Unused Eddies """ nb_dataset = len(self.datasets) has_virtual = "virtual" in self[0].dtype.names eddies = list() for i, dataset in enumerate(self.datasets): last_dataset = i == (nb_dataset - 1) if has_virtual and not last_dataset: m_in = ~self[i]["virtual"] else: m_in = slice(None) if i == 0: index_used = self[i]["in"] elif last_dataset: index_used = self[i - 1]["out"] else: index_used = unique( concatenate((self[i - 1]["out"], self[i]["in"][m_in]))) logger.debug("Load file : %s", dataset) if self.memory: with open(dataset, "rb") as h: current_obs = self.class_method.load_file( h, raw_data=raw_data) else: current_obs = self.class_method.load_file(dataset, raw_data=raw_data) eddies.append(current_obs.index(index_used, reverse=True)) return EddiesObservations.concatenate(eddies)
def update_axes(ax, mappable=None): ax.grid() if mappable: plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9])) # %% # We load demo sample and take only first year. # # Replace by a list of filename to apply on your own dataset. file_objects = get_remote_demo_sample( "eddies_med_adt_allsat_dt2018/Anticyclonic_2010_2011_2012")[:365] # %% # Merge all identification datasets in one object all_a = EddiesObservations.concatenate( [EddiesObservations.load_file(i) for i in file_objects]) # %% # We define polygon bound x0, x1, y0, y1 = 15, 20, 33, 38 xs = np.array([[x0, x1, x1, x0, x0]], dtype="f8") ys = np.array([[y0, y0, y1, y1, y0]], dtype="f8") # Polygon object created for the match function use. polygon = dict(contour_lon_e=xs, contour_lat_e=ys, contour_lon_s=xs, contour_lat_s=ys) # %% # Geographic frequency of eddies step = 0.125
# Movie period t0 = (datetime(2005, 5, 1) - datetime(1950, 1, 1)).days t1 = (datetime(2005, 6, 1) - datetime(1950, 1, 1)).days # %% # Get data from period and area e = EddiesObservations.load_file(data.get_demo_path("network_med.nc")) e = e.extract_with_mask((e.time >= t0) * (e.time < t1)).extract_with_area( dict(llcrnrlon=25, urcrnrlon=35, llcrnrlat=31, urcrnrlat=37.5)) # %% # Reproduce individual daily identification(for demonstration) EDDIES_BY_DAYS = list() for i, b0, b1 in e.iter_on("time"): EDDIES_BY_DAYS.append(e.index(i)) # need for display e = EddiesObservations.concatenate(EDDIES_BY_DAYS) # %% # Run network building group to intercept every step n = MyNetwork.from_eddiesobservations(EDDIES_BY_DAYS, window=7) _ = n.group_observations(minimal_area=True) # %% def update(frame): i_current, i_match, gr = NETWORK_GROUPS[frame] current = EDDIES_BY_DAYS[i_current] x = flatten_line_matrix(current.contour_lon_e) y = flatten_line_matrix(current.contour_lat_e) current_contour.set_data(x, y) match = EDDIES_BY_DAYS[i_match]