[yt-users] passing parameters to 'ray'

Sam Skillman samskillman at gmail.com
Wed Aug 10 08:49:52 PDT 2011


Hi Elizabeth,

So the problem is that when you add_field and ask to validate the
height_vector, it doesn't exist yet.  I believe you can get the desired
behavior with:

from yt.mods import *

def _RayTest(field, data):

    center = data.get_field_parameter("center")
    h_vec = na.array(data.get_field_parameter("height_vector"))

    print "center :", center, "h_vec: ", h_vec

    return data["Density"]

add_field("RayTest", function=_RayTest)

# Grab data
fn = "GravPotential/DD0301/GT_BTAccel_256AMR4_PeHeat_sf5_SNe_0301"
pf = load(fn)
ray1 = pf.h.ray((2.0, 2.0 ,2.0), (12.0, 12.0, 12.0))
ray1.set_field_parameter('height_vector',na.array([0.,0.,1.]))
ray1.set_field_parameter('center',[0.5]*3)
ray1["RayTest"]

When I run this I get:
center : [0.5, 0.5, 0.5] h_vec:  [ 0.  0.  1.]

I'm not sure what dd was in your dd.center since dd wasn't defined in that
script, but you should be able to set center to whatever you want here.  I
also changed density to Density.

Best,
Sam

On Wed, Aug 10, 2011 at 9:36 AM, Elizabeth Tasker <taskere at mcmaster.ca>wrote:

> Hi Matt,
>
> I think this script explains what I mean. When I run it, I get:
>
> /1/home/taskere/yt/yt/data_**objects/field_info_container.**py in
> __call__(self, data)
>   357                 doesnt_have.append(p)
>   358         if len(doesnt_have) > 0:
> --> 359             raise NeedsParameter(doesnt_have)
>   360         return True
>   361
>
> NeedsParameter: (['height_vector'])
>
>
> As a side note, I think 'ray' sets its own value for the field parameter,
> "center", making it the start of the ray. If that's true, does it have
> problems for calling radius? e.g.
>
> ray["Radius"]
>
> where radius would need to be the center of the object, not necessarily the
> start of the ray? (This particular issue wouldn't affect me, but I thought
> it might bite someone later).
>
> Elizabeth
>
>
>
> Matthew Turk wrote:
>
>>
>> Hi Elizabeth,
>>
>> Could you elaborate on what you mean, and provide an example script?
>>
>> Thanks,
>>
>> -Matt
>>
>> On Aug 10, 2011 7:22 AM, "Elizabeth Tasker" <taskere at mcmaster.ca <mailto:
>> taskere at mcmaster.ca>> wrote:
>> > Hi,
>> >
>> > I'm having problems passing parameters to a ray object. I'm trying:
>> >
>> > ray1 = pf.h.ray( com[c], com[nearestcore], field_parameters =
>> > {'height_vector':na.array([0,**0,1]), 'center':dd.center})
>> > Omega0 = ray1["Omega"]
>> >
>> > and I also tried out:
>> >
>> > ray1.set_field_parameter("**height_vector", na.array([0,0,1]))
>> > ray1.set_field_parameter("**center", dd.center)
>> >
>> > But it can't recognise them.
>> >
>> > Elizabeth
>> > ______________________________**_________________
>> > yt-users mailing list
>> > yt-users at lists.spacepope.org <mailto:yt-users at lists.**spacepope.org<yt-users at lists.spacepope.org>
>> >
>>
>> > http://lists.spacepope.org/**listinfo.cgi/yt-users-**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<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/20110810/99ef3d3b/attachment.htm>


More information about the yt-users mailing list