Guest User

Untitled

a guest
Oct 2nd, 2015
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Best used in ipython notebook
  2. import yt
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. %matplotlib inline
  6.  
  7.  
  8. npart = 1024
  9. data = dict(particle_mass = np.random.random(size=npart),
  10.             particle_position_x = np.random.random(size=npart),
  11.             particle_position_y = np.random.random(size=npart),
  12.             particle_position_z = np.random.random(size=npart)
  13.            )
  14. # Move one particle to other corner
  15. data['particle_position_x'][-1] = 1.5
  16. data['particle_position_y'][-1] = 1.5
  17.  
  18. ds = yt.load_particles(data, bbox = np.array([[0.0, 2.0], [0.0, 2.0], [0.0, 2.0]]))
  19.  
  20. ## This is what we want to obtain as uniformly gridded data
  21. yt.ProjectionPlot(ds, 'z', ('deposit', 'all_cic'))
  22.  
  23. ## Create two grids with different refinements
  24. level = ds.index.max_level
  25. dims = ds.domain_dimensions * ds.refine_by**level
  26. cg0 = ds.covering_grid(0, left_edge=ds.domain_left_edge, dims = ds.domain_dimensions)
  27. cg1 = ds.covering_grid(level, left_edge=ds.domain_left_edge, dims = dims)
  28.  
  29. # Here the data from the one moved particle seems to be missing
  30. plt.imshow(np.sum(np.array(cg1['all_cic'])[:,:,:],axis=2),interpolation='none')
  31. # ...although it is here
  32. plt.imshow(np.sum(np.array(cg0['all_cic'])[:,:,:],axis=2),interpolation='none')
RAW Paste Data