实时动态扫描数据流

本文探讨了如何实现实时动态扫描数据流的技术,涵盖了关键的处理算法、流处理平台的选择及其在大数据分析中的应用。通过对数据的快速捕获和分析,实现高效的数据洞察,助力业务决策。
摘要由CSDN通过智能技术生成
import datetime
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.dates as mdates
plt.rcParams["font.sans-serif"]=['SimHei']
hour = 10
step = 60
second = int(float(hour)*60*60)
now = datetime.datetime.now()
MeanValue, SumValue, MeanIndex = 0, 0, 0
delta = datetime.timedelta(seconds=60)
xmin = now - delta
ymax = 0
plt.ion()
plt.figure(1)
ax = plt.subplot(111)
Meanline = []
for i in range(0, second, step):
    m = (1500 - 100 + 200 * np.random.random())/380
    if ymax < m:
        ymax = m
    now += delta
    SumValue += m
    xmax = now
    MeanValue = SumValue/(MeanIndex + 1)
    MeanIndex += 1
    if i == 0:
        x = [now - delta, now]
        y = [m-1, m]
        plt.plot(x, y, "-")
    else:
        x.pop(0)
        x.append(now)
        y.pop(0)
        y.append(m)
        plt.plot(x, y, "-")
    if (xmax - xmin) > datetime.timedelta(hours=1):
        xmin = xmax - datetime.timedelta(hours=1)
    plt.xlim(xmin, xmax)
    plt.ylim(0, 1.5*ymax)
    ax1 = plt.axhline(y=MeanValue, color="b", linewidth=1, linestyle="--")
    Meanline.append(ax1)
    if i > 1:
        Meanline[0].remove()
        Meanline.pop(0)

    plt.xticks(rotation=50)
    ax.xaxis.set_major_formatter(mdates.DateFormatter("%m-%d %H:%M:%S"))
    plt.pause(1)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值