[yt-svn] commit/yt: MatthewTurk: Merged in smumford/yt/yt-3.0 (pull request #865)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue May 6 06:36:09 PDT 2014


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/aa2ce117afc7/
Changeset:   aa2ce117afc7
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-06 15:36:00
Summary:     Merged in smumford/yt/yt-3.0 (pull request #865)

3.0 style changes and some fixes to cookbook.
Affected #:  14 files

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/aligned_cutting_plane.py
--- a/doc/source/cookbook/aligned_cutting_plane.py
+++ b/doc/source/cookbook/aligned_cutting_plane.py
@@ -1,18 +1,18 @@
-from yt.mods import *
+import yt
 
 # Load the dataset.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
 
 # Create a 1 kpc radius sphere, centered on the max density.  Note that this
 # sphere is very small compared to the size of our final plot, and it has a
 # non-axially aligned L vector.
-sp = pf.sphere("center", (15.0, "kpc"))
+sp = ds.sphere("center", (15.0, "kpc"))
 
 # Get the angular momentum vector for the sphere.
 L = sp.quantities.angular_momentum_vector()
 
-print "Angular momentum vector: %s" % (L)
+print "Angular momentum vector: {0}".format(L)
 
 # Create an OffAxisSlicePlot on the object with the L vector as its normal
-p = OffAxisSlicePlot(pf, L, "density", sp.center, (25, "kpc"))
+p = yt.OffAxisSlicePlot(ds, L, "density", sp.center, (25, "kpc"))
 p.save()

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/amrkdtree_downsampling.py
--- a/doc/source/cookbook/amrkdtree_downsampling.py
+++ b/doc/source/cookbook/amrkdtree_downsampling.py
@@ -1,26 +1,28 @@
-## Using AMRKDTree Homogenized Volumes to examine large datasets at lower resolution.
+# Using AMRKDTree Homogenized Volumes to examine large datasets
+# at lower resolution.
 
 # In this example we will show how to use the AMRKDTree to take a simulation
 # with 8 levels of refinement and only use levels 0-3 to render the dataset.
 
 # We begin by loading up yt, and importing the AMRKDTree
+import numpy as np
 
-from yt.mods import *
+import yt
 from yt.utilities.amr_kdtree.api import AMRKDTree
 
 # Load up a data and print out the maximum refinement level
-pf = load('IsolatedGalaxy/galaxy0030/galaxy0030')
+ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
 
-kd = AMRKDTree(pf)
+kd = AMRKDTree(ds)
 # Print out the total volume of all the bricks
 print kd.count_volume()
 # Print out the number of cells
 print kd.count_cells()
 
-tf = ColorTransferFunction((-30, -22))
-cam = pf.h.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256,
-                 tf, volume=kd)
-tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5], colormap = 'RdBu_r')
+tf = yt.ColorTransferFunction((-30, -22))
+cam = ds.h.camera([0.5, 0.5, 0.5], [0.2, 0.3, 0.4], 0.10, 256,
+                  tf, volume=kd)
+tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5], colormap='RdBu_r')
 cam.snapshot("v1.png", clip_ratio=6.0)
 
 # This rendering is okay, but lets say I'd like to improve it, and I don't want
@@ -28,7 +30,7 @@
 # generate a low resolution version of the AMRKDTree and pass that in to the
 # camera.  We do this by specifying a maximum refinement level of 3.
 
-kd_low_res = AMRKDTree(pf, l_max=3)
+kd_low_res = AMRKDTree(ds, max_level=3)
 print kd_low_res.count_volume()
 print kd_low_res.count_cells()
 
@@ -42,21 +44,21 @@
 # rendering until we find something we like.
 
 tf.clear()
-tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
-        alpha=np.ones(4,dtype='float64'), colormap = 'RdBu_r')
+tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
+              alpha=np.ones(4, dtype='float64'), colormap='RdBu_r')
 cam.snapshot("v2.png", clip_ratio=6.0)
 
 # This looks better.  Now let's try turning on opacity.
 
-tf.grey_opacity=True
+tf.grey_opacity = True
 cam.snapshot("v4.png", clip_ratio=6.0)
 
 # That seemed to pick out som interesting structures.  Now let's bump up the
 # opacity.
 
 tf.clear()
-tf.add_layers(4, 0.01, col_bounds = [-27.5,-25.5],
-        alpha=10.0*np.ones(4,dtype='float64'), colormap = 'RdBu_r')
+tf.add_layers(4, 0.01, col_bounds=[-27.5, -25.5],
+              alpha=10.0 * np.ones(4, dtype='float64'), colormap='RdBu_r')
 cam.snapshot("v3.png", clip_ratio=6.0)
 
 # This looks pretty good, now lets go back to the full resolution AMRKDTree
@@ -65,4 +67,3 @@
 cam.snapshot("v4.png", clip_ratio=6.0)
 
 # This looks great!
-

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/average_value.py
--- a/doc/source/cookbook/average_value.py
+++ b/doc/source/cookbook/average_value.py
@@ -1,12 +1,12 @@
-from yt.mods import *
+import yt
 
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030") # load data
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")  # load data
 
 field = "temperature"  # The field to average
-weight = "cell_mass" # The weight for the average
+weight = "cell_mass"  # The weight for the average
 
-dd = pf.h.all_data() # This is a region describing the entire box,
-                     # but note it doesn't read anything in yet!
+dd = ds.h.all_data()  # This is a region describing the entire box,
+                      # but note it doesn't read anything in yet!
 # We now use our 'quantities' call to get the average quantity
 average_value = dd.quantities["WeightedAverageQuantity"](field, weight)
 

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/boolean_data_objects.py
--- a/doc/source/cookbook/boolean_data_objects.py
+++ b/doc/source/cookbook/boolean_data_objects.py
@@ -1,23 +1,23 @@
-from yt.mods import * # set up our namespace
+import yt
 
-pf = load("Enzo_64/DD0043/data0043") # load data
+ds = yt.load("Enzo_64/DD0043/data0043")  # load data
 # Make a few data ojbects to start.
-re1 = pf.region([0.5, 0.5, 0.5], [0.4, 0.4, 0.4], [0.6, 0.6, 0.6])
-re2 = pf.region([0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [0.6, 0.6, 0.6])
-sp1 = pf.sphere([0.5, 0.5, 0.5], 0.05)
-sp2 = pf.sphere([0.1, 0.2, 0.3], 0.1)
+re1 = ds.region([0.5, 0.5, 0.5], [0.4, 0.4, 0.4], [0.6, 0.6, 0.6])
+re2 = ds.region([0.5, 0.5, 0.5], [0.5, 0.5, 0.5], [0.6, 0.6, 0.6])
+sp1 = ds.sphere([0.5, 0.5, 0.5], 0.05)
+sp2 = ds.sphere([0.1, 0.2, 0.3], 0.1)
 # The "AND" operator. This will make a region identical to re2.
-bool1 = pf.boolean([re1, "AND", re2])
+bool1 = ds.boolean([re1, "AND", re2])
 xp = bool1["particle_position_x"]
 # The "OR" operator. This will make a region identical to re1.
-bool2 = pf.boolean([re1, "OR", re2])
+bool2 = ds.boolean([re1, "OR", re2])
 # The "NOT" operator. This will make a region like re1, but with the corner
 # that re2 covers cut out.
-bool3 = pf.boolean([re1, "NOT", re2])
+bool3 = ds.boolean([re1, "NOT", re2])
 # Disjoint regions can be combined with the "OR" operator.
-bool4 = pf.boolean([sp1, "OR", sp2])
+bool4 = ds.boolean([sp1, "OR", sp2])
 # Find oddly-shaped overlapping regions.
-bool5 = pf.boolean([re2, "AND", sp1])
+bool5 = ds.boolean([re2, "AND", sp1])
 # Nested logic with parentheses.
 # This is re1 with the oddly-shaped region cut out.
-bool6 = pf.boolean([re1, "NOT", "(", re1, "AND", sp1, ")"])
+bool6 = ds.boolean([re1, "NOT", "(", re1, "AND", sp1, ")"])

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/camera_movement.py
--- a/doc/source/cookbook/camera_movement.py
+++ b/doc/source/cookbook/camera_movement.py
@@ -1,43 +1,43 @@
-from yt.mods import * # set up our namespace
+import numpy as np
+
+import yt
 
 # Follow the simple_volume_rendering cookbook for the first part of this.
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030") # load data
-dd = pf.h.all_data()
-mi, ma = dd.quantities["Extrema"]("density")[0]
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")  # load data
+dd = ds.all_data()
+mi, ma = dd.quantities["Extrema"]("density")
 
 # Set up transfer function
-tf = ColorTransferFunction((np.log10(mi), np.log10(ma)))
+tf = yt.ColorTransferFunction((np.log10(mi), np.log10(ma)))
 tf.add_layers(6, w=0.05)
 
 # Set up camera paramters
-c = [0.5, 0.5, 0.5] # Center
-L = [1, 1, 1] # Normal Vector
-W = 1.0 # Width
-Nvec = 512 # Pixels on a side
+c = [0.5, 0.5, 0.5]  # Center
+L = [1, 1, 1]  # Normal Vector
+W = 1.0  # Width
+Nvec = 512  # Pixels on a side
 
 # Specify a north vector, which helps with rotations.
-north_vector = [0.,0.,1.]
+north_vector = [0., 0., 1.]
 
 # Find the maximum density location, store it in max_c
-v,max_c = pf.h.find_max('density')
+v, max_c = ds.find_max('density')
 
 # Initialize the Camera
-cam = pf.h.camera(c, L, W, (Nvec,Nvec), tf, north_vector=north_vector)
+cam = ds.camera(c, L, W, (Nvec, Nvec), tf, north_vector=north_vector)
 frame = 0
 
 # Do a rotation over 5 frames
-for i, snapshot in enumerate(cam.rotation(np.pi, 5, clip_ratio = 8.0)):
+for i, snapshot in enumerate(cam.rotation(np.pi, 5, clip_ratio=8.0)):
     snapshot.write_png('camera_movement_%04i.png' % frame)
     frame += 1
 
 # Move to the maximum density location over 5 frames
-for i, snapshot in enumerate(cam.move_to(max_c, 5, clip_ratio = 8.0)):
+for i, snapshot in enumerate(cam.move_to(max_c, 5, clip_ratio=8.0)):
     snapshot.write_png('camera_movement_%04i.png' % frame)
     frame += 1
 
 # Zoom in by a factor of 10 over 5 frames
-for i, snapshot in enumerate(cam.zoomin(10.0, 5, clip_ratio = 8.0)):
+for i, snapshot in enumerate(cam.zoomin(10.0, 5, clip_ratio=8.0)):
     snapshot.write_png('camera_movement_%04i.png' % frame)
-    frame += 1
-
-
+    frame += 1
\ No newline at end of file

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/contours_on_slice.py
--- a/doc/source/cookbook/contours_on_slice.py
+++ b/doc/source/cookbook/contours_on_slice.py
@@ -1,13 +1,13 @@
-from yt.mods import * # set up our namespace
+import yt
 
 # first add density contours on a density slice
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") # load data
-p = SlicePlot(pf, "x", "density")
+pf = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")  # load data
+p = yt.SlicePlot(pf, "x", "density")
 p.annotate_contour("density")
 p.save()
 
 # then add temperature contours on the same densty slice
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150") # load data
-p = SlicePlot(pf, "x", "density")
+pf = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")  # load data
+p = yt.SlicePlot(pf, "x", "density")
 p.annotate_contour("temperature")
 p.save(str(pf)+'_T_contour')

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/extract_fixed_resolution_data.py
--- a/doc/source/cookbook/extract_fixed_resolution_data.py
+++ b/doc/source/cookbook/extract_fixed_resolution_data.py
@@ -1,25 +1,25 @@
-from yt.mods import *
+import yt
 
 # For this example we will use h5py to write to our output file.
 import h5py
 
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
 
 level = 2
-dims = pf.domain_dimensions * pf.refine_by**level
+dims = ds.domain_dimensions * ds.refine_by**level
 
 # Now, we construct an object that describes the data region and structure we
 # want
-cube = pf.covering_grid(2, # The level we are willing to extract to; higher
-                             # levels than this will not contribute to the data!
-                          left_edge=[0.0, 0.0, 0.0], 
-                          # And any fields to preload (this is optional!)
-                          dims = dims,
-                          fields=["density"])
+cube = ds.covering_grid(2,  # The level we are willing to extract to; higher
+                            # levels than this will not contribute to the data!
+                        left_edge=[0.0, 0.0, 0.0],
+                        # And any fields to preload (this is optional!)
+                        dims=dims,
+                        fields=["density"])
 
 # Now we open our output file using h5py
 # Note that we open with 'w' which will overwrite existing files!
-f = h5py.File("my_data.h5", "w") 
+f = h5py.File("my_data.h5", "w")
 
 # We create a dataset at the root note, calling it density...
 f.create_dataset("/density", data=cube["density"])

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/find_clumps.py
--- a/doc/source/cookbook/find_clumps.py
+++ b/doc/source/cookbook/find_clumps.py
@@ -1,26 +1,30 @@
-# set up our namespace
-from yt.mods import * 
-from yt.analysis_modules.level_sets.api import *
+import numpy as np
 
-fn = "IsolatedGalaxy/galaxy0030/galaxy0030" # parameter file to load
-field = "density" # this is the field we look for contours over -- we could do
-                  # this over anything.  Other common choices are 'AveragedDensity'
-                  # and 'Dark_Matter_Density'.
-step = 2.0 # This is the multiplicative interval between contours.
+import yt
+from yt.analysis_modules.level_sets.api import (Clump, find_clumps,
+                                                get_lowest_clumps)
 
-pf = load(fn) # load data
+fn = "IsolatedGalaxy/galaxy0030/galaxy0030"  # parameter file to load
+# this is the field we look for contours over -- we could do
+# this over anything.  Other common choices are 'AveragedDensity'
+# and 'Dark_Matter_Density'.
+field = "density"
+
+step = 2.0  # This is the multiplicative interval between contours.
+
+ds = yt.load(fn)  # load data
 
 # We want to find clumps over the entire dataset, so we'll just grab the whole
 # thing!  This is a convenience parameter that prepares an object that covers
 # the whole domain.  Note, though, that it will load on demand and not before!
-data_source = pf.disk([0.5, 0.5, 0.5], [0., 0., 1.], 
-                        8./pf.units['kpc'], 1./pf.units['kpc'])
+data_source = ds.disk([0.5, 0.5, 0.5], [0., 0., 1.],
+                      (8., 'kpc'), (1., 'kpc'))
 
 # Now we set some sane min/max values between which we want to find contours.
 # This is how we tell the clump finder what to look for -- it won't look for
 # contours connected below or above these threshold values.
-c_min = 10**np.floor(np.log10(data_source[field]).min()  )
-c_max = 10**np.floor(np.log10(data_source[field]).max()+1)
+c_min = 10**np.floor(np.log10(data_source[field]).min())
+c_max = 10**np.floor(np.log10(data_source[field]).max() + 1)
 
 # keep only clumps with at least 20 cells
 function = 'self.data[\'%s\'].size > 20' % field
@@ -38,13 +42,13 @@
 # As it goes, it appends the information about all the sub-clumps to the
 # master-clump.  Among different ways we can examine it, there's a convenience
 # function for outputting the full index to a file.
-f = open('%s_clump_index.txt' % pf,'w')
-amods.level_sets.write_clump_index(master_clump,0,f)
+f = open('%s_clump_index.txt' % ds, 'w')
+yt.amods.level_sets.write_clump_index(master_clump, 0, f)
 f.close()
 
 # We can also output some handy information, as well.
-f = open('%s_clumps.txt' % pf,'w')
-amods.level_sets.write_clumps(master_clump,0,f)
+f = open('%s_clumps.txt' % ds, 'w')
+yt.amods.level_sets.write_clumps(master_clump, 0, f)
 f.close()
 
 # We can traverse the clump index to get a list of all of the 'leaf' clumps
@@ -52,7 +56,7 @@
 
 # If you'd like to visualize these clumps, a list of clumps can be supplied to
 # the "clumps" callback on a plot.  First, we create a projection plot:
-prj = ProjectionPlot(pf, 2, field, center='c', width=(20,'kpc'))
+prj = yt.ProjectionPlot(ds, 2, field, center='c', width=(20, 'kpc'))
 
 # Next we annotate the plot with contours on the borders of the clumps
 prj.annotate_clumps(leaf_clumps)
@@ -62,7 +66,7 @@
 
 # We can also save the clump object to disk to read in later so we don't have
 # to spend a lot of time regenerating the clump objects.
-pf.h.save_object(master_clump, 'My_clumps')
+ds.h.save_object(master_clump, 'My_clumps')
 
 # Later, we can read in the clump object like so,
-master_clump = pf.h.load_object('My_clumps')
+master_clump = ds.load_object('My_clumps')

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/fit_spectrum.py
--- a/doc/source/cookbook/fit_spectrum.py
+++ b/doc/source/cookbook/fit_spectrum.py
@@ -1,25 +1,19 @@
-import os
-import sys
-import h5py
+import yt
+from yt.analysis_modules.cosmological_observation.light_ray.api import LightRay
+from yt.analysis_modules.api import AbsorptionSpectrum
+from yt.analysis_modules.absorption_spectrum.api import generate_total_fit
 
-from yt.mods import *
-from yt.analysis_modules.cosmological_observation.light_ray.api import \
-     LightRay
-from yt.analysis_modules.api import AbsorptionSpectrum
-from yt.analysis_modules.absorption_spectrum.api import \
-        generate_total_fit
+# Define and add a field to simulate OVI based on a constant relationship to HI
+def _OVI_NumberDensity(field, data):
+    return data['HI_NumberDensity']
 
-# Define and add a field to simulate OVI based on
-# a constant relationship to HI
 
-def _OVI_NumberDensity(field,data):
-    return data['HI_NumberDensity']
 def _convertOVI(data):
     return 4.9E-4*.2
 
-add_field('my_OVI_NumberDensity',
-        function=_OVI_NumberDensity,
-        convert_function=_convertOVI)
+yt.add_field('my_OVI_NumberDensity',
+             function=_OVI_NumberDensity,
+             convert_function=_convertOVI)
 
 
 # Define species andi associated parameters to add to continuum
@@ -29,33 +23,33 @@
 # (as in the OVI doublet), 'numLines' will be equal to the number
 # of lines, and f,gamma, and wavelength will have multiple values.
 
-HI_parameters = {'name':'HI',
-        'field' : 'HI_NumberDensity',
-        'f': [.4164],
-        'Gamma':[6.265E8],
-        'wavelength':[1215.67],
-        'mass': 1.00794,
-        'numLines':1,
-        'maxN': 1E22, 'minN':1E11,
-        'maxb': 300, 'minb':1,
-        'maxz': 6, 'minz':0,
-        'init_b':30,
-        'init_N':1E14}
+HI_parameters = {'name': 'HI',
+                 'field': 'HI_NumberDensity',
+                 'f': [.4164],
+                 'Gamma': [6.265E8],
+                 'wavelength': [1215.67],
+                 'mass': 1.00794,
+                 'numLines': 1,
+                 'maxN': 1E22, 'minN': 1E11,
+                 'maxb': 300, 'minb': 1,
+                 'maxz': 6, 'minz': 0,
+                 'init_b': 30,
+                 'init_N': 1E14}
 
-OVI_parameters = {'name':'OVI',
-        'field' : 'my_OVI_NumberDensity',
-        'f':[.1325,.06580],
-        'Gamma':[4.148E8,4.076E8],
-        'wavelength':[1031.9261,1037.6167],
-        'mass': 15.9994,
-        'numLines':2,
-        'maxN':1E17,'minN':1E11,
-        'maxb':300, 'minb':1,
-        'maxz':6, 'minz':0,
-        'init_b':20,
-        'init_N':1E12}
+OVI_parameters = {'name': 'OVI',
+                  'field': 'my_OVI_NumberDensity',
+                  'f': [.1325, .06580],
+                  'Gamma': [4.148E8, 4.076E8],
+                  'wavelength': [1031.9261, 1037.6167],
+                  'mass': 15.9994,
+                  'numLines': 2,
+                  'maxN': 1E17, 'minN': 1E11,
+                  'maxb': 300, 'minb': 1,
+                  'maxz': 6, 'minz': 0,
+                  'init_b': 20,
+                  'init_N': 1E12}
 
-species_dicts = {'HI':HI_parameters,'OVI':OVI_parameters}
+species_dicts = {'HI': HI_parameters, 'OVI': OVI_parameters}
 
 # Create a LightRay object extending from z = 0 to z = 0.1
 # and use only the redshift dumps.
@@ -63,7 +57,7 @@
               'Enzo', 0.0, 0.1,
               use_minimum_datasets=True,
               time_data=False
-            )
+              )
 
 # Get all fields that need to be added to the light ray
 fields = ['temperature']
@@ -80,34 +74,32 @@
                   get_los_velocity=True,
                   njobs=-1)
 
-# Create an AbsorptionSpectrum object extending from 
+# Create an AbsorptionSpectrum object extending from
 # lambda = 900 to lambda = 1800, with 10000 pixels
 sp = AbsorptionSpectrum(900.0, 1400.0, 50000)
 
 # Iterate over species
-for s,params in species_dicts.iteritems():
-
-    #Iterate over transitions for a single species
+for s, params in species_dicts.iteritems():
+    # Iterate over transitions for a single species
     for i in range(params['numLines']):
-
-        #Add the lines to the spectrum
-        sp.add_line(s, params['field'], 
-                params['wavelength'][i], params['f'][i],
-                params['Gamma'][i], params['mass'], 
-                label_threshold=1.e10)
+        # Add the lines to the spectrum
+        sp.add_line(s, params['field'],
+                    params['wavelength'][i], params['f'][i],
+                    params['Gamma'][i], params['mass'],
+                    label_threshold=1.e10)
 
 
 # Make and save spectrum
-wavelength, flux = sp.make_spectrum('lightray.h5', 
-        output_file='spectrum.h5',
-        line_list_file='lines.txt',
-        use_peculiar_velocity=True)
+wavelength, flux = sp.make_spectrum('lightray.h5',
+                                    output_file='spectrum.h5',
+                                    line_list_file='lines.txt',
+                                    use_peculiar_velocity=True)
 
 
-#Define order to fit species in
-order_fits = ['OVI','HI']
+# Define order to fit species in
+order_fits = ['OVI', 'HI']
 
 # Fit spectrum and save fit
 fitted_lines, fitted_flux = generate_total_fit(wavelength,
-            flux, order_fits, species_dicts, 
-            output_file='spectrum_fit.h5')
+                                               flux, order_fits, species_dicts,
+                                               output_file='spectrum_fit.h5')

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/free_free_field.py
--- a/doc/source/cookbook/free_free_field.py
+++ b/doc/source/cookbook/free_free_field.py
@@ -1,40 +1,42 @@
-from yt.mods import *
-from yt.utilities.physical_constants import mp # Need to grab the proton mass from the
-                                               # constants database
+import numpy as np
+import yt
+# Need to grab the proton mass from the constants database
+from yt.utilities.physical_constants import mp
 
 # Define the emission field
 
-keVtoerg = 1.602e-9 # Convert energy in keV to energy in erg
-KtokeV = 8.617e-08 # Convert degrees Kelvin to degrees keV
+keVtoerg = 1.602e-9  # Convert energy in keV to energy in erg
+KtokeV = 8.617e-08  # Convert degrees Kelvin to degrees keV
 sqrt3 = np.sqrt(3.)
-expgamma = 1.78107241799 # Exponential of Euler's constant
+expgamma = 1.78107241799  # Exponential of Euler's constant
 
-def _FreeFree_Emission(field, data) :
 
-    if data.has_field_parameter("Z") :
+def _FreeFree_Emission(field, data):
+
+    if data.has_field_parameter("Z"):
         Z = data.get_field_parameter("Z")
-    else :
-        Z = 1.077 # Primordial H/He plasma
+    else:
+        Z = 1.077  # Primordial H/He plasma
 
-    if data.has_field_parameter("mue") :
+    if data.has_field_parameter("mue"):
         mue = data.get_field_parameter("mue")
-    else :
-        mue = 1./0.875 # Primordial H/He plasma
+    else:
+        mue = 1./0.875  # Primordial H/He plasma
 
-    if data.has_field_parameter("mui") :
+    if data.has_field_parameter("mui"):
         mui = data.get_field_parameter("mui")
-    else :
-        mui = 1./0.8125 # Primordial H/He plasma
+    else:
+        mui = 1./0.8125  # Primordial H/He plasma
 
-    if data.has_field_parameter("Ephoton") :
+    if data.has_field_parameter("Ephoton"):
         Ephoton = data.get_field_parameter("Ephoton")
-    else :
-        Ephoton = 1.0 # in keV
+    else:
+        Ephoton = 1.0  # in keV
 
-    if data.has_field_parameter("photon_emission") :
+    if data.has_field_parameter("photon_emission"):
         photon_emission = data.get_field_parameter("photon_emission")
-    else :
-        photon_emission = False # Flag for energy or photon emission
+    else:
+        photon_emission = False  # Flag for energy or photon emission
 
     n_e = data["density"]/(mue*mp)
     n_i = data["density"]/(mui*mp)
@@ -50,24 +52,25 @@
     eps_E = 1.64e-20*Z*Z*n_e*n_i/np.sqrt(data["temperature"]) * \
         np.exp(-Ephoton/kT)*g_ff
 
-    if photon_emission: eps_E /= (Ephoton*keVtoerg)
+    if photon_emission:
+        eps_E /= (Ephoton*keVtoerg)
 
     return eps_E
 
-add_field("FreeFree_Emission", function=_FreeFree_Emission)
+yt.add_field("FreeFree_Emission", function=_FreeFree_Emission)
 
 # Define the luminosity derived quantity
-
-def _FreeFreeLuminosity(data) :
+def _FreeFreeLuminosity(data):
     return (data["FreeFree_Emission"]*data["cell_volume"]).sum()
 
-def _combFreeFreeLuminosity(data, luminosity) :
+
+def _combFreeFreeLuminosity(data, luminosity):
     return luminosity.sum()
 
-add_quantity("FreeFree_Luminosity", function=_FreeFreeLuminosity,
-             combine_function=_combFreeFreeLuminosity, n_ret = 1)
+yt.add_quantity("FreeFree_Luminosity", function=_FreeFreeLuminosity,
+                combine_function=_combFreeFreeLuminosity, n_ret=1)
 
-pf = load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
+pf = yt.load("GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0150")
 
 sphere = pf.sphere(pf.domain_center, (100., "kpc"))
 
@@ -75,8 +78,8 @@
 
 print "L_E (1 keV, primordial) = ", sphere.quantities["FreeFree_Luminosity"]()
 
-# The defaults for the field assume a H/He primordial plasma. Let's set the appropriate
-# parameters for a pure hydrogen plasma.
+# The defaults for the field assume a H/He primordial plasma.
+# Let's set the appropriate parameters for a pure hydrogen plasma.
 
 sphere.set_field_parameter("mue", 1.0)
 sphere.set_field_parameter("mui", 1.0)
@@ -90,10 +93,9 @@
 
 print "L_E (10 keV, pure hydrogen) = ", sphere.quantities["FreeFree_Luminosity"]()
 
-# Finally, let's set the flag for photon emission, to get the total number of photons
-# emitted at this energy:
+# Finally, let's set the flag for photon emission, to get the total number
+# of photons emitted at this energy:
 
 sphere.set_field_parameter("photon_emission", True)
 
 print "L_ph (10 keV, pure hydrogen) = ", sphere.quantities["FreeFree_Luminosity"]()
-

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/global_phase_plots.py
--- a/doc/source/cookbook/global_phase_plots.py
+++ b/doc/source/cookbook/global_phase_plots.py
@@ -1,14 +1,14 @@
-from yt.mods import * # set up our namespace
+import yt
 
 # load the dataset
-pf = load("IsolatedGalaxy/galaxy0030/galaxy0030")
+ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
 
 # This is an object that describes the entire box
-ad = pf.h.all_data()
+ad = ds.h.all_data()
 
-# We plot the average VelocityMagnitude (mass-weighted) in our object 
+# We plot the average VelocityMagnitude (mass-weighted) in our object
 # as a function of Density and temperature
-plot = PhasePlot(ad, "density","temperature","velocity_magnitude")
+plot = yt.PhasePlot(ad, "density", "temperature", "velocity_magnitude")
 
 # save the plot
 plot.save()

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/halo_finding.py
--- a/doc/source/cookbook/halo_finding.py
+++ b/doc/source/cookbook/halo_finding.py
@@ -2,9 +2,9 @@
 This script shows the simplest way of getting halo information.  For more
 information, see :ref:`halo_finding`.
 """
-from yt.mods import * # set up our namespace
+import yt
 
-pf = load("Enzo_64/DD0043/data0043")
+ds = yt.load("Enzo_64/DD0043/data0043")
 
-halos = HaloFinder(pf)
-halos.write_out("%s_halos.txt" % pf)
+halos = yt.HaloFinder(ds)
+halos.write_out("%s_halos.txt" % ds)

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 doc/source/cookbook/hse_field.py
--- a/doc/source/cookbook/hse_field.py
+++ b/doc/source/cookbook/hse_field.py
@@ -1,121 +1,134 @@
-from yt.mods import *
+import numpy as np
+import yt
 
-# Define the components of the gravitational acceleration vector field by taking the
-# gradient of the gravitational potential
+# Define the components of the gravitational acceleration vector field by
+# taking the gradient of the gravitational potential
 
-def _Grav_Accel_x(field, data) :
+
+def _Grav_Accel_x(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dx = div_fac * data['dx'].flat[0]
 
-    gx  = data["Grav_Potential"][sl_right,1:-1,1:-1]/dx
-    gx -= data["Grav_Potential"][sl_left, 1:-1,1:-1]/dx
+    gx = data["gravitational_potential"][sl_right, 1:-1, 1:-1]/dx
+    gx -= data["gravitational_potential"][sl_left, 1:-1, 1:-1]/dx
 
-    new_field = np.zeros(data["Grav_Potential"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = -gx
+    new_field = np.zeros(data["gravitational_potential"].shape,
+                         dtype='float64')
+    new_field[1:-1, 1:-1, 1:-1] = -gx
 
     return new_field
 
-def _Grav_Accel_y(field, data) :
+
+def _Grav_Accel_y(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dy = div_fac * data['dy'].flat[0]
 
-    gy  = data["Grav_Potential"][1:-1,sl_right,1:-1]/dy
-    gy -= data["Grav_Potential"][1:-1,sl_left ,1:-1]/dy
+    gy = data["gravitational_potential"][1:-1, sl_right, 1:-1]/dy
+    gy -= data["gravitational_potential"][1:-1, sl_left, 1:-1]/dy
 
-    new_field = np.zeros(data["Grav_Potential"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = -gy
+    new_field = np.zeros(data["gravitational_potential"].shape,
+                         dtype='float64')
+    new_field[1:-1, 1:-1, 1:-1] = -gy
 
     return new_field
 
-def _Grav_Accel_z(field, data) :
+
+def _Grav_Accel_z(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dz = div_fac * data['dz'].flat[0]
 
-    gz  = data["Grav_Potential"][1:-1,1:-1,sl_right]/dz
-    gz -= data["Grav_Potential"][1:-1,1:-1,sl_left ]/dz
+    gz = data["gravitational_potential"][1:-1, 1:-1, sl_right]/dz
+    gz -= data["gravitational_potential"][1:-1, 1:-1, sl_left]/dz
 
-    new_field = np.zeros(data["Grav_Potential"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = -gz
+    new_field = np.zeros(data["gravitational_potential"].shape,
+                         dtype='float64')
+    new_field[1:-1, 1:-1, 1:-1] = -gz
 
     return new_field
 
+
 # Define the components of the pressure gradient field
 
-def _Grad_Pressure_x(field, data) :
+
+def _Grad_Pressure_x(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dx = div_fac * data['dx'].flat[0]
 
-    px  = data["pressure"][sl_right,1:-1,1:-1]/dx
-    px -= data["pressure"][sl_left, 1:-1,1:-1]/dx
+    px = data["pressure"][sl_right, 1:-1, 1:-1]/dx
+    px -= data["pressure"][sl_left, 1:-1, 1:-1]/dx
 
     new_field = np.zeros(data["pressure"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = px
+    new_field[1:-1, 1:-1, 1:-1] = px
 
     return new_field
 
-def _Grad_Pressure_y(field, data) :
+
+def _Grad_Pressure_y(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dy = div_fac * data['dy'].flat[0]
 
-    py  = data["pressure"][1:-1,sl_right,1:-1]/dy
-    py -= data["pressure"][1:-1,sl_left ,1:-1]/dy
+    py = data["pressure"][1:-1, sl_right, 1:-1]/dy
+    py -= data["pressure"][1:-1, sl_left, 1:-1]/dy
 
     new_field = np.zeros(data["pressure"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = py
+    new_field[1:-1, 1:-1, 1:-1] = py
 
     return new_field
 
-def _Grad_Pressure_z(field, data) :
+
+def _Grad_Pressure_z(field, data):
 
     # We need to set up stencils
 
-    sl_left = slice(None,-2,None)
-    sl_right = slice(2,None,None)
+    sl_left = slice(None, -2, None)
+    sl_right = slice(2, None, None)
     div_fac = 2.0
 
     dz = div_fac * data['dz'].flat[0]
 
-    pz  = data["pressure"][1:-1,1:-1,sl_right]/dz
-    pz -= data["pressure"][1:-1,1:-1,sl_left ]/dz
+    pz = data["pressure"][1:-1, 1:-1, sl_right]/dz
+    pz -= data["pressure"][1:-1, 1:-1, sl_left]/dz
 
     new_field = np.zeros(data["pressure"].shape, dtype='float64')
-    new_field[1:-1,1:-1,1:-1] = pz
+    new_field[1:-1, 1:-1, 1:-1] = pz
 
     return new_field
 
+
 # Define the "degree of hydrostatic equilibrium" field
 
-def _HSE(field, data) :
+
+def _HSE(field, data):
 
     gx = data["density"]*data["Grav_Accel_x"]
     gy = data["density"]*data["Grav_Accel_y"]
@@ -131,36 +144,37 @@
 
 # Now add the fields to the database
 
-add_field("Grav_Accel_x", function=_Grav_Accel_x, take_log=False,
-          validators=[ValidateSpatial(1,["Grav_Potential"])])
+yt.add_field("Grav_Accel_x", function=_Grav_Accel_x, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
 
-add_field("Grav_Accel_y", function=_Grav_Accel_y, take_log=False,
-          validators=[ValidateSpatial(1,["Grav_Potential"])])
+yt.add_field("Grav_Accel_y", function=_Grav_Accel_y, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
 
-add_field("Grav_Accel_z", function=_Grav_Accel_z, take_log=False,
-          validators=[ValidateSpatial(1,["Grav_Potential"])])
+yt.add_field("Grav_Accel_z", function=_Grav_Accel_z, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["gravitational_potential"])])
 
-add_field("Grad_Pressure_x", function=_Grad_Pressure_x, take_log=False,
-          validators=[ValidateSpatial(1,["pressure"])])
+yt.add_field("Grad_Pressure_x", function=_Grad_Pressure_x, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["pressure"])])
 
-add_field("Grad_Pressure_y", function=_Grad_Pressure_y, take_log=False,
-          validators=[ValidateSpatial(1,["pressure"])])
+yt.add_field("Grad_Pressure_y", function=_Grad_Pressure_y, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["pressure"])])
 
-add_field("Grad_Pressure_z", function=_Grad_Pressure_z, take_log=False,
-          validators=[ValidateSpatial(1,["pressure"])])
+yt.add_field("Grad_Pressure_z", function=_Grad_Pressure_z, take_log=False,
+             validators=[yt.ValidateSpatial(1, ["pressure"])])
 
-add_field("HSE", function=_HSE, take_log=False)
+yt.add_field("HSE", function=_HSE, take_log=False)
 
-# Open two files, one at the beginning and the other at a later time when there's a
-# lot of sloshing going on.
+# Open two files, one at the beginning and the other at a later time when
+# there's a lot of sloshing going on.
 
-pfi = load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0000")
-pff = load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0350")
+dsi = yt.load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0000")
+dsf = yt.load("GasSloshingLowRes/sloshing_low_res_hdf5_plt_cnt_0350")
 
-# Sphere objects centered at the cluster potential minimum with a radius of 200 kpc
+# Sphere objects centered at the cluster potential minimum with a radius
+# of 200 kpc
 
-sphere_i = pfi.h.sphere(pfi.domain_center, (200, "kpc"))
-sphere_f = pff.h.sphere(pff.domain_center, (200, "kpc"))
+sphere_i = dsi.h.sphere(dsi.domain_center, (200, "kpc"))
+sphere_f = dsf.h.sphere(dsf.domain_center, (200, "kpc"))
 
 # Average "degree of hydrostatic equilibrium" in these spheres
 
@@ -170,10 +184,13 @@
 print "Degree of hydrostatic equilibrium initially: ", hse_i
 print "Degree of hydrostatic equilibrium later: ", hse_f
 
-# Just for good measure, take slices through the center of the domain of the two files
+# Just for good measure, take slices through the center of the domains
+# of the two files
 
-slc_i = SlicePlot(pfi, 2, ["density","HSE"], center=pfi.domain_center, width=(1.0, "mpc"))
-slc_f = SlicePlot(pff, 2, ["density","HSE"], center=pff.domain_center, width=(1.0, "mpc"))
+slc_i = yt.SlicePlot(dsi, 2, ["density", "HSE"], center=dsi.domain_center,
+                     width=(1.0, "mpc"))
+slc_f = yt.SlicePlot(dsf, 2, ["density", "HSE"], center=dsf.domain_center,
+                     width=(1.0, "mpc"))
 
 slc_i.save("initial")
 slc_f.save("final")

diff -r 513b0df9cdaf57c16feafa25521a00f93fa6d46f -r aa2ce117afc797ccbea2a157621a590880ad7c00 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -498,8 +498,10 @@
                              (x0, x1, y0, y1),).transpose()
         X,Y = (np.linspace(xx0,xx1,nx,endpoint=True),
                np.linspace(yy0,yy1,ny,endpoint=True))
-        plot._axes.streamplot(X,Y, pixX, pixY, density = self.dens,
-                              **self.plot_args)
+        streamplot_args = {'x': X, 'y': Y, 'u':pixX, 'v': pixY,
+                           'density': self.dens}
+        streamplot_args.update(self.plot_args)
+        plot._axes.streamplot(**self.streamplot_args)
         plot._axes.set_xlim(xx0,xx1)
         plot._axes.set_ylim(yy0,yy1)
         plot._axes.hold(False)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list