Пример #1
0
def run_mpi():
    print "Rank :", rank, "started"
    npix = hp.nside2npix(config.nside_out)
    dim, ind_elements = cov_ut.get_dim(config.pol_type)
    bolo_list = [None, None, None]

    inv_cov_matrix_local = np.zeros((npix, ind_elements), dtype=np.float)
    b_matrix_local = np.zeros((npix, dim), dtype=np.float)
    hitmap_local = np.zeros(npix, dtype=np.float)

    bolo_segment_dict = get_local_bolo_segment_list(rank, size, config.bolo_list, config.segment_list)

    time.sleep(0.1*rank)
    print "Rank :", rank, ", Bolos and Segments :", bolo_segment_dict
    comm.Barrier()

    recon_dir = get_recon_dir()
    if rank == 0:
        make_data_dirs() 

    for bolo_name in bolo_segment_dict.keys():
        print "Rank :", rank, "Bolos class being generated"
        bolo_list = initialise_bolo(bolo_name, bolo_list)
        for segment in bolo_segment_dict[bolo_name]:
            prompter.prompt("Rank : %d doing Bolo : %s and segment : %d" % (rank, bolo_name, segment))
            if config.take_diff_signal:
                signal, v, pol_ang = acquire_difference_signal(bolo_a, bolo_b, segment)
            else:
                signal, v, pol_ang = acquire_signal(bolo, segment)
            if config.subtract_template:
                signal_TEMPLATE = bolo_TEMPLATE.read_timestream(segment, read_list=["signal"])["signal"]
                signal -= estimated_y*signal_TEMPLATE
            print "Rank :", rank, "Bolos signal read"
            hitpix = hp.vec2pix(config.nside_out, v[...,0], v[...,1], v[...,2])
            del v
            cov_ut.get_inv_cov_matrix(hitpix, pol_ang, signal, inv_cov_matrix_local, b_matrix_local, hitmap_local, npix, config.pol_type)
            print "Rank :", rank, "Inverse covariance matrix generated"

    if config.subtract_template:
        del signal_TEMPLATE
    del signal
    del pol_ang
    del hitpix

    inv_cov_matrix_local_segment = distribute_matrix(inv_cov_matrix_local, "cov_matrix")
    del inv_cov_matrix_local
    b_matrix_local_segment = distribute_matrix(b_matrix_local, "b_matrix")
    del b_matrix_local
    hitmap_local_segment = distribute_matrix(hitmap_local, "hitmap")
    del hitmap_local

    cov_matrix_local_segment = cov_ut.get_covariance_matrix(inv_cov_matrix_local_segment, hitmap_local_segment, config.pol_type)

    sky_map_local_segment = cov_ut.get_sky_map(cov_matrix_local_segment, b_matrix_local_segment, hitmap_local_segment, config.pol_type)

    write_segments(hitmap_local_segment, "hitmap", recon_dir) 
    write_segments(inv_cov_matrix_local_segment, "inverse_covariance_matrix", recon_dir) 
    write_segments(cov_matrix_local_segment, "covariance_matrix", recon_dir) 
    write_segments(sky_map_local_segment, "sky_map", recon_dir) 
Пример #2
0
def run_mpi():
    if rank == 0:
        make_data_dirs()

    bolo_segment_dict = get_local_bolo_segment_list(rank, size, config.bolo_list, config.segment_list)
    comm.Barrier()
    time.sleep(0.1*rank)
    print "Rank :", rank, "Local bolo segment list :\n", bolo_segment_dict
    comm.Barrier()

    tot_seg = 0
    for keys in bolo_segment_dict.keys():
        tot_seg += len(bolo_segment_dict[keys])

    if "hitmap" in config.timestream_data_products:
        hitmap_local = np.zeros(hp.nside2npix(config.nside_in))

    for bolo_name in bolo_segment_dict.keys():
        bolo = Bolo(bolo_name, config)
        for segment in bolo_segment_dict[bolo_name]:
            start_seg = time.time()
            prompter.prompt("Doing Bolo : %s Segment : %d Rank : %d" % (bolo_name, segment+1, rank))
            if "hitmap" in config.timestream_data_products:
                hitmap_local += bolo.simulate_timestream(segment)
            else:
                bolo.simulate_timestream(segment)
            stop_seg = time.time()
            prompter.prompt("Rank : " + str(rank) + " Time taken : " + str(stop_seg - start_seg) + ". Projected time : " + str((stop_seg - start_seg)*tot_seg))

    prompter.prompt("Done simulating")

    
    if "hitmap" in config.timestream_data_products:
        hitmap = np.zeros(hitmap_local.size)

        comm.Reduce(hitmap_local, hitmap, MPI.SUM, 0)
        
        scan_dir = os.path.join(config.general_data_dir, config.sim_tag, config.scan_tag)
        if rank == 0:
            hp.write_map(os.path.join(scan_dir, "hitmap_in.fits"), hitmap)