[yt-users] clump to field?
Matthew Turk
matthewturk at gmail.com
Fri May 17 12:34:20 PDT 2013
On Fri, May 17, 2013 at 3:31 PM, david collins <dcollins4096 at gmail.com> wrote:
> 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.
>
I have to think about specifically how you might do this, but I do
believe that you can probably accomplish what you're looking for by
using a boolean region.
> 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.
>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
More information about the yt-users
mailing list