Commits

Matthew Turk committed b354bea

Initial import of testing script for 3.0.

Comments (0)

Files changed (1)

+import sys; sys.path.insert(0, "/home/mturk/yt/yt-3.0")
+from yt.config import ytcfg; ytcfg["yt","serialize"]="False"
+from yt.mods import *
+from yt.testing import *
+from yt.frontends.sph.api import OWLSStaticOutput
+
+def make_plots(pf):
+    p = ProjectionPlot(pf, "x", "Density", weight_field="Density")
+    p.save()
+    p = SlicePlot(pf, "x", "Density")
+    p.save()
+
+def _get_dobjs(c):
+    dobjs = [("sphere", ("center", (1.0, "unitary"))),
+             ("sphere", ("center", (0.1, "unitary"))),
+             ("ortho_ray", (0, (c[x_dict[0]], c[y_dict[0]]))),
+             ("slice", (0, c[0])),
+             ("disk", ("center", [0.1, 0.3, 0.6],
+                        (0.2, 'unitary'), (0.1, 'unitary'))),
+             ("cutting", ([0.1, 0.3, 0.6], 'center')),
+             ("all_data", ()),
+            ]
+    return dobjs
+
+def chunking(pf):
+    c = (pf.domain_right_edge + pf.domain_left_edge)/2.0 
+    c += 0.5/pf.domain_dimensions
+    for dobj in _get_dobjs(c):
+        obj = getattr(pf.h, dobj[0])(*dobj[1])
+        coords = {'f':{}, 'i':{}}
+        for t in ["io", "all", "spatial"]:
+            coords['i'][t] = []
+            coords['f'][t] = []
+            for chunk in obj.chunks(None, t):
+                coords['f'][t].append(chunk.fcoords[:,:])
+                coords['i'][t].append(chunk.icoords[:,:])
+            coords['f'][t] = np.concatenate(coords['f'][t])
+            coords['i'][t] = np.concatenate(coords['i'][t])
+            coords['f'][t].sort()
+            coords['i'][t].sort()
+        assert_equal(coords['f']['io'], coords['f']['all'])
+        assert_equal(coords['f']['io'], coords['f']['spatial'])
+        assert_equal(coords['i']['io'], coords['i']['all'])
+        assert_equal(coords['i']['io'], coords['i']['spatial'])
+
+def selecting(pf):
+    c = (pf.domain_right_edge + pf.domain_left_edge)/2.0 
+    c += 0.5/pf.domain_dimensions
+    ffield = pfield = None
+    for field in sorted(pf.h.field_list):
+        if pf.field_info[field].particle_type:
+            pfield = field
+        else:
+            ffield = ffield
+    for dobj in _get_dobjs(c):
+        obj = getattr(pf.h, dobj[0])(*dobj[1])
+        print "%s: %s" % (dobj[0], dobj[1:])
+        obj["Ones"]
+        if ffield is not None:
+            print "    Selecting ", ffield,
+            obj[ffield]
+            print "(%s)" % (obj[ffield].size)
+        if pfield is not None:
+            print "    Selecting ", pfield,
+            obj[pfield]
+            print "(%s)" % (obj[pfield].size)
+
+pf1 = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+make_plots(pf1)
+chunking(pf1)
+selecting(pf1)
+
+pf2 = load("snapshot_033/snap_033.0.hdf5")
+#make_plots(pf1)
+#chunking(pf1)
+selecting(pf2)
+
+pf3 = load("output_00007/info_00007.txt")
+make_plots(pf3)
+#chunking(pf3)
+selecting(pf3)