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
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)
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)
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)
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
def nameOrPath(name): if fullpath: return joinPaths(path, name) else: return name
def readDir(path): return [d for d in ls(path) if isdir(joinPaths(path, d))]