Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from yt.mods import *
- pf = load('plt_derr_perr_grav_00100')
- # We'll use 2 fields for our MVTF
- field1 = 'density'
- field2 = 'Temp'
- dd = pf.h.all_data()
- mi, ma = dd.quantities['Extrema'](field1)[0]
- tmi, tma = dd.quantities['Extrema'](field2)[0]
- mi, ma = np.log10(mi), np.log10(ma)
- tmi, tma = np.log10(tmi), np.log10(tma)
- den_x_bounds = (mi-1, ma+1)
- temp_x_bounds = (tmi-1, tma+1)
- nbins = 1.0e6
- # We'll use logs here
- pf.field_info[field1].take_log=True
- pf.field_info[field2].take_log=True
- # Initialize the MVTF
- mv = MultiVariateTransferFunction()
- # Create our transfer functions--note that we'll be using a
- # combination of both blue and green for temperature, and red
- # for density
- red = TransferFunction(den_x_bounds, nbins)
- blue_green = TransferFunction(temp_x_bounds, nbins)
- alpha = TransferFunction(den_x_bounds, nbins)
- # Add our transfer function to the MVTF. By saying red's
- # field_id is 0, we are also saying that 0 will be the index
- # for density in the camera object's field list
- mv.add_field_table(red, 0)
- mv.add_field_table(blue_green, 1)
- mv.add_field_table(alpha, 0)
- # Link channels. This is where we specify that we want 'red'
- # to go to the red channel, etc.
- mv.link_channels(0,0)
- mv.link_channels(1,[1,2])
- mv.link_channels(2,3)
- # Add gaussians to our transfer functions--this can be done
- # any time after they are created
- locs = [np.log10(1.2e7), np.log10(5.0e6)]
- wi = [1.0e-6, 1.0e-4]
- h = 20.0
- red.add_gaussian(locs[0], wi[1], h)
- red.add_gaussian(locs[1], wi[1], h)
- blue_green.add_gaussian(locs[0], wi[0], h)
- mv.grey_opacity=False
- # Initialize the camera with the correct field list, take a
- # snapshot, and save the image
- c = [5.0e9, 5.0e9, 5.0e9]
- L = [0.15, 1.0, 0.40]
- W = (pf.domain_right_edge - pf.domain_left_edge)*0.7
- Nvec = 1024
- cam = pf.h.camera(c, L, W, (Nvec,Nvec), transfer_function = mv,
- fields=['density', 'Temp'], pf=pf, no_ghost=True)
- im = cam.snapshot(num_threads=4)
- im.write_png('den_temp_mvtf.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement