[yt-users] clump to field?

david collins dcollins4096 at gmail.com
Fri May 17 12:31:19 PDT 2013


Hi, all--

I have a clump that I've gotten with the clump finder.  I'd like to paint
those zones of that clump with a flag, so I can exclude that region from
other analysis.  I'm a little stuck on how to get this done-- I feel like
it needs to involve clump.data._flush_data_to_grids and a cut_mask, but I'm
a little stuck on how to define the field that I flush_to_grids.

Specifically, how to get the cut_mask information to the field, and how to
avoid clobbering the paint from one clump with another (or, from one grid
with another)

I'm trying to do something like:

<code>
for grid in clump.data._grids:
    cut_mask = clump.data._get_cut_mask(grid)
    def masked_region(field,data):
        cut_mask = data.get_field_parameter('cut_mask', None)
        try:
            base = data['masked_region']
        except:
            base = na.zeros(data['Density'].shape)
        if cut_mask is not None:
            base = na.maximum(base,cut_mask)
        return base

 add_field('masked_region',function=masked_region,validators=[ValidateGridType()],
not_in_all=True)
    grid.set_field_parameter('cut_mask',cut_mask)
    print grid, cut_mask.sum(), grid['masked_region'].sum()
clump.data._flush_to_grids('masked_region',0)
</code>

but clump['masked_region'].sum() only returns the flagged zones in the
first of the grids.

I feel like this is something I've done before, but can't find any
reference to it in my email or old scripts.  Apologies if this has been
answered elsewhere, or it's obvious and I'm being thick.

Thanks!
d.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130517/02a3f275/attachment.htm>


More information about the yt-users mailing list