Hi all, I tried to draw PDFs using ProfilePlot with "fractional" keyword. But, it returned unit incompatibility. I have looked at the code, and realized that the fractional keyword makes field_data dimensionless, while it tried to return data with units of original data. I think it must be easy to fix. Error message is attached below. Thanks, Chang-Goo ---------------------------------------------------------------------------YTUnitConversionError Traceback (most recent call last)<ipython-input-137-18016774c3d0> in <module>()----> 1 pdf=ProfilePlot(dd,"temp",['cell_mass','cell_volume'],weight_field=None,fractional=True) 2 pdf.show() /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/visualization/profile_plotter.pyc in __init__(self, data_source, x_field, y_fields, weight_field, n_bins, accumulation, fractional, label, plot_spec, profiles) 216 self.plot_spec = [self.plot_spec.copy() for p in self.profiles] 217 --> 218 self._setup_plots() 219 220 def save(self, name=None): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/visualization/profile_plotter.pyc in _setup_plots(self) 309 self.axes = AxesContainer(self.figures) 310 for i, profile in enumerate(self.profiles):--> 311 for field, field_data in profile.items(): 312 self.axes[field].plot(np.array(profile.x), 313 np.array(field_data), /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/data_objects/profiles.pyc in items(self) 854 855 def items(self):--> 856 return [(k,self[k]) for k in self.field_data.keys()] 857 858 def __iter__(self): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/data_objects/profiles.pyc in __getitem__(self, field) 851 raise KeyError(field) 852 else:--> 853 return self.field_data[fname].in_units(self.field_units[fname]) 854 855 def items(self): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in in_units(self, units) 358 359 """--> 360 new_units = self._unit_repr_check_same(units) 361 conversion_factor = self.units.get_conversion_factor(new_units) 362 /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in _unit_repr_check_same(self, units) 315 if not self.units.same_dimensions_as(units): 316 raise YTUnitConversionError(--> 317 self.units, self.units.dimensions, units, units.dimensions) 318 319 return units YTUnitConversionError: Unit dimensionalities do not match. Tried to convert between dimensionless (dim 1) and code_length**3 (dim (length)**3).
Hi Chang-Goo, Thanks for the bug report. I've issued a pull request to fix the issue here: https://bitbucket.org/yt_analysis/yt/pull-request/881/fixing-an-issue-with-t... I expect that to be merged soon. Once it's in you should be able to pull the change and update to get the fix. -Nathan On Tue, May 6, 2014 at 10:43 AM, Chang-Goo Kim <cgkim@astro.princeton.edu>wrote:
Hi all,
I tried to draw PDFs using ProfilePlot with "fractional" keyword. But, it returned unit incompatibility. I have looked at the code, and realized that the fractional keyword makes field_data dimensionless, while it tried to return data with units of original data. I think it must be easy to fix. Error message is attached below.
Thanks,
Chang-Goo
---------------------------------------------------------------------------YTUnitConversionError Traceback (most recent call last)<ipython-input-137-18016774c3d0> in <module>()----> 1 pdf=ProfilePlot(dd,"temp",['cell_mass','cell_volume'],weight_field=None,fractional=True) 2 pdf.show() /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/visualization/profile_plotter.pyc in __init__(self, data_source, x_field, y_fields, weight_field, n_bins, accumulation, fractional, label, plot_spec, profiles) 216 self.plot_spec = [self.plot_spec.copy() for p in self.profiles] 217 --> 218 self._setup_plots() 219 220 def save(self, name=None): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/visualization/profile_plotter.pyc in _setup_plots(self) 309 self.axes = AxesContainer(self.figures) 310 for i, profile in enumerate(self.profiles):--> 311 for field, field_data in profile.items(): 312 self.axes[field].plot(np.array(profile.x), 313 np.array(field_data), /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/data_objects/profiles.pyc in items(self) 854 855 def items(self):--> 856 return [(k,self[k]) for k in self.field_data.keys()] 857 858 def __iter__(self): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/data_objects/profiles.pyc in __getitem__(self, field) 851 raise KeyError(field) 852 else:--> 853 return self.field_data[fname].in_units(self.field_units[fname]) 854 855 def items(self): /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in in_units(self, units) 358 359 """--> 360 new_units = self._unit_repr_check_same(units) 361 conversion_factor = self.units.get_conversion_factor(new_units) 362 /u/cgkim/Sources/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in _unit_repr_check_same(self, units) 315 if not self.units.same_dimensions_as(units): 316 raise YTUnitConversionError(--> 317 self.units, self.units.dimensions, units, units.dimensions) 318 319 return units YTUnitConversionError: Unit dimensionalities do not match. Tried to convert between dimensionless (dim 1) and code_length**3 (dim (length)**3).
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (2)
-
Chang-Goo Kim
-
Nathan Goldbaum