[yt-svn] commit/yt-doc: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Thu Nov 8 19:06:22 PST 2012
3 new commits in yt-doc:
https://bitbucket.org/yt_analysis/yt-doc/changeset/1ae198ee98d6/
changeset: 1ae198ee98d6
user: ngoldbaum
date: 2012-11-09 03:40:57
summary: Updating the clump cookbook recipe.
affected #: 1 file
diff -r 1555a8c8bf6d189a4597a1cb86ffce2690a5bb6c -r 1ae198ee98d67e9c8df7d24e4fbc9e644c4adf83 source/cookbook/find_clumps.py
--- a/source/cookbook/find_clumps.py
+++ b/source/cookbook/find_clumps.py
@@ -11,7 +11,8 @@
# 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.h.all_data()
+data_source = pf.h.disk([0.5, 0.5, 0.5], [0., 0., 1.],
+ 8./pf.units['kpc'], 1./pf.units['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
@@ -19,15 +20,18 @@
c_min = 10**na.floor(na.log10(data_source[field]).min() )
c_max = 10**na.floor(na.log10(data_source[field]).max()+1)
+# keep only clumps with at least 20 cells
+function = 'self.data[field].size > 20'
+
# Now find get our 'base' clump -- this one just covers the whole domain.
-master_clump = amods.level_sets.Clump(data_source, None, field)
+master_clump = Clump(data_source, None, field, function=function)
# This next command accepts our base clump and we say the range between which
# we want to contour. It recursively finds clumps within the master clump, at
# intervals defined by the step size we feed it. The current value is
# *multiplied* by step size, rather than added to it -- so this means if you
# want to look in log10 space intervals, you would supply step = 10.0.
-amods.level_sets.find_clumps(master_clump, c_min, c_max, step)
+find_clumps(master_clump, c_min, c_max, step)
# 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
@@ -40,5 +44,23 @@
f = open('%s_clumps.txt' % pf,'w')
amods.level_sets.write_clumps(master_clump,0,f)
f.close()
+
+# We can traverse the clump hierarchy to get a list of all of the 'leaf' clumps
+leaf_clumps = get_lowest_clumps(master_clump)
+
# If you'd like to visualize these clumps, a list of clumps can be supplied to
-# the "clumps" callback on a plot.
+# the "clumps" callback on a plot. First, we create a projection plot:
+prj = ProjectionPlot(pf, 2, field, center='c', width=(20,'kpc'))
+
+# Next we annotate the plot with contours on the borders of the clumps
+prj.annotate_clumps(all_clumps)
+
+# Lastly, we write the plot to disk.
+slc.save('clumps')
+
+# 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')
+
+# Later, we can read in the clump object like so,
+master_clump = pf.h.load_object('My_clumps')
https://bitbucket.org/yt_analysis/yt-doc/changeset/7913621bed90/
changeset: 7913621bed90
user: ngoldbaum
date: 2012-11-09 03:45:38
summary: Forgot to import the level sets api.
affected #: 1 file
diff -r 1ae198ee98d67e9c8df7d24e4fbc9e644c4adf83 -r 7913621bed907c0b110b1e8e32024019687feca4 source/cookbook/find_clumps.py
--- a/source/cookbook/find_clumps.py
+++ b/source/cookbook/find_clumps.py
@@ -1,4 +1,6 @@
-from yt.mods import * # set up our namespace
+# set up our namespace
+from yt.mods import *
+from yt.analysis_modules.level_sets.api import *
fn = "IsolatedGalaxy/galaxy0030/galaxy0030" # parameter file to load
field = "Density" # this is the field we look for contours over -- we could do
https://bitbucket.org/yt_analysis/yt-doc/changeset/32b3509b6d3f/
changeset: 32b3509b6d3f
user: ngoldbaum
date: 2012-11-09 03:59:55
summary: Fixing some errors.
affected #: 1 file
diff -r 7913621bed907c0b110b1e8e32024019687feca4 -r 32b3509b6d3f3e7593309dc1ecec1d63b17f87f6 source/cookbook/find_clumps.py
--- a/source/cookbook/find_clumps.py
+++ b/source/cookbook/find_clumps.py
@@ -6,7 +6,7 @@
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 = 10.0 # This is the multiplicative interval between contours.
+step = 2.0 # This is the multiplicative interval between contours.
pf = load(fn) # load data
@@ -23,7 +23,7 @@
c_max = 10**na.floor(na.log10(data_source[field]).max()+1)
# keep only clumps with at least 20 cells
-function = 'self.data[field].size > 20'
+function = 'self.data[\'%s\'].size > 20' % field
# Now find get our 'base' clump -- this one just covers the whole domain.
master_clump = Clump(data_source, None, field, function=function)
@@ -55,10 +55,10 @@
prj = ProjectionPlot(pf, 2, field, center='c', width=(20,'kpc'))
# Next we annotate the plot with contours on the borders of the clumps
-prj.annotate_clumps(all_clumps)
+prj.annotate_clumps(leaf_clumps)
# Lastly, we write the plot to disk.
-slc.save('clumps')
+prj.save('clumps')
# 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.
Repository URL: https://bitbucket.org/yt_analysis/yt-doc/
--
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