示例#1
0
def main():
  """ Main Function"""

  parser = argparse.ArgumentParser(description='Create a dataset with n circles creating a cylinder around the z-axis')
 
  parser.add_argument('--radius','-r',metavar='R',
      type=float,nargs='?',default=1.0,
      help='The radius of the sphere')
  parser.add_argument('--pointscircle','-n',metavar='N', 
      type=int, nargs=1,
      help='The number of particles per circle in the sphere')

  parser.add_argument('--weight','-w',metavar='W', 
      type=float, nargs='?',
      help='The weight of the individual particles',
      default=1.0)
  parser.add_argument('--speed','-s',metavar='S',
      type=float, nargs='?', default=1.0,
      help='The speed of the individual particles')
  parser.add_argument('--display','-d',
      action='store_const',const=True,default=False,
      help='Display the dataset')
  parser.add_argument('--file','-f',nargs='?',
      type=argparse.FileType('wb'), default=sys.stdout,
      help='The outputfile')
  args = parser.parse_args()
  print args

  angles=args.angles
  points=args.pointscircle[0]
  radius=args.radius
  weight=args.weight
  speed=args.speed
  x,y,z,w,vx,vy,vz = generateDataset(angles,points,radius,weight,speed)
  """ Display the values """
  if (args.display):
    plot(x,y,z)

  """ Dump them to std or file"""
  printInput(args.file,w,x,y,z,vx,vy,vz)

def filename(prefix,number,radius,speed,special):
  return prefix+"_n"+str(number)+"_r"+str(radius)+"_s"+str(speed)+"_"+special+".in"


prefix = "circles"
for np in numberOfPoints:
  for r in radius:
    for s in speed:
      for a in angles:
        x,y,z,w,vx,vy,vz = circles.generateCircle(a,np,r,weight,s)
        fname = filename("circles",np,r,s,"a"+("_".join(map(lambda x: str(x),a))))
        print fname
        f = open(fname,'w')
        circles.printInput(f,w,x,y,z,vx,vy,vz)
"""
prefix = "cylinder"
for np in numberOfPoints:
  for r in radius:
    for s in speed:
      for nc in numberofCircles:
        for sh in shift:
          x,y,z,w,vx,vy,vz = circles.generateCylinder(np,s,nc,r,weight,s)
          fname = filename("cylinder",np,r,s,"nc"+str(nc)+"_sh"+str(sh))
          print fname
          f = open(fname,'w')
          circles.printInput(f,w,x,y,z,vx,vy,vz)

prefix = "rotcircle"
for np in numberOfPoints: