#  for j in range(242,251):
    #    args.pixels_2.append( (i,j) )

    # args.roi_2 = [16,15,4,4] # 16x16 BINNING
    # args.roi_2 = [59,54,16,16] # 4x4 BINNING

    import monitordir
    import os
    import time

    # Set the directory where png's will be saved
    args.path = "braggdata/"

    if args.range != None:
        print "average = ", args.average
        shots = qrange.parse_range(args.range)
        args.shots = shots
        if args.average == False:
            for shot in shots:
                analyze_shot(int(shot), args)
            print ""
            exit(0)
        else:
            analyze_shot(int(shots[0]), args, average=True)
            print ""
            exit(0)

    path = os.getcwd()
    exprs = ["/????atoms.manta", "/????atoms.fits", "/????atoms_andor2.fits"]

    last = monitordir.get_last_shot(path, exprs)