Hello Everybody, I am writing you this time to ask if anybody has an example how to manipulate data. For instance, I am using contour_values, connected_sets = sphere.extract_connected_sets("Density", levels, mi, ma) print connected_sets[i] #{0: ExtractedRegionBase (redshift0058): _base_region=AMRSphere (redshift0058): center=[ 0.1005697 0.15871103 0.37831026], radius=0.0124657962771} and connected_sets is an array of dict of dicts, but I couldn't find any example of how manipulate a dict object. Thank in Advance -- Francia F.R.
if you defined sphere as something like:
sphere=pf.h.sphere([.5,.5,.5],0.3)
then
connected_sets[i][0]['Density']
for i = 0, 1, 2...
lets me see the values.
Hope that helped.
From
G.S.
On Tue, Sep 18, 2012 at 2:23 PM, Francia F. Riesco
Hello Everybody, I am writing you this time to ask if anybody has an example how to manipulate data. For instance, I am using contour_values, connected_sets = sphere.extract_connected_sets(**"Density", levels, mi, ma)
print connected_sets[i]
#{0: ExtractedRegionBase (redshift0058): _base_region=AMRSphere (redshift0058): center=[ 0.1005697 0.15871103 0.37831026], radius=0.0124657962771}
and connected_sets is an array of dict of dicts, but I couldn't find any example of how manipulate a dict object. Thank in Advance
-- Francia F.R. ______________________________**_________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/**listinfo.cgi/yt-users-**spacepope.orghttp://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
sorry that should read
connected_sets[1][i]['Density']
where i = 0,1,2...
From
G.S.
On Tue, Sep 18, 2012 at 2:37 PM, Geoffrey So
if you defined sphere as something like:
sphere=pf.h.sphere([.5,.5,.5],0.3)
then
connected_sets[i][0]['Density']
for i = 0, 1, 2...
lets me see the values.
Hope that helped.
From G.S.
On Tue, Sep 18, 2012 at 2:23 PM, Francia F. Riesco
wrote: Hello Everybody, I am writing you this time to ask if anybody has an example how to manipulate data. For instance, I am using contour_values, connected_sets = sphere.extract_connected_sets(**"Density", levels, mi, ma)
print connected_sets[i]
#{0: ExtractedRegionBase (redshift0058): _base_region=AMRSphere (redshift0058): center=[ 0.1005697 0.15871103 0.37831026], radius=0.0124657962771}
and connected_sets is an array of dict of dicts, but I couldn't find any example of how manipulate a dict object. Thank in Advance
-- Francia F.R. ______________________________**_________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/**listinfo.cgi/yt-users-**spacepope.orghttp://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Francia,
On Tue, Sep 18, 2012 at 5:23 PM, Francia F. Riesco
Hello Everybody, I am writing you this time to ask if anybody has an example how to manipulate data. For instance, I am using contour_values, connected_sets = sphere.extract_connected_sets("Density", levels, mi, ma)
print connected_sets[i]
#{0: ExtractedRegionBase (redshift0058): _base_region=AMRSphere (redshift0058): center=[ 0.1005697 0.15871103 0.37831026], radius=0.0124657962771}
and connected_sets is an array of dict of dicts, but I couldn't find any example of how manipulate a dict object.
Sure! So as a starter, the connected sets set up so that the return values provide to you both the bounds of each connected set and the data objects corresponding to each connected set. So what connected_sets is is a tuple, where the first is a set of bounds, and the second is a list of clumps. So you could do something like: bounds = connected_sets[0] clumps_by_level = connected_sets[1] Now your clumps_by_level is a dict of dicts, like you mentioned. So the first key is the "level" of the connected sets you've extracted -- since you can extract multiple levels, this returns them all simultaneously. So if you want the first level: clumps_by_level[0] You can see the bounds that led to this with: print bounds[0], bounds[1] Note that the bounds of a given level are bounds[level] and bounds[level+1]. So now you can see that each contour has a unique ID, which is the second key of the dict: clumps_by_level[0][0] is clump ID 0 (second key) and level 0 (first key). So if you wanted the first clump from all the levels, you could do: for level in clumps_by_level: for clump_id in clumps_by_level[level]: print bounds[level], bounds[level+1], clumps_by_level[level][clump_id] I hope that helps -- for more info on how dicts work, the Python tutorial is quite nice: http://docs.python.org/tutorial/datastructures.html Dicts are very cool and a big language feature in Python. If you run into anything else you have questions about, please don't hesitate to write back! -Matt
Thank in Advance
-- Francia F.R. _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (3)
-
Francia F. Riesco
-
Geoffrey So
-
Matthew Turk