def locs_metrics(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outfile = ctx.obj['outfile'] lm = LocsMetrics(db) lm.generate(outfile)
def photodensity(ctx): config = ctx.obj['config'] db = DB(ctx.obj['dbname'], config) db.open() pd = PhotoDensity(db) pd.generate() db.close()
def usermetrics(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() um = UserMetrics(db) um.generate() db.close()
def fix_locations(ctx): click.echo('Fixing locations') config = ctx.obj['config'] db = DB(ctx.obj['dbname'], config) db.open() fixer = FixLocations(db) fixer.run() db.close()
def retrieve(ctx): click.echo('Retrieving Instagram data') config = ctx.obj['config'] db = DB(ctx.obj['dbname'], config) db.open() retriever = Retriever(config, db) retriever.run() db.close()
def clean_locations(ctx): click.echo('Cleaning location data') db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) locs.clean() db.close() click.echo('done.')
def areas(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() infile = ctx.obj['infile'] smooth = ctx.obj['smooth'] ar = Areas(db, infile, smooth) ar.compute()
def usersamples(ctx): dbname = ctx.obj['dbname'] infile = ctx.obj['infile'] db = DB(dbname, ctx.obj['config']) db.open() us = UserSamples(db, dbname, infile) us.generate() db.close()
def json_export(ctx): dbname = ctx.obj['dbname'] outfile = ctx.obj['outfile'] db = DB(dbname, ctx.obj['config']) db.open() je = JsonExport(db, outfile) je.export() db.close()
def gen_graph(ctx): dbname = ctx.obj['dbname'] outfile = ctx.obj['outfile'] table = ctx.obj['table'] db = DB(dbname, ctx.obj['config']) db.open() gg = GenGraph(db, outfile, table) gg.generate() db.close()
def crop_rectangle(ctx): min_lat = float(ctx.obj['min_lat']) min_lng = float(ctx.obj['min_lng']) max_lat = float(ctx.obj['max_lat']) max_lng = float(ctx.obj['max_lng']) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() ghostb.cropdata.crop_rectangle(db, min_lat, min_lng, max_lat, max_lng) db.close()
def add_locations(ctx): country_code = ctx.obj['country_code'] click.echo('Adding locations for %s' % country_code) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) (points, inserted) = locs.add_locations(ctx.obj['locs_file'], country_code) db.close() click.echo('%d points found, %d points added.' % (points, inserted))
def dists(ctx): dbname = ctx.obj['dbname'] infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] db = DB(dbname, ctx.obj['config']) db.open() g = ghostb.graph.read_graph(infile) ghostb.graph.write_dists(g, db, outfile) db.close()
def distances(ctx): dbname = ctx.obj['dbname'] infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] db = DB(dbname, ctx.obj['config']) db.open() dist = Distances(db) dist.compute(infile, outfile) db.close()
def import_locations(ctx): infile = ctx.obj['infile'] click.echo('Importing locations from %s' % infile) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) (points, inserted) = locs.import_locations(infile) db.close() click.echo('%d points found, %d points added.' % (points, inserted))
def dist_sequence(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] intervals = int(ctx.obj['intervals']) smooth = ctx.obj['smooth'] scales = Scales(outdir, intervals) scales.dist_sequence(db, smooth)
def scales_usermetrics(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] intervals = int(ctx.obj['intervals']) scale_membership = ctx.obj['scale_membership'] s = Scales(outdir, intervals) s.usermetrics(db, scale_membership)
def add_region_grid(ctx): region = ctx.obj['region'] rows = int(ctx.obj['rows']) cols = int(ctx.obj['cols']) click.echo('Adding grid of locations for region: %s' % region) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) locs.add_region_grid(region, rows, cols) db.close()
def borders(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() indir = ctx.obj['indir'] infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] smooth = ctx.obj['smooth'] bs = Borders(db, smooth) bs.process(indir, infile, outfile)
def filter_dists(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] max_dist = float(ctx.obj['max_dist']) fd = FilterDists(db) fd.filter(infile, outfile, max_dist) db.close()
def replace_low_degree(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] min_degree = float(ctx.obj['min_degree']) rld = ReplaceLowDegree(db, infile, min_degree) rld.run(outfile) db.close()
def similarity_matrix(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] intervals = int(ctx.obj['intervals']) smooth = ctx.obj['smooth'] optimize = ctx.obj['optimize'] scales = Scales(outdir, intervals) scales.similarity_matrix(db, smooth, optimize)
def scales_graphs(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] intervals = int(ctx.obj['intervals']) scale = ctx.obj['scale'] table = ctx.obj['table'] scales = Scales(outdir, intervals) scales.generate_graphs(db, scale, table)
def scales_borders(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] best = ctx.obj['best'] smooth = ctx.obj['smooth'] intervals = int(ctx.obj['intervals']) scales = Scales(outdir, intervals) scales.generate_borders(db, best, smooth)
def userscales(ctx): dbname = ctx.obj['dbname'] infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] scales = ctx.obj['scales'] table = ctx.obj['table'] db = DB(dbname, ctx.obj['config']) db.open() us = UserScales(db, outfile, infile, scales, table) us.generate() db.close()
def cropgraph(ctx): infile = ctx.obj['infile'] outfile = ctx.obj['outfile'] min_lat = float(ctx.obj['min_lat']) min_lng = float(ctx.obj['min_lng']) max_lat = float(ctx.obj['max_lat']) max_lng = float(ctx.obj['max_lng']) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() cg = CropGraph(db) cg.crop(infile, outfile, min_lat, min_lng, max_lat, max_lng) db.close()
def scales_multi_borders(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] outfile = ctx.obj['outfile'] smooth = ctx.obj['smooth'] intervals = int(ctx.obj['intervals']) scales = ctx.obj['scales'] s = Scales(outdir, intervals) s.generate_multi_borders(db, outfile, smooth, scales)
def scales_metric(ctx): dbname = ctx.obj['dbname'] db = DB(dbname, ctx.obj['config']) db.open() outdir = ctx.obj['outdir'] best = ctx.obj['best'] intervals = int(ctx.obj['intervals']) smooth = ctx.obj['smooth'] scale = ctx.obj['scale'] metric = ctx.obj['metric'] scales = Scales(outdir, intervals) scales.metric(metric, db, best, smooth, scale)
def add_area(ctx): min_lat = float(ctx.obj['min_lat']) min_lng = float(ctx.obj['min_lng']) max_lat = float(ctx.obj['max_lat']) max_lng = float(ctx.obj['max_lng']) click.echo('Adding locations in area: [%s, %s, %s, %s]' % (min_lat, min_lng, max_lat, max_lng)) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) (points, inserted) = locs.add_area(ctx.obj['locs_file'], min_lat, min_lng, max_lat, max_lng) db.close() click.echo('%d points found, %d points added.' % (points, inserted))
def add_grid(ctx): min_lat = float(ctx.obj['min_lat']) min_lng = float(ctx.obj['min_lng']) max_lat = float(ctx.obj['max_lat']) max_lng = float(ctx.obj['max_lng']) rows = int(ctx.obj['rows']) cols = int(ctx.obj['cols']) click.echo('Adding grid of locations for area: [%s, %s, %s, %s]' % (min_lat, min_lng, max_lat, max_lng)) db = DB(ctx.obj['dbname'], ctx.obj['config']) db.open() locs = Locations(db) locs.add_grid(min_lat, min_lng, max_lat, max_lng, rows, cols) db.close()