@@ -0,0 +1,1535 @@
+import numpy as np%0Aimport h5py as hdf%0Afrom addHaloInfo import find_indices%0Afrom multiprocessing import Pool, cpu_count, current_process%0Afrom itertools import izip, repeat%0Afrom os import environ%0Aimport sys%0Afrom scipy.stats import anderson, shapiro%0A%0Adef mp_worker((h, data)):%0A    if len(h) %3C 10:%0A        return -1., -1, -1%0A    else:%0A        LOSV = data%5B'LOSV'%5D%5Bh%5D%0A        A2, critical, _ = anderson(LOSV)%0A        w, p = shapiro(LOSV)%0A%0A    return A2, critical, w%0A%0Adef mp_worker_wrapper(*args):%0A    return mp_worker(*args)%0A%0Adef start_process():%0A    print 'Starting', current_process().name%0A%0Adef main(start=None, end=None):%0A    with hdf.File('out1204878_allGalaxies_props.hdf5', 'r') as f:%0A        dset = f%5Bf.keys()%5B0%5D%5D%0A        data = dset%5B'LOSV', 'HALOID'%5D%0A%0A    hids = np.unique(data%5B'HALOID'%5D)%0A    halos = np.array(find_indices(data%5B'HALOID'%5D, hids))%0A%0A    p = Pool(cpu_count(), maxtasksperchild=1, initializer=start_process)%0A%0A    result = p.map(mp_worker_wrapper, izip(halos, repeat(data)),%0A            chunksize=500)%0A%0A    p.close()%0A    p.join()%0A%0A    finalResult = np.ones(hids.shape, dtype=%5B('HALOID', '%3Ei8'),%0A        ('A2', '%3Ef4'),  ('CRIT', '%3E(5,)f4'),  ('SW-P', '%3Ef4')%5D)%0A    finalResult%5B'HALOID'%5D = hids%0A    for i, (A2, C, W) in enumerate(result):%0A        finalResult%5B'A2'%5D%5Bi%5D = A2%0A        finalResult%5B'CRIT'%5D%5Bi%5D = C%0A        finalResult%5B'SW-P'%5D%5Bi%5D = W%0A%0A    with hdf.File('out1204878_allGalaxies_ADSW.hdf5', 'w') as f:%0A        f%5B'DSresult'%5D = finalResult%0A        f.flush()%0A%0A    return finalResult%0Aif __name__ == %22__main__%22:%0A    main()%0A

calculate the Anderson Darling test