示例#1
0
文件: tools.py 项目: k323r/YASB-tools
def readRibletForces(dataDir, forceDirName, forceFileName, normaliseForces, STARTTIME = 100, ENDTIME = 500, LATESTTIME = -1):
    ribletForces = dict()
    # read in riblet data
    for case in readDir(dataDir):
        try:
            name, _, _, _, s, = case.split("_")[:5]
        except:
            if DEBUG: printMD("__could no parse directory: {}, skipping__".format(case))
            continue
        if len(s) == 4:
            try:
                s = float(s)/10
            except:
                pass
        elif len(s) == 5:
            try:
                s = float(s)/100
            except:
                pass
        else:
            print("encountered non matching string length for s")

        if name == "Riblet":
            timeDir = getTimeSteps(joinPaths(dataDir, joinPaths(case, forceDirName)))[LATESTTIME]
            forceFilePath = joinPaths(
                joinPaths(dataDir, joinPaths(
                    case, joinPaths(
                        forceDirName, joinPaths(timeDir, forceFileName)))))
            ribletForces[str(s)] = readForceFile(forceFilePath,
                                                 startTime = STARTTIME,
                                                 endTime = ENDTIME,
                                                 normalForce = normaliseForces[str(s)]
                                                )
    return ribletForces
示例#2
0
 def moveFile(sourcePath):
     className, imageName = sourcePath.split('/')[3:]
     targetPath = joinPaths(targetRoot, className, imageName)
     try:
         copyfile(sourcePath, targetPath)
     except (FileNotFoundError):
         makedirs(joinPaths(targetRoot, className))
         copyfile(sourcePath, targetPath)
示例#3
0
 def scan(path):
     for file in listdir(path):
         absolute = joinPaths(path, file)
         if isdir(absolute):
             Scanner.scan(absolute)
             #print (abspath(absolute))
         if isfile(absolute):
             filename = basename(absolute).lower()
             if (filename.endswith('.csproj')):
                 print(filename)
             if (filename == 'packages.config'):
                 print(' * ' + absolute)
示例#4
0
 def scan(path):
     for file in listdir(path):
         absolute = joinPaths(path,file)
         if isdir(absolute):
             Scanner.scan(absolute)
             #print (abspath(absolute))
         if isfile(absolute):
             filename = basename(absolute).lower()
             if ( filename.endswith('.csproj')):
                 print (filename)
             if (filename == 'packages.config'):
                 print (' * ' + absolute)
示例#5
0
文件: tools.py 项目: k323r/YASB-tools
def readTimeDirs(dataDir, dirName, fileName, normalise = [], columns = [] , STARTTIME = 100, ENDTIME = 500, LATESTTIME = -1):
    dataPerDir = dict()
    # read in riblet data
    for case in readDir(dataDir):
        try:
            name, _, _, _, s, = case.split("_")[:5]
        except:
            if DEBUG: printMD("__could no parse directory: {}, skipping__".format(case))
            continue
        if len(s) == 4:
            try:
                s = float(s)/10
            except:
                pass
        elif len(s) == 5:
            try:
                s = float(s)/100
            except:
                pass
        else:
            print("encountered non matching string length for s")

        if name == "Riblet":
            timeDir = getTimeSteps(joinPaths(dataDir, joinPaths(case, dirName)))[LATESTTIME]
            if DEBUG: print(timeDir)
            filePath = joinPaths(
                joinPaths(dataDir, joinPaths(
                    case, joinPaths(
                        dirName, joinPaths(timeDir, fileName)))))
            dataPerDir[str(s)] = filePath
            '''
            dataPerDir[str(s)] = readTimeFile(filePath,
                                              startTime = STARTTIME,
                                              endTime = ENDTIME,
                                              normalise = normalise,
                                              columns = columns,
                                             )
            '''
    return dataPerDir
示例#6
0
 def nameOrPath(name):
     if fullpath:
         return joinPaths(path, name)
     else:
         return name
示例#7
0
文件: tools.py 项目: k323r/YASB-tools
def readDir(path):
    return [d for d in ls(path) if isdir(joinPaths(path, d))]