예제 #1
0
def test_fft_part():
    # Ramses data
    ioutput = 193
    ro = RamsesOutput("/data/Aquarius/output/", ioutput)
    parts = ro.particle_source(["mass", "level"])

    # Map operator : mass
    scal_func = ScalarOperator(lambda dset: dset["mass"])

    # Map region
    center = [0.567811, 0.586055, 0.559156]

    # Map processing
    mp = fft_projection.MapFFTProcessor(parts, ro.info)

    axname = "los"
    axis = [-0.172935, 0.977948, -0.117099]

    cam  = Camera(center=center, line_of_sight_axis=axis, up_vector="z", region_size=[5.0E-1, 4.5E-1], \
      distance=2.0E-1, far_cut_depth=2.0E-1, map_max_size=100)
    map = mp.process(scal_func, cam, surf_qty=True)

    #h5f = tables.openFile("./long_tests/fft_part.h5", mode='w')
    #h5f.createArray("/", "map", map)
    #h5f.close()

    h5f = tables.openFile("./long_tests/fft_part.h5", mode='r')
    mapB = h5f.getNode("/map").read()
    h5f.close()

    #print map
    assert (map - mapB).all() < 10e-6
예제 #2
0
def test_sph_profile():
    # Halo parameters
    halo_center = [0.567811, 0.586055, 0.559156]  # in box units
    halo_radius = 0.00075  # in box units

    # RamsesOutput
    ro = RamsesOutput("/data/Aquarius/output", 193)

    # Prepare to read the mass/epoch fields only
    source = ro.particle_source(["mass", "epoch"])

    # Sphere region
    sph = Sphere(halo_center, halo_radius)

    # Filtering particles
    point_dset = RegionFilter(sph, source)
    dm_filter = lambda dset: dset["epoch"] == 0.0
    dm_parts = PointFunctionFilter(dm_filter, point_dset)

    # Profile computation
    m_weight_func = lambda dset: dset["mass"]
    r_bins = numpy.linspace(0.0, halo_radius, 200)

    # Mass profile
    # This triggers the actual reading of the particle data files from disk.
    mass_profile = bin_spherical(dm_parts,
                                 halo_center,
                                 m_weight_func,
                                 r_bins,
                                 divide_by_counts=False)

    # Density profile
    sph_vol = 4.0 / 3.0 * numpy.pi * r_bins**3
    shell_vol = numpy.diff(sph_vol)
    rho_profile = mass_profile / shell_vol

    # Plot
    # Geometrical midpoint of the bins
    length = ro.info["unit_length"].express(C.kpc)
    bins_centers = (r_bins[1:] + r_bins[:-1]) / 2. * length
    dens = ro.info["unit_density"].express(C.Msun / C.kpc**3)

    #h5f = tables.openFile("./long_tests/sph_profile.h5", mode='w')
    #h5f.createArray("/", "sph_profile", rho_profile)
    #h5f.close()

    h5f = tables.openFile("./long_tests/sph_profile.h5", mode='r')
    rho_profileB = h5f.getNode("/sph_profile").read()
    h5f.close()

    #print rho_profile
    assert (rho_profile - rho_profileB).all() < 10e-6