def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) cm = "coolwarm" field = ('boxlib', 'radial_velocity') ds._get_field_info(field).take_log = False sc = Scene() # add a volume: select a sphere #center = (0, 0, 0) #R = (5.e8, 'cm') #dd = ds.sphere(center, R) vol = VolumeSource(ds, field=field) sc.add_source(vol) # transfer function vals = [-5.e5, -2.5e5, -1.25e5, 1.25e5, 2.5e5, 5.e5] sigma = 3.e4 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "coolwarm" for v in vals: tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.get_source(0).transfer_function = tf cam = sc.add_camera(ds, lens_type="perspective") cam.resolution = (1080, 1080) cam.position = 1.0 * ds.domain_right_edge # look toward the center -- we are dealing with an octant center = ds.domain_left_edge normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(ds.domain_width) sc.camera = cam #sc.annotate_axes(alpha=0.05) #sc.annotate_domain(ds, color=np.array([0.05, 0.05, 0.05, 0.05])) #sc.annotate_grids(ds, alpha=0.05) sc.render() sc.save("{}_radvel".format(plotfile), sigma_clip=4.0)
def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) field = ('gas', 'velocity_z') ds._get_field_info(field).take_log = False sc = Scene() # add a volume: select a sphere #center = (0, 0, 0) #R = (5.e8, 'cm') #dd = ds.sphere(center, R) vol = VolumeSource(ds, field=field) vol.use_ghost_zones = True sc.add_source(vol) # transfer function vals = [-1.e7, -5.e6, 5.e6, 1.e7] sigma = 5.e5 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "coolwarm" for v in vals: tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.get_source(0).transfer_function = tf cam = sc.add_camera(ds, lens_type="perspective") cam.resolution = (1920, 1080) center = 0.5*(ds.domain_left_edge + ds.domain_right_edge) cam.position = [2.5*ds.domain_right_edge[0], 2.5*ds.domain_right_edge[1], center[2]+0.25*ds.domain_right_edge[2]] # look toward the center -- we are dealing with an octant normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(ds.domain_width) sc.camera = cam #sc.annotate_axes(alpha=0.05) #sc.annotate_domain(ds, color=np.array([0.05, 0.05, 0.05, 0.05])) #sc.annotate_grids(ds, alpha=0.05) sc.render() sc.save("{}_radvel".format(plotfile), sigma_clip=4.0) sc.save_annotated("{}_radvel_annotated.png".format(plotfile), sigma_clip=4.0, text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5,0.95), "Maestro simulation of convection in a mixed H/He XRB", dict(color="y", fontsize="24", horizontalalignment="center")]])
def doit(plotfile, fname): ds = yt.load(plotfile) cm = "gist_rainbow" if fname == "vz": field = ('gas', 'velocity_z') use_log = False vals = [-1.e7, -5.e6, 5.e6, 1.e7] sigma = 5.e5 fmt = None cm = "coolwarm" elif fname == "magvel": field = ('gas', 'velocity_magnitude') use_log = True vals = [1.e5, 3.16e5, 1.e6, 3.16e6, 1.e7] sigma = 0.1 elif fname == "enucdot": field = ('boxlib', 'enucdot') use_log = True vals = [1.e16, 3.162e16, 1.e17, 3.162e17, 1.e18] vals = list(10.0**numpy.array([16.5, 17.0, 17.5, 18.0, 18.5])) sigma = 0.05 fmt = "%.3g" # this is hackish, but there seems to be no better way to set whether # you are rendering logs ds._get_field_info(field).take_log = use_log # hack periodicity ds.periodicity = (True, True, True) mi = min(vals) ma = max(vals) if use_log: mi, ma = np.log10(mi), np.log10(ma) print mi, ma # setup the scene and camera sc = Scene() cam = Camera(ds, lens_type="perspective") # Set up the camera parameters: center, looking direction, width, resolution center = (ds.domain_right_edge + ds.domain_left_edge)/2.0 xmax, ymax, zmax = ds.domain_right_edge # this shows something face on c = np.array([-8.0*xmax, center[1], center[2]]) # the normal vector should be pointing back through the center L = center.d - c L = L/np.sqrt((L**2).sum()) north_vector=[0.0,0.0,1.0] cam.position = ds.arr(c) cam.switch_orientation(normal_vector=L, north_vector=north_vector) cam.set_width(ds.domain_width*4) cam.resolution = (720,720) # create the volume source vol = VolumeSource(ds, field=field) # Instantiate the ColorTransferfunction. tf = vol.transfer_function tf = ColorTransferFunction((mi, ma)) #tf.grey_opacity=True for v in vals: if use_log: tf.sample_colormap(math.log10(v), sigma**2, colormap=cm) #, alpha=0.2) else: print v tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.camera = cam sc.add_source(vol) sc.render("test_perspective.png", clip_ratio=6.0)
def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) cm = "coolwarm" field = ('boxlib', 'density') ds._get_field_info(field).take_log = True sc = Scene() # add a volume: select a sphere vol = VolumeSource(ds, field=field) sc.add_source(vol) # transfer function vals = [-1, 0, 1, 2, 4, 5, 6, 7] #vals = [0.1, 1.0, 10, 100., 1.e4, 1.e5, 1.e6, 1.e7] sigma = 0.1 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "coolwarm" cm = "spectral" for v in vals: if v < 4: alpha = 0.1 else: alpha = 0.5 tf.sample_colormap(v, sigma**2, colormap=cm, alpha=alpha) sc.get_source(0).transfer_function = tf cam = Camera(ds, lens_type="perspective") cam.resolution = (1280, 720) cam.position = 1.5*ds.arr(np.array([0.0, 5.e9, 5.e9]), 'cm') # look toward the center -- we are dealing with an octant center = 0.5*(ds.domain_left_edge + ds.domain_right_edge) normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(ds.domain_width) sc.camera = cam #sc.annotate_axes() #sc.annotate_domain(ds) pid = plotfile.split("plt")[1] sc.render() sc.save("wdmerger_{}.png".format(pid), sigma_clip=6.0) sc.save_annotated("wdmerger_annotated_{}.png".format(pid), text_annotate=[[(0.05, 0.05), "t = {:.3f}".format(float(ds.current_time.d)), dict(horizontalalignment="left")], [(0.5,0.95), "Castro simulation of merging white dwarfs", dict(color="y", fontsize="24", horizontalalignment="center")]])
def doit(plotfile): ds = CastroDataset(plotfile) ds._periodicity = (True, True, True) field = ('boxlib', 'enuc') ds._get_field_info(field).take_log = True sc = Scene() # add a volume: select a sphere #center = (0, 0, 0) #R = (5.e8, 'cm') #dd = ds.sphere(center, R) vol = create_volume_source(ds.all_data(), field=field) sc.add_source(vol) # transfer function vals = [16.5, 17.0, 17.5, 18.0, 18.5, 19.0, 19.5] sigma = 0.1 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cmap = "viridis" for v in vals: if v < 19.0: alpha = 0.25 else: alpha = 0.75 tf.sample_colormap(v, sigma**2, alpha=alpha, colormap=cmap) sc.get_source(0).transfer_function = tf cam = sc.add_camera(ds, lens_type="perspective") cam.resolution = (1920, 1280) # view 1 cam.position = [ 0.75 * ds.domain_right_edge[0], 0.5 * (ds.domain_left_edge[1] + ds.domain_right_edge[1]), ds.domain_right_edge[2] ] # + 0.25 * (ds.domain_right_edge[2] - ds.domain_left_edge[2])] # look toward the center center = 0.5 * (ds.domain_left_edge + ds.domain_right_edge) # set the center in the vertical direction to be the height of the underlying base layer center[-1] = 2000 * cm normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(3 * ds.domain_width) cam.zoom(3.0) sc.camera = cam sc.save_annotated( "{}_Hnuc_annotated_side.png".format(plotfile), text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5, 0.95), "Castro simulation of XRB flame spreading", dict(color="y", fontsize="24", horizontalalignment="center")]]) # view 2 dx = ds.domain_right_edge[0] - ds.domain_left_edge[0] cam.position = [ 0.5 * (ds.domain_left_edge[0] + ds.domain_right_edge[0]) + 0.0001 * dx, 0.5 * (ds.domain_left_edge[1] + ds.domain_right_edge[1]), ds.domain_right_edge[2] ] # + 0.25 * (ds.domain_right_edge[2] - ds.domain_left_edge[2])] # look toward the center center = 0.5 * (ds.domain_left_edge + ds.domain_right_edge) # set the center in the vertical direction to be the height of the underlying base layer center[-1] = 2000 * cm normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(3 * ds.domain_width) cam.zoom(0.6) sc.camera = cam sc.save_annotated( "{}_Hnuc_annotated_top.png".format(plotfile), text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5, 0.95), "Castro simulation of XRB flame spreading", dict(color="y", fontsize="24", horizontalalignment="center")]])
def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) cm = "coolwarm" field = ('boxlib', 'radial_velocity') ds._get_field_info(field).take_log = False sc = Scene() # add a volume: select a sphere center = (0, 0, 0) R = (5.e8, 'cm') dd = ds.sphere(center, R) vol = VolumeSource(dd, field=field) sc.add_source(vol) # transfer function vals = [-5.e6, -2.5e6, -1.25e6, 1.25e6, 2.5e6, 5.e6] sigma = 3.e5 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "coolwarm" for v in vals: tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.get_source(0).transfer_function = tf cam = Camera(ds, lens_type="perspective") cam.resolution = (1280, 720) cam.position = 1.5*ds.arr(np.array([5.e8, 5.e8, 5.e8]), 'cm') # look toward the center -- we are dealing with an octant center = ds.domain_left_edge normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(ds.domain_width) sc.camera = cam #sc.annotate_axes() #sc.annotate_domain(ds) sc.render() sc.save("subchandra_test.png", sigma_clip=6.0) sc.save_annotated("subchandra_test_annotated.png", text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5,0.95), "Maestro simulation of He convection on a white dwarf", dict(color="y", fontsize="24", horizontalalignment="center")]])
def doit(plotfile, fname): ds = yt.load(plotfile) cm = "gist_rainbow" if fname == "vz": field = ('gas', 'velocity_z') use_log = False vals = [-1.e7, -5.e6, 5.e6, 1.e7] sigma = 5.e5 fmt = None cm = "coolwarm" elif fname == "magvel": field = ('gas', 'velocity_magnitude') use_log = True vals = [1.e5, 3.16e5, 1.e6, 3.16e6, 1.e7] sigma = 0.1 elif fname == "enucdot": field = ('boxlib', 'enucdot') use_log = True vals = [1.e16, 3.162e16, 1.e17, 3.162e17, 1.e18] vals = list(10.0**numpy.array([16.5, 17.0, 17.5, 18.0, 18.5])) sigma = 0.05 fmt = "%.3g" # this is hackish, but there seems to be no better way to set whether # you are rendering logs ds._get_field_info(field).take_log = use_log # hack periodicity ds.periodicity = (True, True, True) mi = min(vals) ma = max(vals) if use_log: mi, ma = np.log10(mi), np.log10(ma) print mi, ma # setup the scene and camera sc = Scene() cam = Camera(ds, lens_type="perspective") # Set up the camera parameters: center, looking direction, width, resolution center = (ds.domain_right_edge + ds.domain_left_edge) / 2.0 xmax, ymax, zmax = ds.domain_right_edge # this shows something face on c = np.array([-8.0 * xmax, center[1], center[2]]) # the normal vector should be pointing back through the center L = center.d - c L = L / np.sqrt((L**2).sum()) north_vector = [0.0, 0.0, 1.0] cam.position = ds.arr(c) cam.switch_orientation(normal_vector=L, north_vector=north_vector) cam.set_width(ds.domain_width * 4) cam.resolution = (720, 720) # create the volume source vol = VolumeSource(ds, field=field) # Instantiate the ColorTransferfunction. tf = vol.transfer_function tf = ColorTransferFunction((mi, ma)) #tf.grey_opacity=True for v in vals: if use_log: tf.sample_colormap(math.log10(v), sigma**2, colormap=cm) #, alpha=0.2) else: print v tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.camera = cam sc.add_source(vol) sc.render("test_perspective.png", clip_ratio=6.0)
def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) field = ('gas', 'velocity_z') ds._get_field_info(field).take_log = False sc = Scene() # add a volume: select a sphere #center = (0, 0, 0) #R = (5.e8, 'cm') #dd = ds.sphere(center, R) vol = VolumeSource(ds, field=field) vol.use_ghost_zones = True sc.add_source(vol) # transfer function vals = [-1.e7, -5.e6, 5.e6, 1.e7] sigma = 5.e5 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "coolwarm" for v in vals: tf.sample_colormap(v, sigma**2, colormap=cm) #, alpha=0.2) sc.get_source(0).transfer_function = tf cam = sc.add_camera(ds, lens_type="perspective") cam.resolution = (1920, 1080) center = 0.5 * (ds.domain_left_edge + ds.domain_right_edge) cam.position = [ 2.5 * ds.domain_right_edge[0], 2.5 * ds.domain_right_edge[1], center[2] + 0.25 * ds.domain_right_edge[2] ] # look toward the center -- we are dealing with an octant normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(ds.domain_width) sc.camera = cam #sc.annotate_axes(alpha=0.05) #sc.annotate_domain(ds, color=np.array([0.05, 0.05, 0.05, 0.05])) #sc.annotate_grids(ds, alpha=0.05) sc.render() sc.save("{}_radvel".format(plotfile), sigma_clip=4.0) sc.save_annotated( "{}_radvel_annotated.png".format(plotfile), sigma_clip=4.0, text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5, 0.95), "Maestro simulation of convection in a mixed H/He XRB", dict(color="y", fontsize="24", horizontalalignment="center")]])
def doit(plotfile): ds = yt.load(plotfile) ds.periodicity = (True, True, True) field = ('boxlib', 'Hnuc') ds._get_field_info(field).take_log = True sc = Scene() # add a volume: select a sphere #center = (0, 0, 0) #R = (5.e8, 'cm') #dd = ds.sphere(center, R) vol = VolumeSource(ds, field=field) sc.add_source(vol) # transfer function vals = [14, 14.5, 15, 15.5, 16] sigma = 0.1 tf = yt.ColorTransferFunction((min(vals), max(vals))) tf.clear() cm = "viridis" for v in vals: if v < 15.5: alpha = 0.1 else: alpha = 0.75 tf.sample_colormap(v, sigma**2, alpha=alpha, colormap=cm) sc.get_source(0).transfer_function = tf cam = sc.add_camera(ds, lens_type="perspective") cam.resolution = (1080, 1080) cam.position = 1.0 * ds.domain_right_edge # look toward the center -- we are dealing with an octant center = ds.domain_left_edge normal = (center - cam.position) normal /= np.sqrt(normal.dot(normal)) cam.switch_orientation(normal_vector=normal, north_vector=[0., 0., 1.]) cam.set_width(0.5 * ds.domain_width) cam.zoom(1.5) sc.camera = cam #sc.annotate_axes(alpha=0.05) #sc.annotate_domain(ds, color=np.array([0.05, 0.05, 0.05, 0.05])) #sc.annotate_grids(ds, alpha=0.05) sc.render() sc.save("{}_Hnuc".format(plotfile), sigma_clip=4.0) sc.save_annotated( "{}_Hnuc_annotated.png".format(plotfile), text_annotate=[[(0.05, 0.05), "t = {}".format(ds.current_time.d), dict(horizontalalignment="left")], [(0.5, 0.95), "MAESTROeX simulation of ECSN convection", dict(color="y", fontsize="24", horizontalalignment="center")]])