#cursor.execute(query, place_data)
            except Exception as e:
                print 'unable to insert %s: %s' % (row.ptol_id, e.message)
        #connection.commit()
        #cursor.close()
        #connection.close()
        session.commit()
        session.close()
    except Exception as e:
        print 'unable to connect: %s' % (e.message, )

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
            description='Load Ptolemy places to database.')
    parser.add_argument('--sgdb', help='read from sgdb with given prefix')
    parser.add_argument('--xlsx', help='xlsx to read from instead of sgdb')

    args = parser.parse_args()

    if args.sgdb:
        places = common.read_places(args.sgdb)
    elif args.xlsx:
        places = common.read_places_xlsx(args.xlsx)
    else:
        sys.stderr.write('must specify one of --sgdb or --xlsx')
        exit(1)

    places = common.read_places_output_csv(args.csv)

    #main(places)
示例#2
0
        kml.write('<Document>\n')
        common.write_styles(kml)
        for i in range(len(known)):
            kml.write('  <Folder id="%s">\n' % (known.ix[i].ptol_id, ))
            kml.write('      <name>%s</name>\n' % (known.ix[i].ptol_id, ))
            ax = known.ix[i, XCOLS].values
            ay = known.ix[i, YCOLS].values
            alabel = known.ix[i].ptol_id
            common.write_point(kml, 'red', ax, alabel)
            common.write_point(kml, 'red', ay, alabel)
            if verbose: print known.ix[i].ptol_id, ax, ay
            points = [indices[i, j] for j in range(1, k)]
            for m in range(len(points)):
                j = points[m]
                bx = known.ix[j, XCOLS].values
                by = known.ix[j, YCOLS].values
                blabel = known.ix[j].ptol_id
                common.write_point(kml, 'yellow', bx, blabel)
                common.write_point(kml, 'yellow', by, blabel)
                common.write_line(kml, ax, bx, colors[m])
                common.write_line(kml, ay, by, colors[m])
                if verbose: print '  ', known.ix[j].ptol_id, bx, by
            kml.write('  </Folder>\n')
        kml.write('</Document>\n')
        kml.write('</kml>\n')


if __name__ == '__main__':
    known, _ = common.split_places(common.read_places())
    write_neighbor_visualization_kml(known)
示例#3
0
    """Compute unknown modern coordinates from known ones using the
    given triangulation."""
    colors = ['red', 'yellow', 'green']
    with open('../Data/visualize_triangles.kml', 'wb') as kml:
        kml.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        kml.write('<kml xmlns="http://www.opengis.net/kml/2.2">\n')
        kml.write('<Document>\n')
        common.write_styles(kml)
        for simp in tri.simplices:
            print simp
            tri_name = 'Triangle_%s' % '_'.join(str(x) for x in simp)
            kml.write('  <Folder id="%s">\n' % (tri_name, ))
            kml.write('      <name>%s</name>\n' % (tri_name, ))
            write_triangle(kml, tri_name, colors,
                           [(known.ix[x].ptol_lat, known.ix[x].ptol_lon)
                            for x in simp])
            write_triangle(kml, tri_name, colors,
                           [(known.ix[x].modern_lat, known.ix[x].modern_lon)
                            for x in simp])
            kml.write('  </Folder>\n')
        kml.write('</Document>\n')
        kml.write('</kml>\n')


if __name__ == '__main__':
    places = common.read_places()
    known, unknown = common.split_places(places)
    points = known.loc[:, ['ptol_lat', 'ptol_lon']]
    tri = Delaunay(points, furthest_site=False)
    write_triangle_visualization_kml(tri, known, unknown)
示例#4
0
def main(filename, model):
    places = common.read_places()
    known, unknown = common.split_places(places)
    validate_each(known, model)
    compute_errors(known)
    known.to_csv(filename, encoding='cp1252')
示例#5
0
            except Exception as e:
                print 'unable to insert %s: %s' % (row.ptol_id, e.message)
        #connection.commit()
        #cursor.close()
        #connection.close()
        session.commit()
        session.close()
    except Exception as e:
        print 'unable to connect: %s' % (e.message, )


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Load Ptolemy places to database.')
    parser.add_argument('--sgdb', help='read from sgdb with given prefix')
    parser.add_argument('--xlsx', help='xlsx to read from instead of sgdb')

    args = parser.parse_args()

    if args.sgdb:
        places = common.read_places(args.sgdb)
    elif args.xlsx:
        places = common.read_places_xlsx(args.xlsx)
    else:
        sys.stderr.write('must specify one of --sgdb or --xlsx')
        exit(1)

    places = common.read_places_output_csv(args.csv)

    #main(places)
示例#6
0
        common.write_line(kml, points[i], points[(i+1) % 3], colors[i])


def write_triangle_visualization_kml(tri, known, unknown):
    """Compute unknown modern coordinates from known ones using the
    given triangulation."""
    colors = ['red', 'yellow', 'green']
    with open('../Data/visualize_triangles.kml', 'wb') as kml:
        kml.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        kml.write('<kml xmlns="http://www.opengis.net/kml/2.2">\n')
        kml.write('<Document>\n')
        common.write_styles(kml)
        for simp in tri.simplices:
            print simp
            tri_name = 'Triangle_%s' % '_'.join(str(x) for x in simp)
            kml.write('  <Folder id="%s">\n' % (tri_name, ))
            kml.write('      <name>%s</name>\n' % (tri_name, ))
            write_triangle(kml, tri_name, colors, [(known.ix[x].ptol_lat, known.ix[x].ptol_lon) for x in simp])
            write_triangle(kml, tri_name, colors, [(known.ix[x].modern_lat, known.ix[x].modern_lon) for x in simp])
            kml.write('  </Folder>\n')
        kml.write('</Document>\n')
        kml.write('</kml>\n')


if __name__ == '__main__':
    places = common.read_places()
    known, unknown = common.split_places(places)
    points = known.loc[:, ['ptol_lat','ptol_lon']]
    tri = Delaunay(points, furthest_site=False)
    write_triangle_visualization_kml(tri, known, unknown)
        for i in range(len(known)):
            kml.write('  <Folder id="%s">\n' % (known.ix[i].ptol_id,))
            kml.write("      <name>%s</name>\n" % (known.ix[i].ptol_id,))
            ax = known.ix[i, XCOLS].values
            ay = known.ix[i, YCOLS].values
            alabel = known.ix[i].ptol_id
            common.write_point(kml, "red", ax, alabel)
            common.write_point(kml, "red", ay, alabel)
            if verbose:
                print known.ix[i].ptol_id, ax, ay
            points = [indices[i, j] for j in range(1, k)]
            for m in range(len(points)):
                j = points[m]
                bx = known.ix[j, XCOLS].values
                by = known.ix[j, YCOLS].values
                blabel = known.ix[j].ptol_id
                common.write_point(kml, "yellow", bx, blabel)
                common.write_point(kml, "yellow", by, blabel)
                common.write_line(kml, ax, bx, colors[m])
                common.write_line(kml, ay, by, colors[m])
                if verbose:
                    print "  ", known.ix[j].ptol_id, bx, by
            kml.write("  </Folder>\n")
        kml.write("</Document>\n")
        kml.write("</kml>\n")


if __name__ == "__main__":
    known, _ = common.split_places(common.read_places())
    write_neighbor_visualization_kml(known)
示例#8
0
def main(filename, model):
    places = common.read_places()
    known, unknown = common.split_places(places)
    validate_each(known, model)
    compute_errors(known)
    known.to_csv(filename, encoding='cp1252')