Esempio n. 1
0
def getStateswithViewPoint(filepathList, baseList, refList, detail=False):
    output = {}
    for fpath in filepathList:
        if fpath[-4:] != ".csv":
            if detail == True:
                text = "[ViewPointManager]getSateswithViewPoint:"
                print(text + fpath + " is not csv file")
            continue
        # パスをキーにして管理すると面倒なのでファイル名に変更
        filename = os.path.basename(fpath)
        # print("file:"+filename)
        output[filename] = []
        with open(fpath, "r", encoding="utf-8") as f:
            while True:
                line = f.readline()
                if line == "":
                    break
                bstate = encoder.encodeState(line)
                astate = encoder.transformforViewPoint(bstate, baseList,
                                                       refList)
                # data   = encoder.serialize(astate)
                data = astate
                output[filename].append(data)
    return output
# coding = utf-8

# log データを可視化してチェックするだけ

import glob
import os
import HDP_HMM.MakerMain as makerMain
import DPM.ViewPointEncoder as encoder
import DPM.ViewPointManager as manager

fpaths = glob.glob("tmp/log_MakerMain/*")

for fpath in fpaths:
    if os.path.basename(fpath)[:3] != "log" \
            or fpath[-4:] != ".csv":
        continue
    if int(os.path.basename(fpath)[-6:-4]) > 2:
        continue
    with open(fpath, "r", encoding="utf-8") as f:
        count = 0
        while True:
            line = f.readline()
            if line == "":
                break
            if count%100 == 0:
                manager.show(encoder.encodeState(line), title=fpath)
            count += 1
Esempio n. 3
0
# coding = utf-8

import DPM.ViewPointEncoder as encoder
import DPM.ViewPointManager as manager

interList = []
path="tmp/log_MakerMain/GettingIntermediated/3-2500-2500-9/inter000000000.csv"
with open(path) as f:
    while True:
        line = f.readline()
        if line == "":
            break
        interList.append(int(line.split(",")[0]))
print("inters:"+str(interList))

with open("tmp/log_MakerMain/log000000000.csv", "r", encoding="utf-8") as f:
    counter = 0
    while True:
        counter+=1
        line = f.readline()
        if line == "":
            break
        elif counter%6 != 0 and counter not in interList:
            continue
        state = encoder.encodeState(line)
        name = "log000000000_"+str(counter)+".png"
        inter = counter in interList
        manager.savefig(state, name=name, log=True, inter=inter)