yt.geometry_tests / all_functionality.py

from yt.mods import *
pf = load("JHK-DD0030/galaxy0030")

#v, c = pf.h.find_max("Density")
c = [0.5, 0.5, 0.5]

fields = ["dm_density",
          "particle_type", "CellMassMsun", "x", "Density", "Ones", "Entropy",
          "particle_position_x", "particle_velocity_x", "ParticleMassMsun",
         ]

def do(obj):
    print "GOT", obj._type_name
    for field in fields:
        ff = obj[field]
        print "% 25s % 15i" % (field, ff.size)
    assert na.all(obj["Density"] == obj["gas","Density"])
    print

do(pf.h.sphere([0.5,0.5,0.5], (10.0, 'kpc')))
do(pf.h.ortho_ray(0, (c[x_dict[0]], c[y_dict[0]])))
do(pf.h.slice(0, c[0]))
do(pf.h.disk([0.5,0.5,0.5], [0.1, 0.3, 0.6], (10.0,'kpc'), (1.0,'kpc')))
do(pf.h.cutting([0.1, 0.3, 0.6], [0.5,0.5,0.5]))
do(pf.h.all_data())

sp = pf.h.sphere(c, (10.0, 'kpc'))
coords = {'f':{}, 'i':{}}
for t in ["io", "all", "spatial"]:
    coords['i'][t] = []
    coords['f'][t] = []
    for chunk in sp.chunks(None, t):
        coords['f'][t].append(chunk.fcoords[:,:])
        coords['i'][t].append(chunk.icoords[:,:])
    coords['f'][t] = na.concatenate(coords['f'][t])
    coords['i'][t] = na.concatenate(coords['i'][t])
    coords['i'][t].sort()
    coords['f'][t].sort()

print
print "="*30
for t, ic in sorted(coords['f'].items()):
    print "% 10s % 5.7f % 5.7f % 5.7f" % (t, ic.min(), ic.max(), ic.sum())
for t, ic in sorted(coords['i'].items()):
    print "% 10s % 15i % 15i % 15i" % (t, ic.min(), ic.max(), ic.sum())

print "="*30
assert(coords['i']["io"].size == coords['i']["all"].size)
assert(coords['i']["io"].size == coords['i']["spatial"].size)
assert(coords['f']["io"].size == coords['f']["all"].size)
assert(coords['f']["io"].size == coords['f']["spatial"].size)
print "Assertions passed."
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.