Exemplo n.º 1
0

sp.savetxt(get_path(folder, "stats-%s.csv" %n),
           message_stats,
           delimiter=",", fmt="%8s", comments='',
           header="Node,transmit,transmit_failed_power,"
                  "received,received_failed_power,"
                  "received_failed_loss")


# plotting results
#print len(snr_base)
lqi_base = 6 * np.array(snr_base) + 538
#print lqi_base
plotter.plots(np.arange(len(snr_base[1:])), snr_base[1:],
              get_path(folder, "SNR_Base_Station-%s" % n),
              title="SNR levels",format='png',
              xlabel="Packet Number", ylabel="SNR")

plotter.plots(np.arange(len(snr_base[1:])), lqi_base[1:],
              get_path(folder, "LQI_Base_Station-%s" % n),
              title="LQI's",format='png',
              xlabel="Packet Number", ylabel="LQI")
plotter.plot_bars(np.arange(1, n+1), consume,
                  get_path(folder, "energy consumption-", prefix=n),
                  ymax=1.1*max(consume),
                  ymin=0.9*min(consume),format='png',
                  title="Energy Consumption (%s nodes)" % n,
                  xlabel="Nodes", ylabel="mJ")

plotter.plot_bars(np.arange(1, n+1), loss,
                  get_path(folder, "Loss Packets-", prefix=n),
Exemplo n.º 2
0
               message_stats,
               delimiter=",",
               fmt="%8s",
               comments='',
               header="Node,transmit,transmit_failed_power,"
               "received,received_failed_power,"
               "received_failed_loss")

    # plotting results
    #print len(snr_base)
    lqi_base = 6 * np.array(snr_base) + 538
    #print lqi_base
    plotter.plots(np.arange(len(snr_base[1:])),
                  snr_base[1:],
                  get_path(folder, "SNR_Base_Station-%s" % n),
                  title=net.name + "\nSNR levels (Base Station)",
                  format='png',
                  xlabel="Packet Number",
                  ylabel="SNR")

    #    plotter.plots(np.arange(len(snr_base[1:])), lqi_base[1:],
    #                  get_path(folder, "LQI_Base_Station-%s" % n),
    #                  title="LQI's", format='png',
    #                  xlabel="Packet Number", ylabel="LQI")

    plotter.plot_bars(np.arange(1, n + 1),
                      consume,
                      get_path(folder, "Energy Consumption-", prefix=n),
                      ymax=1.1 * max(consume),
                      ymin=0.9 * min(consume),
                      title=net.name + "\nEnergy Consumption (%s nodes)" % n,
sp.savetxt(get_path(folder, "%s-%s.csv" % (experiment, filename)),
           loc_err,
           delimiter=",",
           fmt="%8.2f",
           comments='',
           header=vary_name +
           '    Anc%    Localized   Not    runtime  |err>R|  '
           'avg_err  max_err  std_err  TX      Rx       SNR     Energy',
           footer=net.name + "\n" + comments)

plotter.plots(vary_range, [e[4] * k for e in loc_err],
              get_path(folder, experiment + " " + filename),
              more_plots=[[e[6] * k for e in loc_err], [e[9] for e in loc_err],
                          [e[10] for e in loc_err], [e[12] for e in loc_err]],
              labels=[
                  "Runtime", "$f_1$ - Avg. Loc. Error", "$f_2$ - No. of Tx",
                  "Rx", "Energy"
              ],
              title=experiment + "\n" + filename,
              xlabel=vary_name,
              ylabel="",
              format='pdf')

plotter.gethtmlLine(
    vary_range, [[e[4] for e in loc_err], [e[6] for e in loc_err],
                 [e[9] for e in loc_err], [e[12] for e in loc_err]],
    fname=experiment + " " + filename,
    folder=folder,
    xlabel=vary_name,
    ylabel="",
    labels=['Runtime', 'Avg. Local. Error', 'No. of Tx', 'Energy'],
    title=experiment + "<br>" + filename,
Exemplo n.º 4
0
    if len(recovered_nodes) > 1:
        #print recovered_nodes
        sp.savetxt(get_path(DATETIME_DIR, "energy_level-%s.csv" % n),
                   zip(recovered_nodes[0][1], recovered_nodes[1][1]),
                   header="%s\t%s" %
                   (recovered_nodes[0][0], recovered_nodes[1][0]),
                   delimiter="\t",
                   fmt="%s",
                   comments='')
        plotter.plots(np.arange(len(recovered_nodes[0][1])),
                      recovered_nodes[0][1],
                      get_path(DATETIME_DIR, "energy_level-%s" % n),
                      more_plots=[recovered_nodes[1][1]],
                      title="Energy Level change",
                      xlabel="Time",
                      ylabel="Energy (Joules)",
                      labels=[
                          "Node %s" % recovered_nodes[0][0],
                          "Node %s" % recovered_nodes[1][0]
                      ])

    # plotting results
    #print len(snr_base)
    lqi_base = 6 * np.array(snr_base) + 538
    #print lqi_base
    plotter.plots(np.arange(len(snr_base[1:])),
                  snr_base[1:],
                  get_path(DATETIME_DIR, "SNR_Base_Station-%s" % n),
                  title="SNR levels",
                  xlabel="Time",
Exemplo n.º 5
0
    k=0
    err_sum=0.0
    for node in net.nodes():
            if node.type == 'N' and 'pos' in node.memory:
                act = node.get_dic()['Info']['position']
                est = node.memory['pos']
                err = sqrt(sum(pow(act - est, 2)))
                print node.id, node.type, act, est, err
                err_sum += err
                k += 1

    print ("%s nodes localized, Avg error: %s m" % (k, err_sum))
    sim.reset()
'''

'''
    for nd in net.nodes():
        print nd.id, "Registrations: %s" % nd.memory.get("Registration", []), \
            "\n\rData: %s" % nd.memory, \
            "\n\rEnergy: %s" % nd.power.energy_consumption

        t_transmit += nd.n_transmitted
        t_transmit_failed += nd.n_transmitted_failed_power

        message_stats.append((nd.id, nd.n_transmitted,
                              nd.n_transmitted_failed_power,
                              nd.n_received,
                              nd.n_received_failed_power,
                              nd.n_received_failed_loss
                              ))
        consume.append(nd.power.energy_consumption * 1000.0)
Exemplo n.º 6
0
print "mean=" + str(np.mean(message_stats, axis=0))

print "Position max=" + str(np.amax(position_stats, axis=0))

try:
    X2 = np.sort([col[3] / comm_range for col in position_stats])
    F2 = np.array(range(k)) / float(k)
    H, X1 = np.histogram([col[3] for col in position_stats],
                         bins=20,
                         normed=True)
    dx = X1[1] - X1[0]
    F1 = np.cumsum(H) * dx
    print X2.__len__(), F2.__len__(), F1.__len__()
    plotter.plots(X1[1:] / comm_range,
                  F1,
                  get_path(DATETIME_DIR, "Error CDF-%d" % nn),
                  title="CDF-" + net.name,
                  xlabel="Normalized Localization error",
                  ylabel="CDF")

    plotter.plots(X2,
                  F2,
                  get_path(DATETIME_DIR, "Error CDF2-%d" % nn),
                  title="CDF-" + net.name,
                  xlabel="Normalized Localization error",
                  ylabel="CDF")

except Exception as exc:
    print exc
    pass

sim.reset()
Exemplo n.º 7
0
    #                 plot_options=["color: 'red',", "color: 'blue',", "type: 'areaspline', color: 'grey', visible: false,"])

    sr += 1

print loc_err
sp.savetxt(get_path(folder, "%s-%s.csv" % (experiment, filename)),
           loc_err,
           delimiter=",", fmt="%8.2f", comments='',
           header=vary_name + '    Anc%    Localized   Not    runtime  |err>R|  '
                              'avg_err  max_err  std_err  TX      Rx       SNR     Energy',
           footer=net.name + "\n" + comments)

plotter.plots(vary_range, [e[4] * k for e in loc_err],
              get_path(folder, experiment + " " + filename),
              more_plots=[[e[6] * k for e in loc_err],
                          [e[9] for e in loc_err],
                          [e[10] for e in loc_err],
                          [e[12] for e in loc_err]],
              labels=["Runtime", "$f_1$ - Avg. Loc. Error", "$f_2$ - No. of Tx", "Rx", "Energy"],
              title=experiment + "\n" + filename,
              xlabel=vary_name, ylabel="", format='pdf')

plotter.gethtmlLine(vary_range, [[e[4] for e in loc_err],
                                 [e[6] for e in loc_err],
                                 [e[9] for e in loc_err],
                                 [e[12] for e in loc_err]],
                    fname=experiment + " " + filename, folder=folder,
                    xlabel=vary_name, ylabel="", labels=['Runtime', 'Avg. Local. Error', 'No. of Tx', 'Energy'],
                    title=experiment + "<br>" + filename, open=1,
                    plot_options=["color: 'cyan',", "color: 'blue',", "color: 'red',", "color: 'green',"])
Exemplo n.º 8
0
    if len(recovered_nodes) > 1:
        #print recovered_nodes
        sp.savetxt(get_path(DATETIME_DIR, "energy_level-%s.csv" % n),
                   zip(recovered_nodes[0][1], recovered_nodes[1][1]),
                   header="%s\t%s" %
                   (recovered_nodes[0][0], recovered_nodes[1][0]),
                   delimiter="\t",
                   fmt="%s",
                   comments='')
        plotter.plots(np.arange(len(recovered_nodes[0][1])),
                      recovered_nodes[0][1],
                      get_path(DATETIME_DIR, "energy_level-%s" % n),
                      more_plots=[recovered_nodes[1][1]],
                      title="Energy Level change",
                      xlabel="Time",
                      ylabel="Energy (Joules)",
                      labels=[
                          "Node %s" % recovered_nodes[0][0],
                          "Node %s" % recovered_nodes[1][0]
                      ])

    # plotting results
    plotter.plot_bars(np.arange(1, n + 1)[1:],
                      consume[1:],
                      get_path(DATETIME_DIR, "energy consumption-", prefix=n),
                      ymax=1.1 * max(consume[1:]),
                      ymin=0.9 * min(consume[1:]),
                      title="Energy Consumption (%s nodes)" % n,
                      xlabel="Nodes",
                      ylabel="mJ")
Exemplo n.º 9
0
          net.nodes()[0].memory['tp']
    k=0
    err_sum=0.0
    for node in net.nodes():
            if node.type == 'N' and 'pos' in node.memory:
                act = node.get_dic()['Info']['position']
                est = node.memory['pos']
                err = sqrt(sum(pow(act - est, 2)))
                print node.id, node.type, act, est, err
                err_sum += err
                k += 1

    print ("%s nodes localized, Avg error: %s m" % (k, err_sum))
    sim.reset()
'''
'''
    for nd in net.nodes():
        print nd.id, "Registrations: %s" % nd.memory.get("Registration", []), \
            "\n\rData: %s" % nd.memory, \
            "\n\rEnergy: %s" % nd.power.energy_consumption

        t_transmit += nd.n_transmitted
        t_transmit_failed += nd.n_transmitted_failed_power

        message_stats.append((nd.id, nd.n_transmitted,
                              nd.n_transmitted_failed_power,
                              nd.n_received,
                              nd.n_received_failed_power,
                              nd.n_received_failed_loss
                              ))
        consume.append(nd.power.energy_consumption * 1000.0)
Exemplo n.º 10
0

    sp.savetxt(get_path(folder, "stats-%s.csv" %n),
               message_stats,
               delimiter=",", fmt="%8s", comments='',
               header="Node,transmit,transmit_failed_power,"
                      "received,received_failed_power,"
                      "received_failed_loss")


    # plotting results
    #print len(snr_base)
    lqi_base = 6 * np.array(snr_base) + 538
    #print lqi_base
    plotter.plots(np.arange(len(snr_base[1:])), snr_base[1:],
                  get_path(folder, "SNR_Base_Station-%s" % n),
                  title="SNR levels (Base Station)",format='png',
                  xlabel="Packet Number", ylabel="SNR")

#    plotter.plots(np.arange(len(snr_base[1:])), lqi_base[1:],
#                  get_path(folder, "LQI_Base_Station-%s" % n),
#                  title="LQI's", format='png',
#                  xlabel="Packet Number", ylabel="LQI")

    plotter.plot_bars(np.arange(1, n+1), consume,
                      get_path(folder, "Energy Consumption-", prefix=n),
                      ymax=1.1*max(consume),
                      ymin=0.9*min(consume),
                      title="Energy Consumption (%s nodes)" % n,
                      xlabel="Nodes", ylabel="mJ", format='png')

    plotter.plot_bars(np.arange(1, n+1), loss,
Exemplo n.º 11
0
print ("%s nodes localized, %s" % (k, comments))
print "max=" + str(np.amax(message_stats, axis=0))
print "std=" + str(np.std(message_stats, axis=0))
print "mean=" + str(np.mean(message_stats, axis=0))

print "Position max=" + str(np.amax(position_stats, axis=0))

try:
    X2 = np.sort([col[3]/comm_range for col in position_stats])
    F2 = np.array(range(k))/float(k)
    H, X1 = np.histogram([col[3] for col in position_stats], bins=20, normed=True)
    dx = X1[1] - X1[0]
    F1 = np.cumsum(H)*dx
    print X2.__len__(), F2.__len__(), F1.__len__()
    plotter.plots(X1[1:]/comm_range,F1,get_path(DATETIME_DIR, "Error CDF-%d" % nn),
                  title="CDF-"+net.name, xlabel="Normalized Localization error",
                  ylabel="CDF")

    plotter.plots(X2,F2,get_path(DATETIME_DIR, "Error CDF2-%d" % nn),
                  title="CDF-"+net.name, xlabel="Normalized Localization error",
                  ylabel="CDF")

except Exception as exc:
    print exc
    pass

sim.reset()

# Create CSV, plots and interactive html/JS charts based on collected data
# np.savetxt(get_path(DATETIME_DIR, "message_stats-%s.csv" % nn),
#            message_stats,
Exemplo n.º 12
0
    sp.savetxt(get_path(DATETIME_DIR, "distances-%s.csv" %n),
               distances,
               delimiter="\t", fmt="%7.1f", comments='',
               header="Node\tdistance(m)\tdbm\tdisplacement")

    if len(recovered_nodes) > 1:
        #print recovered_nodes
        sp.savetxt(get_path(DATETIME_DIR, "energy_level-%s.csv" % n),
               zip(recovered_nodes[0][1], recovered_nodes[1][1]),
               header="%s\t%s" %(recovered_nodes[0][0],
                                 recovered_nodes[1][0]),
               delimiter="\t", fmt="%s", comments='')
        plotter.plots(np.arange(len(recovered_nodes[0][1])),
                      recovered_nodes[0][1],
              get_path(DATETIME_DIR, "energy_level-%s" % n),
              more_plots=[recovered_nodes[1][1]],
              title="Energy Level change",
              xlabel="Time", ylabel="Energy (Joules)",
              labels=["Node %s" % recovered_nodes[0][0],
                      "Node %s" % recovered_nodes[1][0]])

    # plotting results
    plotter.plot_bars(np.arange(1, n+1)[1:], consume[1:],
                  get_path(DATETIME_DIR, "energy consumption-", prefix=n),
                  ymax=1.1*max(consume[1:]),
                  ymin=0.9*min(consume[1:]),
                  title="Energy Consumption (%s nodes)" %n,
                  xlabel="Nodes", ylabel="mJ")

    plotter.plot_bars(np.arange(1, n+1), displacement,
                  get_path(DATETIME_DIR, "Node movement-", prefix=n),
                  ymax=1.05*max(displacement),
Exemplo n.º 13
0
print("Execution time:  %s seconds ---" % round(end_time,2) )
print net_gen.name
sp.savetxt(get_path(folder, "Energy Consumption.csv"),
           n_power,
           delimiter="\t", fmt="%s",
           header="Nodes\tEnergy(m^2)\tefficeincy",
           comments='')

# plotter.plots(n_range, [e[1]/10e6 for e in n_power],
#               get_path(folder, "Energy"),
#               title="Energy Consumption",
#               more_plots=[[e[3]/10e6 for e in n_power], [e[6]/10e6 for e in n_power]],
#               labels=["Edat","Ereq(0.2)","Ereq(0.8)"],
#               xlabel="Number of nodes", ylabel="Energy ($10^6 m^2$)")

print np.array(list(energy[0,:]))
print n_range
plotter.plots(n_range, np.array(energy[0,:]/1e6),
              get_path(folder, "Energy"),
              title="Energy Consumption",
              more_plots=[np.array(energy[1,:])/1e6],
              labels=["Edat (new EM)","Edat (EM)"],
              xlabel="Number of nodes", ylabel="Energy ($10^6 m^2$)")

plotter.plots(n_range, np.array(eff[0,:]/1e-4),
              get_path(folder, "Efficiency"),
              more_plots=[np.array(eff[1,:])/1e-4],
              title="Efficiency",
              labels=["Efficeincy (new EM)","Efficeincy (EM)"],
              xlabel="Number of Nodes", ylabel="Efficiency ($10^{-4}$)")