Example #1
0
def save():
    from context.resource_manager import Properties
    from pandas import DataFrame, Series
    path = os.path.join(Properties.getRootPath(),
                        Properties.getImageXmlResource())
    from xml.dom.minidom import parse, parseString
    images = parse(path)
    id = []
    data = []
    for node in images.getElementsByTagName("Image"):
        idNode = node.getElementsByTagName("id")[0].childNodes[0].data
        id.append(idNode)
        dataNode = node.getElementsByTagName("data")[0].childNodes[0].data
        dataNode = dataNode[1:-1].split(',')
        data.append(dataNode)
    id = np.asarray(id)
    id = Series(id)
    data = np.asarray(list(map(conv, data)), dtype=np.float)
    if not os.path.exists(Properties.getDefaultDataFold() + "/cache/image7"):
        #f=open(Properties.getDefaultDataFold()+"/csv/threshold.csv","w")
        #f.close()
        os.makedirs(Properties.getDefaultDataFold() + "/cache/image7")
    np.save(Properties.getRootPath() + "/data/cache/image7/id.npy", id)
    np.save(Properties.getRootPath() + "/data/cache/image7/data.npy", data)
Example #2
0
    def loadCacheData(self, name='default', tag="Image", relative=True):
        """
        返回xml数据
        :param name:
        :param tag:
        :param relative:
        :return:
        """

        if relative:
            path = os.path.join(Properties.getRootPath() + "/data/cache/" + name)
        else:
            path = name
        try:
            id = np.load(path + "/id.npy")
            data = np.load(path + "/data.npy")
        except:
            return self.getXmlData(name=name, tag=tag, save=True)
        return id, data
Example #3
0
def compute_distance(data=np.array([])):
    """
    :param data:
    :return:
    the numpy array 按行进行查看
    """
    if data.size <= 0:
        raise Exception
        log.critical("cluster need the data, and there has no data in numpy array collection.")
    else:
        log.info("start running compute distance. data count:" + str(data.shape[0]) + " point has to computing.")
    row = data.shape[0]
    result = np.zeros((row, row))
    i = 0
    for i in range(row):
        j = i
        for j in range(row):
            k = compute_point_distance(data[i], data[j])
            result[i][j] = k;
            result[j][i] = k;
        result[i][i] = np.nan
    np.save(Properties.getRootPath() + "/data/cache/distance/data.npy", result)
    return result
Example #4
0
    rho_id=Series(rho,index=id)
    log.critical(rho)
    """
    from cluster import density_cluster
    from pandas import Series
    from pandas import Series, DataFrame
    from context.resource_manager import Properties
    from view import shape_view
    from cluster import density_cluster

    name = 'path'
    distance_c = 12.3972318748
    m = '3_44'
    pile = 0
    id = np.load(Properties.getRootPath() + "/data/cache/" + name + "/id.npy")
    data = np.load(Properties.getRootPath() + "/data/cache/" + name + "/data.npy")
    id_index = Series(id.tolist())
    from cluster import density_cluster
    index_id = Series(id_index.index, index=id_index.values)
    distance = density_cluster.compute_distance(data)
    pile_id = DataFrame([], columns=['pile', 'size'])
    rho_id = density_cluster.rho_function(index_id, distance, distance_c=distance_c)
    rho_id = Series(rho_id, index=index_id.index)
    rho_id = rho_id.sort_values(ascending=False)
    #delta_id, data_id = density_cluster.delta_function(id_index, index_id, rho_id, distance)
    log.debug(rho_id)
    pile=['3_44']
    pile_max=14
    pile = density_cluster.pile_brother(index_id, id_index, distance, distance_c, pile,pile_max)
    log.debug("pile info:")
Example #5
0
    def removeConfigFiles(cls):
        if os.path.isfile(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'directory.ini'):
            os.remove(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'directory.ini')

        if os.path.isfile(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'document.ini'):
            os.remove(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'document.ini')
Example #6
0
 def reload(self):
     if type == 'D':
         self.configParse.read(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'directory.ini')
         # self.f = open(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'directory.ini', 'w+')
     elif type == 'F':
         self.configParse.read(Properties.getRootPath()+'conf' + resource_manager.getSeparator() + 'document.ini')
Example #7
0
def load_data():
    id = np.load(Properties.getRootPath() + "/data/cache/flame/id.npy")
    data = np.load(Properties.getRootPath() + "/data/cache/flame/data.npy")

    return id, data