In [14]:
%pylab inline
In [15]:
import json
from collections import OrderedDict
from copy import deepcopy
import urllib2
In [54]:
probes = []
probes_by_id = {}
for l in open('meta-20150223.txt').readlines():
probes.append(json.loads(l))
probes_by_id[probes[-1]['id']] = probes[-1]
In [59]:
stats_country = OrderedDict()
for p in probes:
cc = p['country_code']
stats_country[cc] = stats_country.get(cc, 0)+1
stats_country = OrderedDict(sorted(stats_country.items(), key=lambda t: t[1], reverse=True))
stats_country_reduced = deepcopy(stats_country)
while len(stats_country_reduced) > 100:
stats_country_reduced.popitem()
In [61]:
figure(figsize=(25,4))
bar(np.arange(len(stats_country_reduced)), stats_country_reduced.values())
devnull = xticks(np.arange(0.5,len(stats_country_reduced)+0.5), stats_country_reduced.keys(), horizontalalignment='center', rotation=90)
#yscale('log')
title('Probe numbers by country')
ylabel('#probes')
xlabel('country code')
grid(axis='y')
savefig('probes-per-country.png')
In [37]:
probes = []
data = json.loads(urllib2.urlopen('https://atlas.ripe.net/api/v1/measurement/1911027/result/').read())
probes = [probes_by_id[p['prb_id']] for p in data if p['prb_id'] in probes_by_id]
In [38]:
stats_country = OrderedDict()
for p in probes:
cc = p['country_code']
stats_country[cc] = stats_country.get(cc, 0)+1
stats_country = OrderedDict(sorted(stats_country.items(), key=lambda t: t[1], reverse=True))
stats_country_reduced = deepcopy(stats_country)
while len(stats_country_reduced) > 120:
stats_country_reduced.popitem()
In [47]:
figure(figsize=(25,4))
bar(np.arange(len(stats_country)), stats_country.values())
devnull = xticks(np.arange(0.5,len(stats_country)+0.5), stats_country.keys(), horizontalalignment='center', rotation=90)
#yscale('log')
title('Probe numbers by country (WW500)')
ylabel('#probes')
xlabel('country code')
grid(axis='y')
savefig('WW500-probes-per-country.png')
In [40]:
probes_in_result = []
data = json.loads(urllib2.urlopen('https://atlas.ripe.net/api/v1/measurement/1911024/result/').read())
probes_in_result = [probes_by_id[p['prb_id']] for p in data]
In [41]:
stats_country_result = OrderedDict()
for p in probes_in_result:
cc = p['country_code']
stats_country_result[cc] = stats_country_result.get(cc, 0)+1
stats_country_result = OrderedDict(sorted(stats_country_result.items(), key=lambda t: t[1], reverse=True))
In [46]:
figure(figsize=(25,4))
bar(np.arange(len(stats_country_result)), stats_country_result.values())
devnull = xticks(np.arange(0.5,len(stats_country_result)+0.5), stats_country_result.keys(), horizontalalignment='center', rotation=90)
#yscale('log')
title('Probe numbers by country in result (SB500)')
ylabel('#probes')
xlabel('country code')
grid(axis='y')
savefig('SB500-probes-per-country.png')
In [49]:
probes_in_result = []
data = json.loads(urllib2.urlopen('https://atlas.ripe.net/api/v1/measurement/1911261/result/').read())
probes_in_result = [probes_by_id[p['prb_id']] for p in data if p['prb_id'] in probes_by_id]
In [50]:
stats_country_result = OrderedDict()
for p in probes_in_result:
cc = p['country_code']
stats_country_result[cc] = stats_country_result.get(cc, 0)+1
stats_country_result = OrderedDict(sorted(stats_country_result.items(), key=lambda t: t[1], reverse=True))
In [62]:
figure(figsize=(25,4))
bar(np.arange(len(stats_country_result)), stats_country_result.values())
devnull = xticks(np.arange(0.5,len(stats_country_result)+0.5), stats_country_result.keys(), horizontalalignment='center', rotation=90)
#yscale('log')
title('Probe numbers by country in result (SB480 in NL,DE)')
ylabel('#probes')
xlabel('country code')
grid(axis='y')
savefig('SB500-probes-per-country.png')
In [ ]: