def average_cloud_centers( shots ):
    print shots 
    c0 = []; c1 = []; 
    for s in shots:
	report = ConfigObj( 'report%04d.INI'%s )  
        c0.append( qrange.evalstr( report, 'CPP:ax0c_crop' ) ) 
        c1.append( qrange.evalstr( report, 'CPP:ax1c_crop' ) )
    return np.mean( np.array(c0)), np.mean( np.array(c1)) 
  args = parser.parse_args()

  print args
 

  rangestr = args.range.replace(':','to')
  rangestr = rangestr.replace(',','_')
  shots = qrange.parse_range(args.range)

  if 'SEQ:shot' not in args.YKEYS:
      args.YKEYS.append('SEQ:shot')

  datadict = {} 
  for s in shots:
      report = ConfigObj( 'report'+s+'.INI')  
      xkey = qrange.evalstr( report, args.XKEY  )
      if xkey not in datadict.keys():
          datadict[xkey] = {}
 
      bgkey = qrange.evalstr( report, args.BGKEY ) 
      if bgkey not in datadict[xkey].keys():
          datadict[xkey][bgkey] = {} 
     
      for Y in args.YKEYS:
          if Y not in datadict[xkey][bgkey].keys(): 
              datadict[xkey][bgkey][Y] = []
          val = qrange.evalstr(report, Y)
          datadict[xkey][bgkey][Y].append( val  )
          if val is np.nan:
              print "Encountered nan in Shot #", s
  import pprint
  vals = {}
 
  sumnet6 = {}

  shots = qrange.parse_range(args.range)
  shlist = glob.glob( os.getcwd() + '/????_bragg.dat')
  shlist.sort()

  # Collect data for all shots, sums and Ns
  for sh in shlist:
    s =  os.path.split(sh)[1].split('_bragg')[0]
    if s in shots:
 
        report = ConfigObj( 'report'+s+'.INI')
        #val = report[sec][key]
        val = qrange.evalstr(report, args.KEY)
        
        dat = rebin(np.loadtxt( s + '_bragg.dat'), \
                    args.binsz, rollX, rollY) 

        if val in keydict.keys():
            index = keydict[val]
            sums[index] = sums[index] + dat
            sqs[index]  = sqs[index] + dat*dat
            ns[index] = ns[index] + 1

            
            sumnet6[index].append( float(report['BRAGG']['sum_net_6']))
 
        else:
            keydict[val] = i
  keys = ["DIMPLE:ir1",\
	"DIMPLE:ir2",\
	"DIMPLE:ir3",\
	"DIMPLE:gr1",\
	"DIMPLE:gr2",\
	"DIMPLE:gr3",\
	"CPP:ax0c",\
	"CPP:ax1c",\
	"CPP:ax0w",\
	"CPP:ax1w"]

  for s in shots:
	report = ConfigObj( 'report'+s+'.INI')  
	temp =[]
	for k in keys:
		temp.append(qrange.evalstr( report, k  ))
	beams = tuple(temp[0:6])
	center = tuple(temp[6:8])
	waist = tuple(temp[8:10])
	print beams
	if (beams in shotsdata.keys()):
		shotsdata[beams] = [center,waist]
	else:
		sys.exit("Unexpect IR GR pair condition.")
  grdata = {'GR1V':[shotsdata[(1,0,1,0,0,0)],shotsdata[(1,0,1,1,0,0)]],\
	'GR1H':[shotsdata[(1,1,0,0,0,0)],shotsdata[(1,1,0,1,0,0)]],\
	'GR2V':[shotsdata[(0,1,1,0,0,0)],shotsdata[(0,1,1,0,1,0)]],\
	'GR2H':[shotsdata[(1,1,0,0,0,0)],shotsdata[(1,1,0,0,1,0)]],\
	'GR3V':[shotsdata[(0,1,1,0,0,0)],shotsdata[(0,1,1,0,0,1)]],\
	'GR3H':[shotsdata[(1,0,1,0,0,0)],shotsdata[(1,0,1,0,0,1)]]}
  
Beispiel #5
0
    verbose = not args.concise
    CONCISEOUT = ""

    rangestr = args.range.replace(":", "to")
    rangestr = rangestr.replace(",", "_")
    shots = qrange.parse_range(args.range)

    if "SEQ:shot" not in args.YKEYS:
        args.YKEYS.append("SEQ:shot")

    datadict = {}
    timekey = "SEQ:abstime"
    for s in shots:
        report = ConfigObj("report" + s + ".INI")
        xkey = qrange.evalstr(report, args.XKEY)
        if xkey not in datadict.keys():
            datadict[xkey] = {}

        bgkey = qrange.evalstr(report, args.BGKEY)
        if bgkey not in datadict[xkey].keys():
            datadict[xkey][bgkey] = {}

        for Y in args.YKEYS:
            if Y not in datadict[xkey][bgkey].keys():
                datadict[xkey][bgkey][Y] = []
            val = qrange.evalstr(report, Y)
            datadict[xkey][bgkey][Y].append(val)
            if val is np.nan:
                if verbose:
                    print "Encountered nan in Shot #", s
  if args.keys != None:
    rawdat='%s\n' % ('\t'.join(args.keys))
    rawdat='#Date\t\t' + rawdat
    print rawdat,
  for rootdir, dirs, files in sortedWalk( args.DIR ):
    for basename in files:
      if 'report' in basename:
        reportpath = os.path.join(rootdir, basename)
        try:
          report = ConfigObj(reportpath)
        except:
          print "Could not load report %s" % reportpath
          continue
        keys = args.keys
        if qrange.evalstr( reportpath, args.TEST):
            if keys == None:
               print "%s\t%s\t is True" % (reportpath, args.TEST )
            else:
               err=False
               line=''
               line_=''
               errmsg=''

               try:
                 abstime = float( report['SEQ']['abstime'])
                 date =  absstart + datetime.timedelta( seconds = abstime)
                 line_ = date.strftime('%a %d-%b-%Y %H:%M\t\t')
               except KeyError:
                 err= True
                 errstr = '#...Failed to get SEQ:abstime from #%s\n' % (reportpath)
Beispiel #7
0

  args = parser.parse_args()

  #print args.range
  #print args.XKEY
  #print args.YKEYS

  rangestr = args.range.replace(':','to')
  rangestr = rangestr.replace(',','_')
  shots = qrange.parse_range(args.range)

  data = []
  for s in shots:
      report = ConfigObj( 'report'+s+'.INI')
      line = [ qrange.evalstr( report, args.XKEY ) ] 
      for Y in args.YKEYS:
          line.append( qrange.evalstr( report, Y)  )
      data.append(line)
  
  dat = np.array(data)
  #print dat

  out = statdat.statdat( dat, 0, 1)[:,0]
 
  header = '#\n# Column index\n#  0  %s\n' % args.XKEY
  for i,Y in enumerate(args.YKEYS):
      header = header + '#  %d  %s\n' % ( 3*i+1, Y )
      header = header + '#  %d  %s\n' % ( 3*i+2, 'standard deviation' )
      header = header + '#  %d  %s\n' % ( 3*i+3, 'standard error of the mean' )
      header = header + '#  %d  %s\n' % ( 3*i+4, 'pk-pk' )