Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Best used in ipython notebook
- import yt
- import numpy as np
- import matplotlib.pyplot as plt
- %matplotlib inline
- npart = 1024
- data = dict(particle_mass = np.random.random(size=npart),
- particle_position_x = np.random.random(size=npart),
- particle_position_y = np.random.random(size=npart),
- particle_position_z = np.random.random(size=npart)
- )
- # Move one particle to other corner
- data['particle_position_x'][-1] = 1.5
- data['particle_position_y'][-1] = 1.5
- ds = yt.load_particles(data, bbox = np.array([[0.0, 2.0], [0.0, 2.0], [0.0, 2.0]]))
- ## This is what we want to obtain as uniformly gridded data
- yt.ProjectionPlot(ds, 'z', ('deposit', 'all_cic'))
- ## Create two grids with different refinements
- level = ds.index.max_level
- dims = ds.domain_dimensions * ds.refine_by**level
- cg0 = ds.covering_grid(0, left_edge=ds.domain_left_edge, dims = ds.domain_dimensions)
- cg1 = ds.covering_grid(level, left_edge=ds.domain_left_edge, dims = dims)
- # Here the data from the one moved particle seems to be missing
- plt.imshow(np.sum(np.array(cg1['all_cic'])[:,:,:],axis=2),interpolation='none')
- # ...although it is here
- plt.imshow(np.sum(np.array(cg0['all_cic'])[:,:,:],axis=2),interpolation='none')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement