[yt-users] TIPSY to regular grid

Bruno Villasenor br1villasen at gmail.com
Wed Dec 16 10:43:34 PST 2015


Hi Nathan,

I tried using the tipsy dataset from yt public data and I get the same
error using version 3.1-dev.

I just installed the newest version (3.3-dev) and it works fine for both
datasets, seems like the bug was corrected in the newer version.

Now I'm having problems with the smoothed_covering_grid, here is the code:
#######################################################################
ds = yt.load( dataDir + dataFile, parameter_file= dataDir + paramFile )
ad = ds.all_data()
left = ad.left_edge

level = 5
data = ds.covering_grid(level=level, left_edge=left,
                                      dims=ds.domain_dimensions * 2**level)
dataSmoth = ds.smoothed_covering_grid(level=level, left_edge=left,
                                      dims=ds.domain_dimensions * 2**level)

gasDens = dataSmoth[('deposit', 'Gas_smoothed_density')].v
#######################################################################

And with both my dataset and the public tipsy dataset I get this error:

In [38]: run volume_dm_simple.py
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/bruno/Desktop/Dropbox/Developer/parallax/gas_images/volume_dm_simple.py
in <module>()
     16                                       dims=ds.domain_dimensions *
2**level)
     17
---> 18 gasDens = dataSmoth[('deposit', 'Gas_smoothed_density')].v

/home/bruno/apps/yt_3.3/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
in __getitem__(self, key)
    266                 return self.field_data[f]
    267             else:
--> 268                 self.get_data(f)
    269         # fi.units is the unit expression string. We depend on the
registry
    270         # hanging off the dataset to define this unit object.

/home/bruno/apps/yt_3.3/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.pyc
in get_data(self, fields)
    611         if len(fields_to_get) == 0: return
    612         fill, gen, part, alias = self._split_fields(fields_to_get)
--> 613         if len(part) > 0: self._fill_particles(part)
    614         if len(fill) > 0: self._fill_fields(fill)
    615         for a, f in sorted(alias.items()):

/home/bruno/apps/yt_3.3/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.pyc
in _fill_particles(self, part)
    641     def _fill_particles(self, part):
    642         for p in part:
--> 643             self[p] = self._data_source[p]
    644
    645     def _fill_fields(self, fields):

TypeError: 'NoneType' object has no attribute '__getitem__'
########################################################################

Thanks for the help.
Bruno

2015-12-14 10:33 GMT-06:00 Nathan Goldbaum <nathan12343 at gmail.com>:

> Hi Bruno,
>
> Can you reproduce this using one of the test tipsy datasets we have on
> yt-project.org/data? The "agora_1e11.00400" dataset might be a good place
> to start.
>
> If you can reproduce it using a public test dataset, you should create an
> issue to track this here, including your reproduction script:
>
> https://bitbucket.org/yt_analysis/yt/issues/new
>
> If it doesn't trigger on anything but your data, we can try sharing your
> dataset offline so that one of us can reproduce the issue on our local
> machine.
>
> -Nathan
>
> On Fri, Dec 11, 2015 at 10:45 PM, Bruno Villasenor <br1villasen at gmail.com>
> wrote:
>
>> Hi Matthew,
>>
>> Here it goes:
>>
>>
>> ---------------------------------------------------------------------------
>> ValueError                                Traceback (most recent call
>> last)
>> /home/bruno/Desktop/Dropbox/Developer/parallax/gas_images/volume_dm.py in
>> <module>()
>>      38                                       dims=ds.domain_dimensions *
>> 2**level)
>>      39
>> ---> 40 dmDens = data[('deposit','DarkMatter_density')]
>>      41
>>      42
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in __getitem__(self, key)
>>     238                 return self.field_data[f]
>>     239             else:
>> --> 240                 self.get_data(f)
>>     241         # fi.units is the unit expression string. We depend on
>> the registry
>>     242         # hanging off the dataset to define this unit object.
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.pyc
>> in get_data(self, fields)
>>     507         fill, gen, part = self._split_fields(fields_to_get)
>>     508         if len(part) > 0: self._fill_particles(part)
>> --> 509         if len(fill) > 0: self._fill_fields(fill)
>>     510         if len(gen) > 0: self._generate_fields(gen)
>>     511
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.pyc
>> in _fill_fields(self, fields)
>>     539         domain_dims = self.ds.domain_dimensions.astype("int64") \
>>     540                     * self.ds.relative_refinement(0, self.level)
>> --> 541         for chunk in self._data_source.chunks(fields, "io"):
>>     542             input_fields = [chunk[field] for field in fields]
>>     543             # NOTE: This usage of "refine_by" is actually *okay*,
>> because it's
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in chunks(self, fields, chunking_style, **kwargs)
>>     564         for chunk in self.index._chunk(self, chunking_style,
>> **kwargs):
>>     565             with self._chunked_read(chunk):
>> --> 566                 self.get_data(fields)
>>     567                 # NOTE: we yield before releasing the context
>>     568                 yield self
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in get_data(self, fields)
>>     670
>>     671         fields_to_generate += gen_fluids + gen_particles
>> --> 672         self._generate_fields(fields_to_generate)
>>     673         for field in self.field_data.keys():
>>     674             if field not in ofields:
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_fields(self, fields_to_generate)
>>     690                 fi = self.ds._get_field_info(*field)
>>     691                 try:
>> --> 692                     fd = self._generate_field(field)
>>     693                     if type(fd) == np.ndarray:
>>     694                         fd = self.ds.arr(fd, fi.units)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_field(self, field)
>>     275                 tr = self._generate_particle_field(field)
>>     276             else:
>> --> 277                 tr = self._generate_fluid_field(field)
>>     278             if tr is None:
>>     279                 raise YTCouldNotGenerateField(field, self.ds)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_fluid_field(self, field)
>>     293             finfo.check_available(gen_obj)
>>     294         except NeedsGridType as ngt_exception:
>> --> 295             rv = self._generate_spatial_fluid(field,
>> ngt_exception.ghost_zones)
>>     296         else:
>>     297             rv = finfo(gen_obj)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_spatial_fluid(self, field, ngz)
>>     309                     o = self._current_chunk.objs[0]
>>     310                     with o._activate_cache():
>> --> 311                         ind += o.select(self.selector,
>> self[field], rv, ind)
>>     312         else:
>>     313             chunks = self.index._chunk(self, "spatial", ngz = ngz)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in __getitem__(self, key)
>>     238                 return self.field_data[f]
>>     239             else:
>> --> 240                 self.get_data(f)
>>     241         # fi.units is the unit expression string. We depend on
>> the registry
>>     242         # hanging off the dataset to define this unit object.
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in get_data(self, fields)
>>     670
>>     671         fields_to_generate += gen_fluids + gen_particles
>> --> 672         self._generate_fields(fields_to_generate)
>>     673         for field in self.field_data.keys():
>>     674             if field not in ofields:
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_fields(self, fields_to_generate)
>>     690                 fi = self.ds._get_field_info(*field)
>>     691                 try:
>> --> 692                     fd = self._generate_field(field)
>>     693                     if type(fd) == np.ndarray:
>>     694                         fd = self.ds.arr(fd, fi.units)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_field(self, field)
>>     275                 tr = self._generate_particle_field(field)
>>     276             else:
>> --> 277                 tr = self._generate_fluid_field(field)
>>     278             if tr is None:
>>     279                 raise YTCouldNotGenerateField(field, self.ds)
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc
>> in _generate_fluid_field(self, field)
>>     295             rv = self._generate_spatial_fluid(field,
>> ngt_exception.ghost_zones)
>>     296         else:
>> --> 297             rv = finfo(gen_obj)
>>     298         return rv
>>     299
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/fields/derived_field.pyc in
>> __call__(self, data)
>>     182                 "for %s" % (self.name,))
>>     183         with self.unit_registry(data):
>> --> 184             dd = self._function(self, data)
>>     185         for field_name in data.keys():
>>     186             if field_name not in original_fields:
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/fields/particle_fields.pyc in
>> particle_density(field, data)
>>     104         d = data.deposit(pos, [data[ptype, mass_name]], method =
>> "sum")
>>     105         d = data.ds.arr(d, "code_mass")
>> --> 106         d /= data["index", "cell_volume"]
>>     107         return d
>>     108
>>
>> /home/bruno/apps/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in
>> __idiv__(self, other)
>>     747         """ See __div__. """
>>     748         oth = sanitize_units_mul(self, other)
>> --> 749         np.divide(self, oth, out=self)
>>     750         return self
>>     751
>>
>> ValueError: operands could not be broadcast together with shapes
>> (2,2,2,8) (2,2,2,0) (2,2,2,8)
>>
>> 2015-12-11 22:27 GMT-06:00 Matthew Turk <matthewturk at gmail.com>:
>>
>>> Hi Bruno,
>>>
>>> That's an odd one -- can you supply the rest of the traceback?
>>>
>>> On Fri, Dec 11, 2015 at 10:16 PM, Bruno Villasenor
>>> <br1villasen at gmail.com> wrote:
>>> > Hello yt-users,
>>> >
>>> > I'm trying to get data from a TIPSY file to a fixed resolution array,
>>> > The simplest version of my code is below:
>>> >
>>> > #####################################################
>>> > ds = yt.load( dataDir + dataFile,
>>> >  parameter_file= dataDir + paramFile )
>>> >
>>> > ad = ds.all_data()
>>> > left = ad.left_edge
>>> >
>>> > level = 1
>>> > data = ds.covering_grid(level=level, left_edge=left,
>>> >                                       dims=ds.domain_dimensions *
>>> 2**level)
>>> >
>>> > dmDens = data[('deposit','DarkMatter_density')]
>>> > ####################################################
>>> >
>>> > I'm getting this error:
>>> > ValueError: operands could not be broadcast together with shapes
>>> (2,2,2,8)
>>> > (2,2,2,0) (2,2,2,8)
>>> >
>>> > Any ideas?
>>> >
>>> > YT_version: 3.1-dev
>>> >
>>> > Thanks in advance.
>>> > Bruno
>>> >
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > 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
>>
>>
>
> _______________________________________________
> 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/20151216/e13b9b8b/attachment.htm>


More information about the yt-users mailing list