コード例 #1
0
ファイル: predict.py プロジェクト: Christyyy/ptolemy
def main(filename, model, places):
    known, unknown = common.split_places(places)
    knownx = known.loc[:, XCOLS]
    knowny = known.loc[:, YCOLS]
    model.fit(knownx, knowny)
    unknownx = unknown.loc[:, XCOLS]
    unknowny = model.predict(unknownx)
    unknown.loc[:, YCOLS] = unknowny
    title = ' '.join(os.path.basename(filename)[0:-4].split('_'))
    common.write_kml_file(filename, None, known, unknown)
    common.write_csv_file(filename[0:-4] + '.csv', known, unknown)
    common.write_map_file(filename[0:-4] + '.pdf', known, unknown, 30, 24, 300, 'ptol_name', title)
    common.write_map_file(filename[0:-4] + '.png', known, unknown, 30, 24, 300, 'ptol_name', title)
コード例 #2
0
ファイル: predict.py プロジェクト: virdi/ptolemy
def main(filename, model, places):
    known, unknown = common.split_places(places)
    knownx = known.loc[:, XCOLS]
    knowny = known.loc[:, YCOLS]
    model.fit(knownx, knowny)
    unknownx = unknown.loc[:, XCOLS]
    unknowny = model.predict(unknownx)
    unknown.loc[:, YCOLS] = unknowny
    title = ' '.join(os.path.basename(filename)[0:-4].split('_'))
    common.write_kml_file(filename, None, known, unknown)
    common.write_csv_file(filename[0:-4] + '.csv', known, unknown)
    common.write_map_file(filename[0:-4] + '.pdf', known, unknown, 30, 24, 300,
                          'ptol_name', title)
    common.write_map_file(filename[0:-4] + '.png', known, unknown, 30, 24, 300,
                          'ptol_name', title)
コード例 #3
0
ファイル: visualize_triangles.py プロジェクト: virdi/ptolemy
    """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
ファイル: visualize_neighbors.py プロジェクト: virdi/ptolemy
        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)
コード例 #5
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')
コード例 #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)
コード例 #7
0
        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
ファイル: validate.py プロジェクト: virdi/ptolemy
def main(output, model, places, prior):
    known, unknown = common.split_places(places)
    validate_each(known, model, prior)
    compute_errors(known)
    known.to_csv(output, encoding='utf-8')
コード例 #9
0
ファイル: validate.py プロジェクト: Christyyy/ptolemy
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')
コード例 #10
0
ファイル: validate.py プロジェクト: claudiusptolemy/ptolemy
def main(output, model, places, prior):
    known, unknown = common.split_places(places)
    validate_each(known, model, prior)
    compute_errors(known)
    known.to_csv(output, encoding='utf-8')