Example #1
0
def visualize(files):
    output = []
    for fn in parallel_objects(files, njobs=-1):
        pf = load(fn)
        for field in FIELDS:
            slc = SlicePlot(pf, 'z', field)
            output.append(slc.save(fn.replace('.h5', '_%s.png' % field))[0])
    return output
Example #2
0
def visualize(files):
    output = []
    for fn in parallel_objects(files, njobs=-1):
        pf = load(fn)
        for field in FIELDS:
            slc = SlicePlot(pf, 'z', field)
            output.append(slc.save(fn.replace('.h5', '_%s.png' % field))[0])
    return output
Example #3
0
def visualize(files):
    output = []
    for fn in files:
        pf = load(fn)
        for field in FIELDS:
            slc = SlicePlot(pf, 'z', field)
            if field == "prei":
                slc.set_cmap(field, 'gist_stern')
            output.append(slc.save(fn.replace('.h5', '_%s.png' % field))[0])
    return output
Example #4
0
def visualize(files):
    output = []
    for fn in files:
        pf = load(fn)
        for field in FIELDS:
            slc = SlicePlot(pf, 'z', field)
            if field == "prei":
                slc.set_cmap(field, 'gist_stern')
            output.append(slc.save(fn.replace('.h5', '_%s.png' % field))[0])
    return output
Example #5
0
def test_axis_ordering_amr():

    # Regression test for axis ordering

    from .yt_compat import get_frb

    g = AMRGrid()

    level = g.add_level()

    grid = level.add_grid()
    grid.xmin, grid.xmax = -1, 1
    grid.ymin, grid.ymax = -2, 2
    grid.zmin, grid.zmax = -3, 3
    grid.nx, grid.ny, grid.nz = 8, 16, 32

    grid.quantities['density'] = []
    grid.quantities['density'].append(
        np.arange(grid.nz)[:, None, None] * np.ones(
            (grid.nz, grid.ny, grid.nx)))

    from yt.mods import ProjectionPlot, SlicePlot

    pf = g.to_yt()

    zw = np.linspace(-3, 3, 33)
    zcen = 0.5 * (zw[1:] + zw[:-1])

    for iz, z in enumerate(zcen):
        prj = SlicePlot(pf, 'z', ['density'], center=[0.0, 0.0, z])
        np.testing.assert_allclose(get_frb(prj, 'density').min(), iz)
        np.testing.assert_allclose(get_frb(prj, 'density').max(), iz)
Example #6
0
def visualize(files):
    output = []
    for fn in parallel_objects(files, njobs=-1):
        pf = load(fn)
        for field in FIELDS:
            slc = SlicePlot(pf, 'z', field)
            if field == 'curz':
                slc.set_cmap(field, 'bwr')
                maxabs = abs(slc._frb[field]).max()
                slc.set_log(field, False)
                slc.set_zlim(field, -maxabs, maxabs)
            output.append(slc.save(fn.replace('.h5', '_%s.png' % field))[0])
    return output
Example #7
0
def test_shadowing_regression(tmpdir):

    from ...grid.tests.yt_compat import get_frb

    # Regression test for a bug that caused photons escaping from some grids to
    # be terminated.

    amr = AMRGrid()

    level = amr.add_level()

    grid = level.add_grid()
    grid.xmin, grid.xmax = -1, 1
    grid.ymin, grid.ymax = -1, 1
    grid.zmin, grid.zmax = -1, 1
    grid.nx, grid.ny, grid.nz = 8, 8, 8
    grid.quantities['density'] = np.ones((grid.nz, grid.ny, grid.nx))

    level = amr.add_level()

    grid = level.add_grid()
    grid.xmin, grid.xmax = 0.5, 1
    grid.ymin, grid.ymax = -0.5, 0.5
    grid.zmin, grid.zmax = -0.5, 0.5
    grid.nx, grid.ny, grid.nz = 4, 8, 8
    grid.quantities['density'] = np.ones((grid.nz, grid.ny, grid.nx))

    m = Model()

    m.set_grid(amr)

    m.add_density_grid(amr['density'], get_test_dust())

    s = m.add_point_source()
    s.luminosity = 100
    s.temperature = 10000
    s.position = (0.0001, 0.0001, 0.0001)

    m.set_n_photons(initial=1e5, imaging=0)

    m.write(tmpdir.join(random_id()).strpath)
    mo = m.run(tmpdir.join(random_id()).strpath)

    from yt.mods import SlicePlot

    g = mo.get_quantities()

    pf = g.to_yt()

    prj = SlicePlot(pf,
                    'y', ['density', 'temperature'],
                    center=[0.0, 0.0, 0.0])

    # With bug, value was lower because there were shadowed regions
    assert 12. < get_frb(prj, 'temperature').min() < 13.
Example #8
0
def test_axis_ordering_cartesian():

    # Regression test for axis ordering

    from .yt_compat import get_frb

    x = np.linspace(-1, 1, 9)
    y = np.linspace(-2, 2, 17)
    z = np.linspace(-3, 3, 33)

    density = np.arange(32)[:, None, None] * np.ones((32, 16, 8))

    g = CartesianGrid(x, y, z)
    g['density'] = []
    g['density'].append(density)

    from yt.mods import ProjectionPlot, SlicePlot

    pf = g.to_yt()

    for iz, z in enumerate(g.z):
        prj = SlicePlot(pf, 'z', ['density'], center=[0.0, 0.0, z])
        np.testing.assert_allclose(get_frb(prj, 'density').min(), iz)
        np.testing.assert_allclose(get_frb(prj, 'density').max(), iz)