[yt-users] yt.utilities.amr_utils

Renyue Cen cen at astro.princeton.edu
Sun Jan 13 10:31:04 PST 2013

Hi Matt,

Thanks very much for your prompt help.
Ok, I switched to lib now.
I am trying to do volume rendering of young stars (those formed in the last 100 Myrs, say),
so I did (by emulating some routines I found):

from yt.utilities.lib import CICDeposit_3

def _convertDensity(data):
    return data.convert("Density")
def _spdensity(field, data):
    blank = na.zeros(data.ActiveDimensions, dtype='float32')
    if data.NumberOfParticles == 0: return blank
    filter  = data.pf.time_units['years']*(data.pf.current_time - data['creation_time']) < 1.e8
    if not filter.any(): return blank
                           blank, na.array(data.LeftEdge).astype(na.float64),
    return blank
add_field("star_density", function=_spdensity,
          validators=[ValidateSpatial(0)], convert_function=_convertDensity)

this new "star_density" of my own is actually for young stars only
(I initially named things like SFR_density instead of the already defined star_density in the above,
but AMRKDTree does not seem to recognize it, so I am re-using the already defined variable "star_density"
to see if that works). Could I do better in this case?



On Jan 13, 2013, at 1:20 PM, Matthew Turk wrote:

> Hi Renyue,
> The module amr_utils became lib a while back.  But my guess is that
> you probably don't need to import it anyway, unless you are explicitly
> using one of the routines it provides.
> -Matt
> On Sun, Jan 13, 2013 at 12:18 PM, Renyue Cen <cen at astro.princeton.edu> wrote:
>> Hi,
>> I am trying to compute gridded density of some subset of particles.
>> So I tried to import some modules first in the python script as follows:
>> from yt.data_objects.field_info_container import \
>>    FieldInfoContainer, \
>>    NullFunc, \
>>    TranslationFunc, \
>>    FieldInfo, \
>>    ValidateParameter, \
>>    ValidateDataField, \
>>    ValidateProperty, \
>>    ValidateSpatial, \
>>    ValidateGridType
>> import yt.data_objects.universal_fields
>> from yt.utilities.physical_constants import mh
>> from yt.funcs import *
>> import yt.utilities.amr_utils as amr_utils
>> But I got this error message:
>> Traceback (most recent call last):
>>  File "SFR.py", line 28, in <module>
>>    import yt.utilities.amr_utils as amr_utils
>> ImportError: No module named amr_utils
>> Am I doing something wrong?
>> Thanks,
>> Renyue

More information about the yt-users mailing list