Пример #1
0
def make_plots(dataset, yt_version, center_max):
    catalog = _get_datafiles()
    kwargs = catalog[dataset + '.tar.gz'].get("load_kwargs", {})
    if yt_version == 3:
        sys.path.insert(0, YT3_PATH)
        field_key = 'yt4'
        #weight_default = ("deposit", "gas_density")
        weight_default = ("gas", "density")
        import yt
        click.echo(yt)
        ds = yt.load(f"{dataset}.tar.gz.untar/{dataset}/{catalog[dataset + '.tar.gz']['load_name']}", **kwargs)
    elif yt_version == 4:
        sys.path.insert(0, YT4_PATH)
        field_key = 'yt4'
        weight_default = ("gas", "density")
        import yt
        click.echo(yt)
        ds = yt.load_sample(dataset)
    else:
        raise click.BadParameter('yt version must be 3 or 4')
    click.echo(ds)
    os.makedirs(dataset, exist_ok = True)
    plot_index = 0
    for field in field_spec['fields']:
        f = tuple(field[field_key])
        weights = [weight_default]
        if field['weight_none']:
            weights.append(None)
        for weight in weights:
            if weight is not None:
                w = tuple(weight)
                wn = f"{w[1]}"
            else:
                w = None
                wn = "None"
            for ax in field_spec['axis']:
                if center_max:
                    center = "max"
                else:
                    center = "c"
                p = yt.ProjectionPlot(ds, ax, f, weight_field = w, center = center)
                for zoom in field_spec['zoom']:
                    p.set_width(1.0, 'unitary')
                    p.zoom(zoom)
                    p.set_cmap("all", field['colormap'])
                    fn = f"{dataset}/yt{yt_version}_p{plot_index:04d}_proj_{f[1]}_{wn}_{ax}_z{zoom:03d}.png"
                    click.echo(f"Saving {fn}")
                    p.save(fn)
                    append_saved_file(dataset, f"yt{yt_version}", 
                                      {'field_key': f"{f[1]}_{wn}", 'axis': ax, 
                                       'zoom': zoom, 'filename': fn,
                                       'plot_index': plot_index, 'center_max': center_max})
                    plot_index += 1
Пример #2
0
from dask.distributed import Client
from dask_chunking import gadget as ga
import sys
import time

if __name__ == '__main__':
    # spin up the dask client  (NEEDS to be within __main__)

    c = None
    if len(sys.argv) > 1 and int(sys.argv[1]) > 1:
        print(f"Starting dask Client with {sys.argv[1]} processors")
        c = Client(threads_per_worker=1, n_workers=int(sys.argv[1]))
        print("client started...")

    # load in gadget, set a selection
    ds = yt.load_sample("snapshot_033")
    ptf = {'PartType0': ['Mass']}
    sp = ds.sphere(ds.domain_center, (2, 'code_length'))

    select_time = time.time()
    glob_stats, chunk_stats = ga.selector_stats(ds, ptf, sp.selector)
    # glob_stats, chunk_stats = ga.selector_stats(ds,ptf) # for no selector
    select_time = time.time() - select_time

    print("\nlocal stats for each chunk:")
    for ch in chunk_stats:
        print(ch)

    print("\nglobal, cross-chunk stats")
    print(glob_stats)
Пример #3
0
import yt

import yt_idv

ds = yt.load_sample("MOOSE_Sample_data", "out.e-s010")

rc = yt_idv.render_context(height=800, width=800, gui=True)

from yt_idv.cameras.trackball_camera import TrackballCamera  # NOQA
from yt_idv.scene_components.mesh import MeshRendering  # NOQA
from yt_idv.scene_data.mesh import MeshData  # NOQA
from yt_idv.scene_graph import SceneGraph  # NOQA

c = TrackballCamera(position=[3.5, 3.5, 3.5], focus=[0.0, 0.0, 0.0])
rc.scene = SceneGraph(camera=c)

dd = ds.all_data()
md = MeshData(data_source=dd)
md.add_data(("connect1", "diffused"))
mr = MeshRendering(data=md, cmap_log=False)

rc.scene.data_objects.append(md)
rc.scene.components.append(mr)
rc.run()
Пример #4
0
import yt

ds = yt.load_sample("IsolatedGalaxy")

fields = ["density", "velocity_x", "velocity_y", "velocity_magnitude"]
p = yt.SlicePlot(ds, "z", fields)
p.set_log(("gas", "velocity_x"), False)
p.set_log(("gas", "velocity_y"), False)

# this returns a matplotlib figure with an ImageGrid and the slices
# added to the grid of axes (in this case, 2x2)
fig = p.export_to_mpl_figure((2, 2))

fig.tight_layout()

fig.savefig("multiplot_export_to_mpl.png")
Пример #5
0
import yt

import yt_idv

N = 400

ds = yt.load_sample("HiresIsolatedGalaxy")
c = [0.53, 0.53, 0.53]

rc = yt_idv.render_context("egl", width=1024, height=1024)
sc = rc.add_scene(ds, "density", no_ghost=False)
sc.components[0].render_method = "projection"
sc.camera.focus = c
sc.camera.position = [0.45, 0.44, 0.43]

ds = (sc.camera.focus - sc.camera.position) / N

for i in range(N):
    sc.components[0].cmap_min = sc.components[0].cmap_max = None
    sc.camera.position = sc.camera.position + ds
    sc.camera._update_matrices()
    rc.snap()
Пример #6
0
import yt

import yt_idv
from yt_idv.scene_components.octree_blocks import OctreeBlockRendering
from yt_idv.scene_data.octree_block_collection import OctreeBlockCollection

ds = yt.load_sample("output_00080")
dd = ds.all_data()

rc = yt_idv.render_context(height=800, width=800, gui=True)
sg = rc.add_scene(ds, None, no_ghost=True)

odata = OctreeBlockCollection(data_source=dd)
odata.add_data("density")
oren = OctreeBlockRendering(data=odata)

sg.data_objects.append(odata)
sg.components.append(oren)

rc.run()