[yt-users] passing parameters to 'ray'

Elizabeth Tasker taskere at mcmaster.ca
Wed Aug 10 15:21:26 PDT 2011


Hi Sam,

Thank you -- my test script now works fine but I've managed to break my 
longer one so completely it's become impossible to test anything. Oops. 
However, I think when I tried the method below originally, I put the 
set_field_parameters in the wrong place, which would explain why they 
didn't work.

Thanks loads for the example.

Elizabeth

Sam Skillman wrote:
> 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 
> <mailto: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>
>         <mailto: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>
>         <mailto:yt-users at lists.spacepope.org
>         <mailto:yt-users at lists.spacepope.org>>
>
>         > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>         ------------------------------------------------------------------------
>
>
>
>         _______________________________________________
>         yt-users mailing list
>         yt-users at lists.spacepope.org <mailto:yt-users at lists.spacepope.org>
>         http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>          
>
>
>
>     _______________________________________________
>     yt-users mailing list
>     yt-users at lists.spacepope.org <mailto:yt-users at lists.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
>   




More information about the yt-users mailing list