#!/usr/bin/env python3 import os, sys import argparse import subprocess from txtTools import openIOFile # = = = = = = = = = = = = = = = = = = = = = = = = = = = = # parser = argparse.ArgumentParser(prog='executeCommandsInFile.py') parser.add_argument("-f", "--filename", help="Name of file containing commands to be run.", type=str) args = parser.parse_args() # = = = = = = = = = Main Program = = = = = = = = = = = = = # filename = args.filename inFile = openIOFile(filename, 'r') for line in inFile: print(" Executing: {}".format(line)) subprocess.call(line, shell=True)
for s in sl: v.append(float(s)) return v # =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* try: factor = sys.argv[1] except: factor = 1. factor = float(factor) f = openIOFile('forces.dat', 'r') oc = openIOFile('forces.cmp', 'w') ot = openIOFile('forces.tot', 'w') lines = f.readlines() spr = ['(',')'] Fx = np.zeros(4,float) for l in lines[1:]: x = np.array(isolateValues(l,spr)) if( len(x) == 13 ): x.tofile(oc,sep=" \t"); oc.write("\n") Fx[0] = x[0] for i in xrange(1,len(Fx)): Fx[i]=factor*(x[i]+x[i+3]) # Pressure + Viscous
nQ = resDict['nQ'] # Number of quadrant hits (nQ[0] := Ntotal) SQ = resDict['SQ'] # Quadrant contributions (e.g. Reynolds stress) cn = 100. / nQ[0] print(' Ejections (%) = {}, Sweeps (%) = {} '.format( cn * nQ[2], cn * nQ[4])) print(' Outward Interactions (%) = {}, Inward Interactions (%) = {} '. format(cn * nQ[1], cn * nQ[3])) # Write/append the results to file if (ofile is not None): Sa = np.abs(SQ[0]) Smag = np.sqrt(np.sum(SQ[1:]**2)) zm = z[ix1[2]] for i in range(1, 5): fwo = openIOFile('{}_Q{}.dat'.format(ofile, i), 'a') fwo.write("{}\t{}\n".format(zm, SQ[i])) fwo.close() print(' Qa[kt,:,:].shape = {}, Q.shape = {}'.format( np.shape(Qa[kt, :, :]), np.shape(Q))) Qa[kt, :, :] = Q.copy() # = = output file = = = = = # Create a NETCDF output dataset (dso) for writing out the data. dso = netcdfOutputDataset(fileout) xv = createNetcdfVariable(dso, xa, 'x', len(xa), 'm', 'f4', ('x', ), parameter) yv = createNetcdfVariable(dso, ya, 'y', len(ya), 'm', 'f4', ('y', ), parameter) zv = createNetcdfVariable(dso, ka, 'z', len(ka), 'm', 'f4', ('z', ), parameter) Qv = createNetcdfVariable(dso, Qa, 'Q', dims[0], 'm-2', 'f4', ( 'z',