parser.add_argument("-pp", "--printOnly", help="Print only the commands on screen.",\ action="store_true", default=False) #==========================================================# try: args = parser.parse_args() except: args = parser.parse_args([0]) # Send strKey=0 args.strKey = raw_input(" Enter search string: ") if( not args.strKey ): sys.exit(1) # Renaming for convenience .... sepChar = args.sepChar printOn = args.printOn printOnly = args.printOnly fileNos, fileList = filesFromList( "*"+args.strKey+"*" ) for filename in fileList: filename_new = reformatNumberInWord(filename, sepChar) cmd = 'mv {} {}'.format(filename, filename_new) if( printOn or printOnly ): print(cmd) if( not printOnly ): sb.call(cmd, shell=True)
xlims = args.xlims ylims = args.ylims logOn = args.log labelsOn = args.labels saveFig = args.save strKey = inputIfNone(strKey, " Enter search string: ") plt.rc('xtick', labelsize=24) #plt.rc('ytick.major', size=10) plt.rc('ytick', labelsize=24) #plt.rc('ytick.minor', size=6) while 1: fileNos, fileList = filesFromList(strKey + "*") pfig = plt.figure(num=1, figsize=(10., 10.5)) #pfig = plt.figure(num=1, figsize=(6.,8.)) for fn in fileNos: pdict = dict() pdict['filename'] = fileList[fn] pdict['Cx'] = factorX pdict['Cy'] = factorY pdict['lm'] = linemode pdict['logOn'] = logOn pdict['revAxes'] = revAxes pdict['xlims'] = xlims pdict['ylims'] = ylims pfig = plotCiXY(pfig, pdict)
default=["U:1"]) parser.add_argument("-r", "--ref", help="Reference value", nargs='?', type=float, default=0.) parser.add_argument("-w", "--waveMode", help="Discrete Wave Mode (overrides -v/--var option)",\ action="store_true", default=False) args = parser.parse_args() #==========================================================# #print type(args.var), args.var if (not args.filename): fileNos, fileList = filesFromList("*.csv") try: args.filename = fileList[0] except: sys.exit('Could not obtain a valid CSV file. Exiting ...') if (args.waveMode): varList = ["U:1", "U:2", "arc_length"] dat = extractFromCSV(args.filename, varList) Umag = np.sqrt(dat[0]**2 + dat[1]**2) xL = dat[2] waveAnalysis(Umag, xL) else: varList = args.var v_ref = args.ref
fileKey = args.fileKey fileout = args.fileout filetopo = args.filetopo flt = args.filter allFiles = args.allfiles norm2one = args.norm2one printOn = args.printOn or args.printOnly printOnly = args.printOnly vtkOn = args.vtk if( vtkOn and (filetopo == '')): sys.exit(' Error! VTK results require -ft/--filetopo. Exiting ...') # Gather footprint data files: fileNos, fileList = filesFromList( "*"+fileKey+"*", allFiles ) # = = = = = = = = = = = = = = = = = = = = = = = = = = = = # # xO := origin coords. # xt := target coords. # ut := target speed Ft = None; Ct = None; Zt = None for fn in fileNos: print(' Processing file: {}'.format(fileList[fn])) Fi, X, Y, Z, Ci = readNumpyZFootprint( fileList[fn] ) Fi *= Ci # Return the footprint into unscaled state. if( Ft is None ): Ft = Fi.copy()
# Rename ... that's all. fileRef = args.fileRef filesDiff = args.filesDiff excl = args.excl # = = = = = = = = = = = = = = = = = = = = = = = = = = = = # # xO := origin coords. # xt := target coords. # ut := target speed try: Fref, X, Y, Z, C = readNumpyZFootprint( fileRef ) # IdsOn=True except: sys.exit(' Could not read the footprint file: {}'.format(fileRef)) # Gather footprint data files: fileNos, fileList = filesFromList( "*"+filesDiff.strip(".npz")+"*.npz" ) for fn in fileNos: try: Fi, X, Y, Z, Ci = readNumpyZFootprint( fileList[fn] ) except: sys.exit(' Could not read the footprint file: {}'.format(fileList[fn])) # Resolution: dPx = np.array([ (X[0,1]-X[0,0]) , (Y[1,0]-Y[0,0]) ]) # Normalize s.t. global integral becomes one. print(' Normalizing the footprints such that SUM(Fp) = 1 ...') C1 = 1./np.sum( Fref * np.prod(dPx)); Fref *= C1 C2 = 1./np.sum( Fi * np.prod(dPx)); Fi *= C2 print('... done! C1_ref = {} and C2 = {}'.format(C1, C2))
fileKey = args.fileKey outstr = args.outstr vnames = args.vnames sname = args.sname notPrimes = args.notPrimes nt = args.ntimeskip cl = abs(int(args.coarse)) ''' Establish two boolean variables which indicate whether the created variable is an independent or dependent variable in function createNetcdfVariable(). ''' parameter = True variable = False # Obtain a list of files to include. fileNos, fileList = filesFromList(fileKey + '*') for fn in fileNos: fileout = outstr + fileList[fn].split('_')[-1] # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = # # Read in data. dataDict = read3dDataFromNetCDF(fileList[fn], vnames[0], cl) up = dataDict['v'] dataDict = read3dDataFromNetCDF(fileList[fn], vnames[1], cl) vp = dataDict['v'] dataDict = read3dDataFromNetCDF(fileList[fn], vnames[2], cl) wp = dataDict['v'] if (notPrimes): # Perform coord. rotation for horizontal components
action="store", default=3) parser.add_argument("--labels", help="User specified labels.", action="store_true",\ default=False) parser.add_argument("--yx", help="Transpose x and y axes.", action="store_true",\ default=False) try: args = parser.parse_args() except: args = parser.parse_args([0]) # Send strKey=0 args.strKey = raw_input(" Enter search string: ") if (not args.strKey): sys.exit(1) plt.rc('xtick', labelsize=14) plt.rc('ytick', labelsize=16) while 1: fileNos, fileList = filesFromList(args.strKey) pfig = plt.figure(num=1, figsize=(8., 8.)) for fn in fileNos: pfig = plotDY(pfig, fileList[fn], args.dim, args.yx) if (args.labels): pfig = userLabels(pfig) plt.grid(True) plt.legend(loc=0) plt.show()
default=None) parser.add_argument("-v", "--var", help="Variable Name in RAW-file", nargs='+',\ default=["U_z"]) parser.add_argument("-r","--ref", help="Reference value", nargs='?', type=float,\ default=0.) args = parser.parse_args() print type(args.var), args.var varList = ["x","y","z"] varList.extend(args.var)#; print varList v_ref = args.ref#; print v_ref if( not args.filename ): fileNos, fileList = filesFromList( "*.raw" ) filename = fileList[0] else: fileList = [args.filename] for fx in fileList: data = extractFromRAW( fx , varList ) x=data[0]; y=data[1]; z=data[2] v=data[3] # Only one var allow at this point. RadiusLimit = 0.616 vd = reduceByRadius(x,y,v,Rlim=0.6) #strOut = print " "; print sepStr
parser.add_argument("-t", "--utmTile", help="Utm tile code (2 chars). For example: P5",\ type=str, default=None) parser.add_argument("-s", "--scale", type=float,\ help="Scale factor for the output. Default=1.", default=1.) args = parser.parse_args() writeLog( parser, args, args.printOnly ) #==========================================================# # Rename ... that's all. filename = args.filename utmTile = args.utmTile bandSelect = args.bandSelect scale = args.scale # If the geotiff file has not been specified, ask specifically. if( not filename ): fileNos, fileList = filesFromList( "*.tif" ) try: filename = fileList[0] except: sys.exit('Could not obtain a valid GEOTIFF file. Exiting ...') dataset = openGeoTiff( filename ) XOrig, resolution = getGeoTransform( dataset ) # Both 2d arrays. XOrig is Top Left! nBands = numberOfRasterBands( dataset, True) # PrintOn = True/False # Ask for the band ID if the user so wants (given that it makes sense) ib = selectBand( nBands, bandSelect , 1 ) # last argument is for default rb = getRasterBand( dataset, ib ) printRasterBandStatistics(rb)
v[j] = isolateNumericalValues( data[:,icols[j]] , ['(',')']) return v # ============ === ARGS === =========================== # parser = argparse.ArgumentParser() parser.add_argument("-t","--torgue", help="Plot Torgues", action="store_true",\ default=False) parser.add_argument("--labels", help="User specified labels.", action="store_true",\ default=False) args = parser.parse_args() # ============== === MAIN === ======================= # fileNos, fileList = filesFromList('./postProcessing/forces/*/forces*' ) Ftot = [[],[],[]]; Ttot =[[],[],[]] time = [] for fn in fileNos: raw = np.loadtxt( fileList[fn], dtype=str ) ncols = len(raw[0,:])-1 # How many columns of Force data t = np.array( extractColumns( raw , [0,] )[0] ) Fp = np.array( extractColumns( raw , [1,2,3] ) ) Fv = np.array( extractColumns( raw , [4,5,6] ) ) Fo = np.array( extractColumns( raw , [7,8,9] ) ) Tp = np.array( extractColumns( raw , [10,11,12] ) ) Tv = np.array( extractColumns( raw , [13,14,15] ) ) To = np.array( extractColumns( raw , [16,17,18] ) )
help="Search string for figures (2).") parser.add_argument("-p", "--printOn", help="Print the renaming commands on screen.",\ action="store_true", default=False) parser.add_argument("-pp", "--printOnly", help="Print only the commands on screen.",\ action="store_true", default=False) parser.add_argument("-na", "--noAnim", help="Do not make an animation.",\ action="store_true", default=False) args = parser.parse_args() #==========================================================# # Renaming for convenience .... printOn = args.printOn printOnly = args.printOnly noAnimation = args.noAnim fileNos1, fileList1 = filesFromList("*" + args.fig1 + "*") fileNos2, fileList2 = filesFromList("*" + args.fig2 + "*") nfigs = min(len(fileList1), len(fileList2)) for i in range(nfigs): cmd = 'montage -mode concatenate -tile 1x2 {0} {1} output_{2:04d}.png'\ .format(fileList1[i], fileList2[i], i ) if (printOn or printOnly): print(cmd) if (not printOnly): sb.call(cmd, shell=True) if (not noAnimation): cmd = 'convert output_* anim.gif ' if (printOn or printOnly):