Exemplo n.º 1
0
def read_embedding(file_path):
    vector_dic = {}
    with open(file_path, 'r') as f:
        for line_num, eachline in enumerate(f):
            if line_num == 1:
                continue
            for line in f:
                node = str(line.split(' ')[0])
                vector = []
                list_1 = line.split(' ')[1:]
                for i in list_1:
                    vector.append(float(i))
                vector_dic[node] = vector
    return vector_dic
Exemplo n.º 2
0
 def parse_columns_from_line( self, line ):
     """
     Returns a list of the desired, parsed columns.
     :param line: the line to parse
     :type line: str
     """
     #TODO: too much going on in this loop - the above should all be precomputed AMAP...
     all_columns = line.split( self.deliminator )
     # if no indeces were passed to init, return all columns
     selected_indeces = self.selected_column_indeces or list( xrange( len( all_columns ) ) )
     parsed_columns = []
     for parser_index, column_index in enumerate( selected_indeces ):
         parsed_columns.append( self.parse_column_at_index( all_columns, parser_index, column_index ) )
     return parsed_columns
Exemplo n.º 3
0
def ReadGcodeFile(filepath):
    f=open(filepath,"r")
    for l in f:
        line=l.split()
        if 'G1' in line:
            G1(line)
            continue
        if 'G0' in line:
            G0(line)
            continue
        if 'G2' in line:
            G2(line)
            continue
        if 'G3' in line:
            G3(line)
            continue        
Exemplo n.º 4
0
 def parse_columns_from_line(self, line):
     """
     Returns a list of the desired, parsed columns.
     :param line: the line to parse
     :type line: str
     """
     #TODO: too much going on in this loop - the above should all be precomputed AMAP...
     all_columns = line.split(self.deliminator)
     # if no indeces were passed to init, return all columns
     selected_indeces = self.selected_column_indeces or list(
         xrange(len(all_columns)))
     parsed_columns = []
     for parser_index, column_index in enumerate(selected_indeces):
         parsed_columns.append(
             self.parse_column_at_index(all_columns, parser_index,
                                        column_index))
     return parsed_columns
Exemplo n.º 5
0
def Convert2dtoangle(filepath, filepath2):

    f = open(filepath, "r")
    fr = open(filepath2, "w")
    for l in f:
        line = l.split()
        x = 0
        y = 0
        for token in line:
            if 'X' in token:
                x = float(token[1:])
            if 'Y' in token:
                y = float(token[1:])
            if 'C' in token:  #for tempray 2d code
                z = float(token[1:])
                fr.write("C" + str(z) + "\n")

        #print "x=",x,"y=",y
        if (x == 0 and y == 0):
            continue
        distancexy = math.hypot(x, y)
        #print "distannce=",distancexy
        if x == 0:
            A1 = 90
            distancexy = y
        else:
            A1 = getangle(x, distancexy, y)  #below rotation angle
        if y == 0:
            distancexy = x
        A2 = getangle(distancexy, firsthand, secondhand)

        A = A1 + A2
        B = getangle(firsthand, secondhand, distancexy)
        #print "AB",A,B

        fr.write("A" + str(A) + " B" + str(B) + "  #x=" + str(x) + " y=" +
                 str(y) + "\n")

        print("A" + str(A) + " B" + str(B) + "\n")
Exemplo n.º 6
0
 def load(self, path):
     with open(path, "r") as map:
         for line in map:
             info = line.split(" ")
             self._parse(info)
Exemplo n.º 7
0
        coords.append(l)

    if (l.find("Coordinates of moved atoms (au):") != -1):
        start = True

fp.close()

atomslist = []

for l in coords:
    p = re.compile(r'\s+')
    line = p.sub(' ', l)
    line = line.lstrip()
    line = line.rstrip()

    plist = line.split(" ")

    if len(plist) == 4:
        atomslist.append((int(plist[0])-1, \
                float(plist[1])*DELTA, float(plist[2])*DELTA, \
                float(plist[3])*DELTA))

for a in atomslist:
    idx = a[0]

    xlist[idx] = a[1]
    ylist[idx] = a[2]
    zlist[idx] = a[3]

xyznanop.write_ncxyz("out.xyz", xlist, ylist, zlist, atoms)
Exemplo n.º 8
0
    util.file_to_sphere_diffr_list(filename, spheres)

totr = 0.0
for s in spheres:
    totr += s.get_radius()

meanr = totr / float(len(spheres))
meand = 2.0 * meanr

#print "xmax: ", xmax, "xmin: ",xmin, "ymax: ", ymax, \
#    "ymin: ", ymin, "zmx: ", zmax, "zmin: ", zmin

file = open("points.txt", "r")

for line in file:
    sx, sy, sz = line.split(" ")

    x = float(sx)
    y = float(sy)
    z = float(sz)

    circles = util_for_tr.get_circle_in_plane(spheres, z)

    if not util_for_tr.is_inside_circles(x, y, circles):

        poly_data_points_initial = util_for_tr.get_circle_points_list(
            x, y, circles)

        poly_data_points = []
        for p in poly_data_points_initial:
            d = util_for_tr.point_distance(p, [x, y])
Exemplo n.º 9
0
 def load(self, path):
     with open(path, "r") as map:
         for line in map:
             info = line.split(" ")
             self._parse(info)