def test_tracking_tdating_dating(source, dry_input): pytest.importorskip("skimage") pandas = pytest.importorskip("pandas") if not dry_input: input, metadata = get_precipitation_fields(0, 2, True, True, 4000, source) input, __ = to_reflectivity(input, metadata) else: input = np.zeros((3, 50, 50)) metadata = {"timestamps": ["00", "01", "02"]} timelist = metadata["timestamps"] output = dating(input, timelist, mintrack=1) # Check output format assert isinstance(output, tuple) assert len(output) == 3 assert isinstance(output[0], list) assert isinstance(output[1], list) assert isinstance(output[2], list) assert len(output[1]) == input.shape[0] assert len(output[2]) == input.shape[0] assert isinstance(output[1][0], pandas.DataFrame) assert isinstance(output[2][0], np.ndarray) assert output[1][0].shape[1] == 8 assert output[2][0].shape == input.shape[1:] if not dry_input: assert len(output[0]) > 0 assert isinstance(output[0][0], pandas.DataFrame) assert output[0][0].shape[1] == 8 else: assert len(output[0]) == 0 assert output[1][0].shape[0] == 0 assert output[2][0].sum() == 0
time=time, ) ############################################################################### # Properties of one of the identified cells: print(cells_id.iloc[0]) ############################################################################### # Example of thunderstorm tracking over a timeseries # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # The tstorm-dating function requires the entire pre-loaded time series. # The first two timesteps are required to initialize the # flow prediction and are not used to compute tracks. track_list, cell_list, label_list = tstorm_dating.dating( input_video=Z, timelist=timelist, ) ############################################################################### # Plotting the results # ~~~~~~~~~~~~~~~~~~~~ # Plot precipitation field plot_precip_field(Z[2, :, :], geodata=metadata, units=metadata["unit"]) plt.xlabel("Swiss easting [m]") plt.ylabel("Swiss northing [m]") # Add the identified cells plot_cart_contour(cells_id.cont, geodata=metadata) # Filter the tracks to only contain cells existing in this timestep