[yt-users] clump as container

Nathan Goldbaum nathan12343 at gmail.com
Wed Dec 17 12:32:20 PST 2014


On Wed Dec 17 2014 at 10:24:51 AM David Collins <dcollins4096 at gmail.com>
wrote:

> Not sure why this is happening.  Any chance you can reproduce it using one
>>> of the test datasets on yt-project.org/data?
>>>
>>
>>
> I tried with the IsolatedGalaxy simulation, using the same code as before
> (below for reference)  but everything works fine.
>
> I did learn that if I don't do quantities.total_mass() on any clump, I get
> sensical results, but as soon as I do call total_mass, it eliminates the
> data on all clumps.  This simulation has only tracer particles, an no other
> particles, is that possibly the problem?
>

Ah, thanks for the hint, I can reproduce this using IsolatedGalaxy now.  I
will file an issue shortly. Having a repro script should help debugging
here.

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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141217/f7678567/attachment.htm>
-------------- next part --------------
_______________________________________________
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