In [36]:
load '/Users/jenningsanderson/Applications/epic-osm/epic-osm.rb'
require 'gnuplot'


Out[36]:
false

In [30]:
o = EpicOSM.new(analysis_window: '/Users/jenningsanderson/Desktop/cscw-osm-networks/haiti-earthquake.yml')
aw = o.analysis_window


Successfully initialized Analysis Window: CSCW 2016: Haiti Earthquake

Out[30]:
#<AnalysisWindow:0x007fa1c2033c78 @bounding_box=#<BoundingBox:0x007fa1c203ff50 @bottom_left=nil, @top_right=nil, @active=false>, @time_frame=#<TimeFrame:0x007fa1c200be08 @start_date=2010-01-11 00:00:00 -0700, @end_date=2010-01-27 15:00:00 -0700, @active=true>, @max_area=1000000000000, @min_area=1, @title="CSCW 2016: Haiti Earthquake", @changeset_tags=nil>

In [33]:
c = aw.changesets_x_all; nil

In [35]:
c_set_users = c.first[:objects].group_by{|c_set| c_set.uid}
c_set_counts = c_set_users.collect{|uid, c_sets| {uid: uid, count: c_sets.length}}; nil

In [39]:
total_c_set_users = c_set_counts.length.to_f


Out[39]:
445.0

In [28]:
[counts.collect{|c| c[:count]}.sort]


NameError: undefined local variable or method `counts' for main:Object
<main>:in `<main>'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/backend.rb:8:in `eval'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/backend.rb:8:in `eval'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/kernel.rb:110:in `execute_request'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/kernel.rb:62:in `run'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/command.rb:30:in `run_kernel'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/lib/iruby/command.rb:16:in `run'
/usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/iruby-0.1.13/bin/iruby:6:in `<top (required)>'
/usr/local/var/rbenv/versions/2.0.0-p247/bin/iruby:23:in `load'
/usr/local/var/rbenv/versions/2.0.0-p247/bin/iruby:23:in `<main>'

In [26]:
Gnuplot::Plot.new do |plot|  
  plot.xrange '[0:counts.length]'
  plot.yrange '[0:462]'
  plot.title  'Changeset Count Distribution'
  plot.ylabel 'Number of Changesets'
  plot.xlabel 'irrelevant'
#   plot.logscale 'y'

  plot.data << Gnuplot::DataSet.new( [counts.collect{|c| c[:count]}.sort] ) do |ds|
    ds.with = "linespoints"
    ds.notitle
  end

#   plot.data << Gnuplot::DataSet.new( [$osm_areas.sort] ) do |ds|
#     ds.with = "linespoints"
#     ds.notitle
#   end
end


Out[26]:
Gnuplot Produced by GNUPLOT 5.0 patchlevel 0 0 50 100 150 200 250 300 350 400 450 0 50 100 150 200 250 300 350 400 450 Number of Changesets irrelevant Changeset Count Distribution gnuplot_plot_1

In [19]:
require 'json'
File.write('/data/areas.json', {osm_areas: $osm_areas, our_areas: $our_areas}.to_json)


Out[19]:
96965

In [3]:
require 'json'


Out[3]:
false

In [12]:
n_counts = JSON.parse(File.read('output.json'))
n_counts.collect{|c| c["count"]}.sort


Out[12]:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 14, 15, 15, 15, 17, 18, 19, 20, 20, 20, 22, 22, 23, 23, 24, 24, 24, 24, 25, 26, 26, 27, 27, 29, 30, 30, 32, 33, 33, 35, 35, 36, 36, 38, 38, 38, 39, 41, 43, 44, 45, 46, 46, 46, 47, 47, 47, 48, 49, 50, 50, 50, 50, 51, 51, 51, 52, 52, 52, 53, 56, 57, 58, 59, 62, 63, 63, 64, 65, 65, 66, 69, 70, 74, 75, 76, 80, 81, 83, 84, 84, 89, 90, 92, 92, 93, 94, 97, 98, 99, 99, 99, 100, 101, 106, 108, 111, 112, 116, 119, 121, 122, 122, 123, 126, 128, 128, 128, 133, 139, 139, 140, 142, 142, 147, 147, 150, 159, 161, 162, 162, 173, 174, 176, 182, 185, 185, 191, 202, 207, 214, 216, 220, 226, 233, 236, 242, 243, 252, 255, 259, 262, 275, 278, 280, 285, 286, 294, 295, 304, 320, 328, 329, 329, 329, 335, 336, 337, 339, 349, 350, 363, 372, 376, 377, 380, 383, 386, 392, 401, 406, 407, 408, 411, 417, 418, 429, 431, 439, 457, 459, 465, 467, 497, 506, 512, 516, 517, 526, 528, 537, 574, 589, 608, 617, 627, 634, 647, 714, 729, 729, 732, 732, 736, 739, 740, 744, 766, 786, 791, 822, 838, 847, 883, 888, 911, 914, 920, 927, 955, 962, 979, 989, 1001, 1006, 1033, 1046, 1047, 1049, 1088, 1098, 1128, 1195, 1211, 1252, 1260, 1288, 1317, 1337, 1372, 1376, 1380, 1419, 1473, 1474, 1484, 1490, 1554, 1573, 1641, 1715, 1734, 1851, 1897, 1980, 2016, 2076, 2121, 2148, 2162, 2217, 2227, 2262, 2313, 2320, 2331, 2338, 2372, 2382, 2463, 2501, 2653, 2691, 2693, 2807, 2882, 2892, 2970, 3096, 3101, 3145, 3167, 3280, 3384, 3514, 3558, 3639, 3859, 3914, 4006, 4022, 4133, 4330, 4345, 4522, 4582, 4744, 4779, 4825, 4962, 4965, 5360, 5842, 5988, 6037, 6309, 6726, 6932, 7059, 7085, 7255, 7265, 7467, 7728, 8446, 8629, 8709, 8952, 9240, 9402, 9407, 9806, 10331, 11254, 11292, 13429, 15268, 16100, 17725, 18669, 20044, 20132, 27445, 28157, 28914, 28914, 29508, 29925, 30010, 33925, 34659, 34702, 46497]

In [13]:
Gnuplot::Plot.new do |plot|  
  plot.xrange '[0:n_counts.length]'
  plot.yrange '[0:n_counts.collect{|c| c[:count]}.max]'
  plot.title  'Node Edit Distribution'
  plot.ylabel 'Number of Nodes Edited'
  plot.xlabel 'irrelevant'
#   plot.logscale 'y'

  plot.data << Gnuplot::DataSet.new( [n_counts.collect{|c| c["count"]}.sort] ) do |ds|
    ds.with = "linespoints"
    ds.notitle
  end

#   plot.data << Gnuplot::DataSet.new( [$osm_areas.sort] ) do |ds|
#     ds.with = "linespoints"
#     ds.notitle
#   end
end


Out[13]:
Gnuplot Produced by GNUPLOT 5.0 patchlevel 0 0 5000 10000 15000 20000 25000 30000 35000 40000 45000 50000 0 50 100 150 200 250 300 350 400 450 Number of Nodes Edited irrelevant Node Edit Distribution gnuplot_plot_1

In [47]:
puts "Over 1000: #{n_counts.select{|x| x["count"] >= 1000}.count/ total_c_set_users*100} Percent"
puts "Between 10 - 1000: #{n_counts.select{|x| x["count"] >= 10 and x["count"] < 1000}.count/ total_c_set_users*100} Percent"
puts "Under 10: #{n_counts.select{|x| x["count"] < 10}.count/ total_c_set_users*100} Percent"


Over 1000: 26.96629213483146 Percent
Between 10 - 1000: 54.157303370786515 Percent
Under 10: 13.03370786516854 Percent

In [48]:
new_node_counts = JSON.parse(File.read('new_node_counts.json'));nil

In [49]:
puts "Over 1000: #{new_node_counts.select{|x| x["count"] >= 1000}.count/ total_c_set_users*100} Percent"
puts "Between 10 - 1000: #{new_node_counts.select{|x| x["count"] >= 10 and x["count"] < 1000}.count/ total_c_set_users*100} Percent"
puts "Under 10: #{new_node_counts.select{|x| x["count"] < 10}.count/ total_c_set_users*100} Percent"


Over 1000: 23.595505617977526 Percent
Between 10 - 1000: 46.06741573033708 Percent
Under 10: 9.213483146067416 Percent

In [ ]: