<div dir="ltr">Hey Mark,<div><br></div><div>Clearly this behavior is undesirable and thanks for bringing it to our attention. I'll file an issue so we can be sure to fix this before the next major release.</div><div><br>
</div><div style>For now, you should be able to get the desired effect with the following:</div><div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px"> dd.quantities["TotalQuantity"]('CellMassMsun')</span><br>
</div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">That will return the total gas mass in solar mass units. If you want it in CGS or code units, just use 'CellMass' or 'CellMassCode' respectively instead of 'CellMassMsun'. If you have any sink particles in your simulation, they won't be included in the sum, so you'll have to do that by hand.</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">-Nathan</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Mon, May 6, 2013 at 4:49 PM, Mark Krumholz <span dir="ltr"><<a href="mailto:krumholz@ucolick.org" target="_blank">krumholz@ucolick.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Hi All,<br>
<br>
I just updated to the latest version of yt, hoping that this would be fixed, but it seems not to be: the "TotalMass" function is broken for Orion data, and, from what I can tell, for any data set that doesn't contain dark matter particles. Here's what I get when I try to use it:<br>
<br>
In [1]: pf=load('data.0030.3d.hdf5')<br>
yt : [WARNING ] 2013-05-06 16:43:36,339 Setting 1.0 in code units to be 1.0 cm<br>
yt : [WARNING ] 2013-05-06 16:43:36,339 No time units. Setting 1.0 = 1 second.<br>
yt : [INFO ] 2013-05-06 16:43:36,340 Parameters: current_time = 6.78585436617e+13<br>
yt : [INFO ] 2013-05-06 16:43:36,340 Parameters: domain_dimensions = [256 256 256]<br>
yt : [INFO ] 2013-05-06 16:43:36,341 Parameters: domain_left_edge = [ -1.68000000e+18 -1.68000000e+18 -1.68000000e+18]<br>
yt : [INFO ] 2013-05-06 16:43:36,341 Parameters: domain_right_edge = [ 1.68000000e+18 1.68000000e+18 1.68000000e+18]<br>
<br>
In [2]: dd=pf.h.all_data()<br>
^[[Ayt : [INFO ] 2013-05-06 16:43:53,804 Adding unknown field gravitational-potential to list of fields<br>
<br>
In [3]: dd.quantities["TotalMass"]()<br>
---------------------------------------------------------------------------<br>
KeyError Traceback (most recent call last)<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/scripts/iyt in <module>()<br>
----> 1 dd.quantities["TotalMass"]()<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in __call__(self, *args, **kwargs)<br>
90 self._<a href="http://data_source.pf.h.io" target="_blank">data_source.pf.h.io</a>)<br>
91 if lazy_reader and not self.force_unlazy:<br>
---> 92 return self._call_func_lazy(args, kwargs)<br>
93 else:<br>
94 return self._call_func_unlazy(args, kwargs)<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in _call_func_lazy(self, args, kwargs)<br>
97 self.retvals = [ [] for i in range(self.n_ret)]<br>
98 for gi,g in enumerate(self._get_grids()):<br>
---> 99 rv = self.func(GridChildMaskWrapper(g, self._data_source), *args, **kwargs)<br>
100 if not iterable(rv): rv = (rv,)<br>
101 for i in range(self.n_ret): self.retvals[i].append(rv[i])<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in _TotalMass(data)<br>
152 """<br>
153 baryon_mass = data["CellMassMsun"].sum()<br>
--> 154 particle_mass = data["ParticleMassMsun"].sum()<br>
155 return [baryon_mass + particle_mass]<br>
156 def _combTotalMass(data, total_mass):<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc in __getitem__(self, item)<br>
58 def __getitem__(self, item):<br>
59 if item not in self.local_cache:<br>
---> 60 data = self.data_source._get_data_from_grid(self.grid, item)<br>
61 self.local_cache[item] = data<br>
62 return self.local_cache[item]<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in save_state(self, grid, field, *args, **kwargs)<br>
93 old_keys = grid.field_data.keys()<br>
94 grid.field_parameters = self.field_parameters<br>
---> 95 tr = func(self, grid, field, *args, **kwargs)<br>
96 grid.field_parameters = old_params<br>
97 grid.field_data = YTFieldData( [(k, grid.field_data[k]) for k in old_keys] )<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in _get_data_from_grid(self, grid, field)<br>
2643 return np.array([f[i,:][pointI] for i in range(3)])<br>
2644 else:<br>
-> 2645 tr = grid[field]<br>
2646 if tr.size == 1: # dx, dy, dz, cellvolume<br>
2647 tr = tr * np.ones(grid.ActiveDimensions, dtype='float64')<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in __getitem__(self, key)<br>
155 """<br>
156 if key not in self.field_data:<br>
--> 157 self.get_data(key)<br>
158 return self.field_data[key]<br>
159<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in get_data(self, field, convert)<br>
198 else: raise<br>
199 else:<br>
--> 200 self._generate_field(field)<br>
201 return self.field_data[field]<br>
202<br>
<br>
/home3/mkrumhol/yt-x86_64/src/yt-hg/yt/data_objects/grid_patch.pyc in _generate_field(self, field)<br>
145 self[field] = self.pf.field_info[field](self)<br>
146 else: # Can't find the field, try as it might<br>
--> 147 raise exceptions.KeyError(field)<br>
148<br>
149 def has_key(self, key):<br>
<br>
KeyError: 'ParticleMassMsun'<br>
<br>
This isn't a huge deal, because I can use "TotalQuantity" on "Density" as a workaround, but I thought I would report it.<br>
<br>
--<br>
Mark Krumholz<br>
<a href="mailto:krumholz@ucolick.org">krumholz@ucolick.org</a><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div><br></div>