[yt-users] clump as container

Matthew Turk matthewturk at gmail.com
Thu Dec 18 07:00:49 PST 2014


Hi Britton and Dave,

Yes -- although that behavior was also true in 2.x, to my recollection.

However, in 3.0, we *can* do this with a little bit of development, so
I think on the whole it's a net win.  With the work Doug Rudd did on
composable objects, we should be able to supply one object as a
base_source to another and then select particles that reside inside
the cells that are selected, using bbox selection based on cells.

All of that being said, I'd say just use the deposited mass from
particles.  It'll give you exactly the same result and will work with
clumps.  This was not available in 2.x, and now is in 3.x.

Also, what I was alluding to in a previous email is that there's an
internal "state" affiliated with an object -- "GenerationInProgress"
-- which can sometimes, if an error is not correctly caught, be
propagated up to the top.  I think this is what's happening.  Without
it getting reset internally, it breaks the object.

-Matt

On Thu, Dec 18, 2014 at 8:57 AM, Britton Smith <brittonsmith at gmail.com> wrote:
> My understanding is that in yt-3.0 we cannot get particles from clumps.  Is
> that true?
>
> On Thu, Dec 18, 2014 at 9:36 AM, David Collins <dcollins4096 at gmail.com>
> wrote:
>>>
>>>
>>> I believe what's going on is that the object gets stuck in a mid-state
>>> of generating data and is locked.  This is something that is not
>>> supposed to happen, but we should be able to fail more gracefully.
>>>
>>
>> Is it stuck because it's hard to get particles directly from the clump?
>>
>>
>>>
>>> > For now, a workaround would be to avoid using the total_mass derived
>>> > quantity and instead do something like this:
>>> >
>>> > clump = ...
>>> > total_mass = clump.quantity.total_quantity('cell_mass')
>>> > clump['density']
>>> > clump['cell_mass']
>>> >
>>> >>
>>> >>
>>> >> The curious disappearing data can be seen here:
>>> >>
>>> >> >>> leaf_clumps[0]['density']
>>> >> YTArray([  94330.76550569,  111095.42419888,  111000.87780872,
>>> >>         158489.47273191,  114487.69237444,  129849.08390983,
>>> >>          95651.97426045,   95462.47824957,  104785.15137116,
>>> >>         149758.92528478,  122558.83598019,   91829.8174425 ,
>>> >>          97015.49553846,  118157.84068288]) g/cm**3
>>> >> >>> leaf_clumps[0]['cell_mass']
>>> >> YTArray([ 0.00070282,  0.00082773,  0.00082702,  0.00118084,  0.000853
>>> >> ,
>>> >>         0.00096745,  0.00071266,  0.00071125,  0.00078071,
>>> >> 0.00111579,
>>> >>         0.00091313,  0.00068419,  0.00072282,  0.00088034]) g
>>> >> >>> leaf_clumps[0].quantities.total_quantity('cell_mass')
>>> >> 0.0118797558199 g
>>> >> >>> leaf_clumps[0].quantities.total_mass()
>>> >> Traceback (most recent call last):
>>> >>   File "<stdin>", line 1, in <module>
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >> line 193, in __call__
>>> >>     rv = super(TotalMass, self).__call__(fields)
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >> line 160, in __call__
>>> >>     rv = super(TotalQuantity, self).__call__(fields)
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >> line 56, in __call__
>>> >>     sto.result = self.process_chunk(ds, *args, **kwargs)
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >> line 166, in process_chunk
>>> >>     for field in fields]
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/data_containers.py",
>>> >> line 248, in __getitem__
>>> >>     self.get_data(f)
>>> >>   File
>>> >>
>>> >> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/selection_data_containers.py",
>>> >> line 749, in get_data
>>> >>     raise YTMixedCutRegion(self.conditionals, field)
>>> >> yt.utilities.exceptions.YTMixedCutRegion: Can't mix particle/discrete
>>> >> and
>>> >> fluid/mesh conditions or
>>> >>                quantities.  Field: ('all', 'particle_mass') and
>>> >> Conditions
>>> >> specified:
>>> >>             obj['contours_72e8d63701e04d13bfec60cada79b7ad'] == 1
>>> >> >>> leaf_clumps[0].quantities.total_quantity('cell_mass')
>>> >> 0.0 g
>>> >> >>> leaf_clumps[0]['cell_mass']
>>> >> YTArray([], dtype=float64) g
>>> >>
>>> >>
>>> >>
>>> >> The code to make the clumps
>>> >>
>>> >>     ds = yt.load(setname)
>>> >>     val, loc = ds.find_max('density')
>>> >>     width = (0.05,'code_length')
>>> >>     sphere = ds.sphere(loc,width)
>>> >>     master_clump = Clump(sphere,"density")
>>> >>     c_min = sphere["gas", "density"].min()
>>> >>     c_max = sphere["gas", "density"].max()
>>> >>     step = 2.0
>>> >>     find_clumps(master_clump, c_min, c_max, step)
>>> >>     leaf_clumps = get_lowest_clumps(master_clump)
>>> >>
>>> >>
>>> >>>
>>> >>> I'll give that a shot in the morning and report back.
>>> >>>
>>> >>>
>>> >>> Thanks!
>>> >>> d.
>>> >>>
>>> >>>>
>>> >>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> If I instead try quantities.total_mass(), I get an odd error.
>>> >>>>> >>> leaf_clumps[22].quantities.total_mass()
>>> >>>>> Traceback (most recent call last):
>>> >>>>>   File "<stdin>", line 1, in <module>
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >>>>> line 193, in __call__
>>> >>>>>     rv = super(TotalMass, self).__call__(fields)
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >>>>> line 160, in __call__
>>> >>>>>     rv = super(TotalQuantity, self).__call__(fields)
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >>>>> line 56, in __call__
>>> >>>>>     sto.result = self.process_chunk(ds, *args, **kwargs)
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/derived_quantities.py",
>>> >>>>> line 166, in process_chunk
>>> >>>>>     for field in fields]
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/data_containers.py",
>>> >>>>> line 248, in __getitem__
>>> >>>>>     self.get_data(f)
>>> >>>>>   File
>>> >>>>>
>>> >>>>> "/home/dcollins4096/local-yt-2014-08-27/src/yt-hg/yt/data_objects/selection_data_containers.py",
>>> >>>>> line 749, in get_data
>>> >>>>>     raise YTMixedCutRegion(self.conditionals, field)
>>> >>>>> yt.utilities.exceptions.YTMixedCutRegion: Can't mix
>>> >>>>> particle/discrete
>>> >>>>> and fluid/mesh conditions or
>>> >>>>>                quantities.  Field: ('all', 'particle_mass') and
>>> >>>>> Conditions specified:
>>> >>>>>             obj['contours_8d0408a91fc34e2bbe9eb838d48de46e'] == 1
>>> >>>>
>>> >>>>
>>> >>>> This is happening because, as the error indicates, you can't combine
>>> >>>> mesh and particle quantities in a cut_region (like a clump is).  The
>>> >>>> total_mass() quantity returns the total mass in particles and gas,
>>> >>>> so that's
>>> >>>> what's triggering the error. I bet this would work if you asked for
>>> >>>> the
>>> >>>> total gas mass only. Of course, that would only work if
>>> >>>> clump['cell_mass']
>>> >>>> returned something sensible.
>>> >>>>
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> I build the clumps in the following manner.  I don't have any
>>> >>>>> validators by design.  Plotting the clumps with
>>> >>>>> annotate_clumps(leaf_clumps)
>>> >>>>> gives reasonable results.
>>> >>>>>
>>> >>>>>     ds = yt.load(setname)
>>> >>>>>     loc = ds.arr([ 0.03613281,  0.79589844,  0.03027344],
>>> >>>>> 'code_length')
>>> >>>>>     width = (0.05,'code_length')
>>> >>>>>     sphere = ds.sphere(loc,width)
>>> >>>>>     master_clump = Clump(sphere,"density")
>>> >>>>> use_particles=False, use_thermal_energy=False)
>>> >>>>>     c_min = sphere["gas", "density"].min()
>>> >>>>>     c_max = sphere["gas", "density"].max()
>>> >>>>>     step = 2.0
>>> >>>>>     find_clumps(master_clump, c_min, c_max, step)
>>> >>>>>     leaf_clumps = get_lowest_clumps(master_clump)
>>> >>>>>
>>> >>>>> Thanks a ton!
>>> >>>>> d.
>>> >>>>>
>>> >>>>> --
>>> >>>>> -- Sent from a computer.
>>> >>>>>
>>> >>>>> _______________________________________________
>>> >>>>> yt-users mailing list
>>> >>>>> yt-users at lists.spacepope.org
>>> >>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>>>>
>>> >>>>
>>> >>>> _______________________________________________
>>> >>>> yt-users mailing list
>>> >>>> yt-users at lists.spacepope.org
>>> >>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >>>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> -- Sent from a computer.
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> -- Sent from a computer.
>>> >> _______________________________________________
>>> >> yt-users mailing list
>>> >> yt-users at lists.spacepope.org
>>> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> >
>>> > _______________________________________________
>>> > yt-users mailing list
>>> > yt-users at lists.spacepope.org
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>>
>> --
>> -- Sent from a computer.
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
_______________________________________________
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