Guest User

mvtf

a guest
Aug 1st, 2013
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from yt.mods import *
  2.  
  3. pf = load('plt_derr_perr_grav_00100')
  4.  
  5. # We'll use 2 fields for our MVTF
  6. field1 = 'density'
  7. field2 = 'Temp'
  8.  
  9. dd = pf.h.all_data()
  10. mi, ma = dd.quantities['Extrema'](field1)[0]
  11. tmi, tma = dd.quantities['Extrema'](field2)[0]
  12. mi, ma = np.log10(mi), np.log10(ma)
  13. tmi, tma = np.log10(tmi), np.log10(tma)
  14.  
  15. den_x_bounds = (mi-1, ma+1)
  16. temp_x_bounds = (tmi-1, tma+1)
  17. nbins = 1.0e6
  18.  
  19. # We'll use logs here
  20. pf.field_info[field1].take_log=True
  21. pf.field_info[field2].take_log=True
  22.  
  23.  
  24. # Initialize the MVTF
  25. mv = MultiVariateTransferFunction()
  26.  
  27. # Create our transfer functions--note that we'll be using a
  28. # combination of both blue and green for temperature, and red
  29. # for density
  30. red = TransferFunction(den_x_bounds, nbins)
  31. blue_green = TransferFunction(temp_x_bounds, nbins)
  32. alpha = TransferFunction(den_x_bounds, nbins)
  33.  
  34. # Add our transfer function to the MVTF. By saying red's
  35. # field_id is 0, we are also saying that 0 will be the index
  36. # for density in the camera object's field list
  37. mv.add_field_table(red, 0)
  38. mv.add_field_table(blue_green, 1)
  39. mv.add_field_table(alpha, 0)
  40.  
  41. # Link channels. This is where we specify that we want 'red'
  42. # to go to the red channel, etc.
  43. mv.link_channels(0,0)
  44. mv.link_channels(1,[1,2])
  45. mv.link_channels(2,3)
  46.  
  47. # Add gaussians to our transfer functions--this can be done
  48. # any time after they are created
  49. locs = [np.log10(1.2e7), np.log10(5.0e6)]
  50. wi = [1.0e-6, 1.0e-4]
  51. h = 20.0
  52.  
  53. red.add_gaussian(locs[0], wi[1], h)
  54. red.add_gaussian(locs[1], wi[1], h)
  55. blue_green.add_gaussian(locs[0], wi[0], h)
  56.  
  57. mv.grey_opacity=False
  58.  
  59. # Initialize the camera with the correct field list, take a
  60. # snapshot, and save the image
  61. c = [5.0e9, 5.0e9, 5.0e9]
  62. L = [0.15, 1.0, 0.40]
  63. W = (pf.domain_right_edge - pf.domain_left_edge)*0.7
  64. Nvec = 1024
  65.  
  66. cam = pf.h.camera(c, L, W, (Nvec,Nvec), transfer_function = mv,
  67.                   fields=['density', 'Temp'], pf=pf, no_ghost=True)
  68. im = cam.snapshot(num_threads=4)
  69. im.write_png('den_temp_mvtf.png')
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×