[yt-users] getting the average density inside a data container

Britton Smith brittonsmith at gmail.com
Sat Nov 30 01:23:59 PST 2013


Hi Kearn,

I believe the issue with the region is that the arguments are center, left
corner, right corner.  Each of those needs to be a triple.

On the other issue, is AveragedDensity a field you created?  If not, I
don't believe it exists.  If you want to take the average inside some
object, you should do something like:
object.quantities["WeightedAverageQuantity"](field, weight_field)

Britton


On Sat, Nov 30, 2013 at 7:12 AM, <k.grisdale at surrey.ac.uk> wrote:

>  Hi yt Users
>
>  I am trying to create a data container that is a cube from which I can
> extract the average density of the gas inside the cube. I am using Ramses
> data.
>
>  When I create a data container using:
>
>  p6 = load("output_00006/info_00006.txt", fields =
> ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
> cen = [0, 0, 0]
> box = p6.h.region(cen, 0.2/p6['cm'], 0.3/p6['cm’])
>  print box["Density”]
>
>  I get this error:
>
>  TypeError: 'float' object has no attribute ‘__getitem__'
>
>  I have tried creating a sphere as a data container and this works for
> the Density, but then when I try to take the AverageDensity in the sphere:
>
>  sphere = p6.h.sphere(cen, 0.7/p6['cm’])
> print sphere['AveragedDensity’]
>
>   I get this error:
>
>  enerationInProgress                      Traceback (most recent call
> last)
> <ipython-input-28-574d78c4fb5c> in <module>()
> ----> 1 print sphere['AveragedDensity']
>
>  /Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
> in __getitem__(self, key)
>     187                 return self.field_data[f]
>     188             else:
> --> 189                 self.get_data(f)
>     190         # Note that this is less succinct so that we can account
> for the case
>     191         # when there are, for example, no elements in the object.
>
>  /Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
> in get_data(self, fields)
>     514             return
>     515         elif self._locked == True:
> --> 516             raise GenerationInProgress(fields)
>     517         # At this point, we want to figure out *all* our
> dependencies.
>     518         fields_to_get = self._identify_dependencies(fields_to_get)
>
>  Any idea what I am doing wrong or if there is another way to go about
> this?
>
>  Thanks
>
>  Kearn
>
> _______________________________________________
> 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/20131130/299c38ae/attachment.htm>


More information about the yt-users mailing list