Exemplo n.º 1
0
def plotme(out_dir, data, name):

    plt.clf()

    data_x = []
    data_y = []

    d = handle_refugee_data.DataTable("mali2012/refugees.csv",
                                      csvformat="mali-portal")

    for day in range(0, len(data["%s data" % name])):
        if d.is_interpolated(name, day) == False:
            #draw a point
            data_x.append(day)
            data_y.append(data.at[day, "%s data" % name])

    # data.loc[:,["%s sim" % name,"%s data" % name]]).as_matrix()
    y1 = data["%s sim" % name].as_matrix()
    y2 = data["%s data" % name].as_matrix()
    days = np.arange(len(y1))

    #plt.ylabel("Number of refugees")
    plt.xlabel("Days elapsed")
    #matplotlib.rc('xtick', labelsize=16)
    #matplotlib.rc('ytick', labelsize=16)

    matplotlib.rcParams.update({'font.size': 22})

    country = {
        "Bobo-Dioulasso": "(BF)",
        "Mentao": "(BF)",
        "Mbera": "(MAU)",
        "Fassala": "(MAU)",
        "Abala": "(NI)",
        "Mangaize": "(NI)",
        "Niamey": "(NI)",
        "Tabareybarey": "(NI)"
    }

    labelsim, = plt.plot(days,
                         y1,
                         linewidth=10,
                         label="%s %s simulation" %
                         (name.title(), country[name.title()]))
    labeldata, = plt.plot(days,
                          y2,
                          linewidth=10,
                          label="%s %s UNHCR data" %
                          (name.title(), country[name.title()]))
    plt.plot(data_x, data_y, 'ob')

    plt.legend(handles=[labelsim, labeldata], loc=4, prop={'size': 20})

    fig = matplotlib.pyplot.gcf()
    fig.set_size_inches(12, 8)
    #adjust margins.
    set_margins()

    fig.savefig("%s/%s.png" % (out_dir, name))
Exemplo n.º 2
0
def plotme_minimal(out_dir, data, name):
  """
  Explaining minimal graphs: populating data points to generate graphs and an example
  """

  plt.clf()

  data_x = []
  data_y = []

  d = handle_refugee_data.DataTable("mali2012/refugees.csv", csvformat="mali-portal")

  #Loop - taking the length of dataset for x and y rays
  for day in range(0, len(data["%s data" % name])):
    if d.is_interpolated(name, day) == False:
      #draw a point
      data_x.append(day)
      data_y.append(data.at[day,"%s data" % name])

  # data.loc[:,["%s sim" % name,"%s data" % name]]).as_matrix()
  y1 = data["%s sim" % name].as_matrix()
  y2 = data["%s data" % name].as_matrix()
  days = np.arange(len(y1))

  matplotlib.rcParams.update({'font.size': 18})

  max_val = max([max(y1),max(y2)])

  #Graph labels
  plt.xticks([])
  plt.yticks([2000,5000])
  plt.ylim([0, 1.1*max_val])

  #Plotting lines representing simulation results and UNHCR data
  labelsim, = plt.plot(days,y1, linewidth=10, label="%s simulation" % (name.title()))
  labeldata, = plt.plot(days,y2, linewidth=10, label="%s UNHCR data" % (name.title()))
  plt.plot(data_x,data_y,'ob')


  #Text labels
  #plt.legend(handles=[labelsim, labeldata],loc=4,prop={'size':20})
  plt.gca().legend_ = None

  plt.text(295, 0.02*plt.ylim()[1], "%s" % (name.title()), size=24, ha='right')
  #plt.text(200, 0.02*plt.ylim()[1], "Max: %s" % (max(y1)), size=24)

  #Size of plots/graphs
  fig = matplotlib.pyplot.gcf()
  fig.set_size_inches(7, 6)
  #adjust margins.
  set_margins(l=0.14,b=0.13,r=0.96,t=0.96)

  fig.savefig("%s/min-%s.png" % (out_dir, name))
Exemplo n.º 3
0
def plotme_minimal(out_dir, data, name):

    plt.clf()

    data_x = []
    data_y = []

    d = handle_refugee_data.DataTable("mali2012/refugees.csv",
                                      csvformat="mali-portal")

    for day in range(0, len(data["%s data" % name])):
        if d.is_interpolated(name, day) == False:
            #draw a point
            data_x.append(day)
            data_y.append(data.at[day, "%s data" % name])

    # data.loc[:,["%s sim" % name,"%s data" % name]]).as_matrix()
    y1 = data["%s sim" % name].as_matrix()
    y2 = data["%s data" % name].as_matrix()
    days = np.arange(len(y1))

    #plt.ylabel("Number of refugees")
    #plt.xlabel("Days elapsed")
    #matplotlib.rc('xtick', labelsize=16)
    #matplotlib.rc('ytick', labelsize=16)

    matplotlib.rcParams.update({'font.size': 28})

    country = {
        "Bobo-Dioulasso": "(BF)",
        "Mentao": "(BF)",
        "Mbera": "(MAU)",
        "Fassala": "(MAU)",
        "Abala": "(NI)",
        "Mangaize": "(NI)",
        "Niamey": "(NI)",
        "Tabareybarey": "(NI)"
    }

    max_val = max([max(y1), max(y2)])

    plt.xticks([])
    plt.yticks([2000, 5000])
    plt.ylim([0, 1.1 * max_val])

    labelsim, = plt.plot(days,
                         y1,
                         linewidth=10,
                         label="%s %s simulation" %
                         (name.title(), country[name.title()]))
    labeldata, = plt.plot(days,
                          y2,
                          linewidth=10,
                          label="%s %s UNHCR data" %
                          (name.title(), country[name.title()]))
    plt.plot(data_x, data_y, 'ob')

    #plt.legend(handles=[labelsim, labeldata],loc=4,prop={'size':20})
    plt.gca().legend_ = None

    plt.text(295,
             0.02 * plt.ylim()[1],
             "%s %s" % (name.title(), country[name.title()]),
             size=24,
             ha='right')
    #plt.text(200, 0.02*plt.ylim()[1], "Max: %s" % (max(y1)), size=24)

    fig = matplotlib.pyplot.gcf()
    fig.set_size_inches(8, 6)
    #adjust margins.
    set_margins(l=0.14, b=0.13, r=0.96, t=0.96)

    fig.savefig("%s/min-%s.png" % (out_dir, name))
Exemplo n.º 4
0
    print("Simulating Mali.")

    end_time = 80
    e = flee.Ecosystem()

    l1 = e.addLocation("A", movechance=0.3)

    l2 = e.addLocation("B", movechance=0.0)
    l3 = e.addLocation("C", movechance=0.0)
    l4 = e.addLocation("D", movechance=0.0)

    e.linkUp("A", "B", "834.0")
    e.linkUp("A", "C", "1368.0")
    e.linkUp("A", "D", "536.0")

    d = handle_refugee_data.DataTable("source-data-unhcr.txt",
                                      csvformat="mali-pdf")

    for t in range(0, end_time):
        new_refs = d.get_new_refugees(t)

        # Insert refugee agents
        for i in range(0, new_refs):
            e.addAgent(location=l1)

        # Propagate the model by one time step.
        e.evolve()

        e.printInfo()
        print(t, l1.numAgents, l2.numAgents, l3.numAgents, l4.numAgents)
        """
    l2_data = d.get_field("Mauritania", t) - d.get_field("Mauritania", 0)