name = MPI.Get_processor_name()

p = argparse.ArgumentParser()
p.add_argument("--detX", default=50)
p.add_argument("--detY", default=50)
p.add_argument("--detOffsetX", default=-1028.607)
p.add_argument("--detOffsetY", default=-1016.952)
p.add_argument("--sdd", default=374.836)
p.add_argument("--samLength", default=20)
p.add_argument("--samRadius", default=0.75)
p.add_argument("--N", default=1000)
p.add_argument("--o", default=None)
args = p.parse_args()

det = Detector(int(args.detX), int(args.detY))
det.SDD = float(args.sdd)
xd_off = float(args.detOffsetX)
yd_off = float(args.detOffsetY)
det.detector_offset(xd_off, yd_off)
sam = Sample(float(args.samLength), float(args.samRadius))
N = int(args.N)

if rank == 0:
    from snippets import generate_photon_statistics

    batchSize = size - 1
    numPixels = det.xdim * det.ydim
    arraySize, rest = numPixels / batchSize, numPixels % batchSize
    output = np.zeros([det.xdim * det.ydim])

    ranges = zip([cpuNode * arraySize for cpuNode in range(batchSize)],
Esempio n. 2
0

if __name__ == '__main__':
    p = argparse.ArgumentParser()
    p.add_argument("--detX", default=500)
    p.add_argument("--detY", default=500)
    p.add_argument("--N", default=1000)
    args = p.parse_args()

    slit_x, cdf_x = generate_photon_statistics(
        './slit_scan/slit_05x05_00001.fio', 1.1, True)
    slit_y, cdf_y = generate_photon_statistics(
        './slit_scan/slit_05x05_00002.fio', 2.3, True)

    det = Detector(int(args.detX), int(args.detY))
    det.SDD = 374.836
    xd_off = -1028.607
    yd_off = -1016.952
    det.detector_offset(xd_off, yd_off)
    sam = Sample(20, 0.75)
    N = int(args.N)
    t = time.time()
    pool = Pool(initializer=init,
                initargs=(det, sam, N, slit_x, cdf_x, slit_y, cdf_y))
    pool.map_async(calculateRowIntensity,
                   range(det.ydim),
                   callback=lambda output, det=det: writeOutput(det, output))
    pool.close()
    pool.join()
    print(time.time() - t)
    det.save_output(sam, N)