[yt-users] a problem switching versions of yt?

Kathy Eastwood kathy.eastwood at nau.edu
Tue Apr 7 13:33:27 PDT 2015


Hi, I *think* I introduced this problem when switching from version 2 to
version 3...I am currently running version 3.1.

I define a derived field, number density, from the original density field,
but something seems to be wrong with the units. I cannot make a sliceplot
(as I used to be able to, in the old version), and I get other "unit
conversion errors".

thanks,
kathy

This cell works ok:

def _numdens(field, data):
    return data["dens"]/(2.36*10**(-24))
ds.add_field("numdens", function=_numdens, units="1/cm**3")

This cell does NOT work, and I get a very similar error when trying to do a
sliceplot:

maxval_numdens, maxloc_numdens = ds.find_max('numdens')
print maxval_numdens
print maxloc_numdens


YTUnitConversionError                     Traceback (most recent call
last)<ipython-input-12-8b3af9af1cf1> in <module>()----> 1
maxval_numdens, maxloc_numdens = ds.find_max('numdens')      2 print
maxval_numdens      3 print maxloc_numdens
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/static_output.pyc in
find_max(self, field)    524         source = self.all_data()    525
      max_val, maxi, mx, my, mz = \--> 526
source.quantities.max_location(field)    527         mylog.info("Max
Value is %0.5e at %0.16f %0.16f %0.16f",    528               max_val,
mx, my, mz)
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc
in __call__(self, field)    524     525     def __call__(self,
field):--> 526         rv = super(MaxLocation, self).__call__(field)
 527         if len(rv) == 1: rv = rv[0]    528         return rv
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc
in __call__(self, *args, **kwargs)     54         storage = {}     55
       for sto, ds in parallel_objects(chunks, -1, storage =
storage):---> 56             sto.result = self.process_chunk(ds,
*args, **kwargs)     57         # Now storage will have everything,
and will be done via pickling, so     58         # the units will be
preserved.  (Credit to Nathan for this
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/derived_quantities.pyc
in process_chunk(self, data, field)    535         mz =
array_like_field(data, -1, "z")    536         maxi = -1--> 537
 if data[field].size > 0:    538             maxi =
np.argmax(data[field])    539             ma = data[field][maxi]
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in
__getitem__(self, key)    246                 return
self.field_data[f]    247             else:--> 248
self.get_data(f)    249         # fi.units is the unit expression
string. We depend on the registry    250         # hanging off the
dataset to define this unit object.
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in
get_data(self, fields)    691     692         fields_to_generate +=
gen_fluids + gen_particles--> 693
self._generate_fields(fields_to_generate)    694         for field in
self.field_data.keys():    695             if field not in ofields:
/home/kde/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.pyc in
_generate_fields(self, fields_to_generate)    717
   raise RuntimeError    718
self.field_data[field] = fd--> 719
fd.convert_to_units(fi.units)    720                 except
GenerationInProgress as gip:    721                     for f in
gip.fields:
/home/kde/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in
convert_to_units(self, units)    387     388         """--> 389
 new_units = self._unit_repr_check_same(units)    390
(conversion_factor, offset) =
self.units.get_conversion_factor(new_units)    391
/home/kde/yt-x86_64/src/yt-hg/yt/units/yt_array.pyc in
_unit_repr_check_same(self, units)    373         if not
self.units.same_dimensions_as(units):    374             raise
YTUnitConversionError(--> 375                 self.units,
self.units.dimensions, units, units.dimensions)    376     377
return units
YTUnitConversionError: Unit dimensionalities do not match. Tried to
convert between code_mass/code_length**3 (dim (mass)/(length)**3) and
cm**(-3) (dim (length)**(-3)).






-- 
Kathy DeGioia Eastwood, Ph.D.
Professor of Physics and Astronomy
Northern Arizona University
Flagstaff, AZ 86011-6010
Ph: 928-523-7159   FX: 928-523-1371
Kathy.Eastwood at nau.edu
deliveries: 602 S. Humphreys St., Bldg 19 Rm 209
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150407/c59fbb25/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