# rounding up the timestamp to 1 second for batch process
adsb0.loc[:, "tsr"] = adsb0.ts.round().astype(int)
ehs0.loc[:, "tsr"] = ehs0.ts.round().astype(int)

ts0 = int(adsb0.tsr.min())
ts1 = int(adsb0.tsr.max())

for t in range(ts0, ts0 + 100):

    adsb = adsb0[adsb0.tsr == t]
    ehs = ehs0[ehs0.tsr == t]

    stream.process_raw(adsb.ts.tolist(),
                       adsb.msg.tolist(),
                       ehs.ts.tolist(),
                       ehs.msg.tolist(),
                       tnow=t)

    # compute_current_weather() and update_mp_model() must be run in following sequence
    wd = stream.compute_current_weather()  # weather data also returned
    stream.update_mp_model()

    print("time: %d | n_ptc: %d" % (t - ts0, len(stream.mp.PTC_X)))

# take an example snapshot
stream.mp.save_snapshot(t)

# construct example grid when finish
data = stream.mp.construct()