[yt-users] passing parameters to 'ray'
Elizabeth Tasker
taskere at mcmaster.ca
Thu Aug 11 20:50:36 PDT 2011
Ah sorry; didn't realise this was the same issue.
On 2011-08-11, at 10:36 PM, Matthew Turk wrote:
> Elizabeth reported this bug about a week ago, so maybe followups can
> go on the bug report:
>
> http://hg.enzotools.org/yt/issue/295/passing-field-parameters-to-covering-grids
>
> On Thu, Aug 11, 2011 at 5:12 PM, Sam Skillman <samskillman at gmail.com> wrote:
>> Hi Elizabeth,
>> It looks like there might be an issue with the transfer of parameters after
>> using validate spatial, which creates a smoothed covering grid. I'll get
>> back to you when I figure it out.
>> Best,
>> Sam
>> On Thu, Aug 11, 2011 at 2:53 PM, Elizabeth Tasker <taskere at mcmaster.ca>
>> wrote:
>>>
>>> Hi Sam,
>>>
>>> OK, I've succeeded in breaking your improved script. When you try and set
>>> both parameter and spatial validators, the code stops recognising them. So:
>>>
>>> add_field("RayTest", function=_RayTest,
>>> validators=[ValidateParameter("disk_vector")])
>>>
>>> works while
>>>
>>> add_field("RayTest", function=_RayTest,
>>> validators=[ValidateParameter("disk_vector"),
>>> ValidateParameter("disk_center"), ValidateSpatial(1, ["x-velocity",
>>> "y-velocity", "z-velocity", "x", "y", "z"])])
>>>
>>> does not.Which it why it didn't work in my longer script.
>>>
>>> Perhaps I've put the format in incorrectly?
>>>
>>> Elizabeth
>>>
>>>
>>>
>>> Elizabeth Tasker wrote:
>>>>
>>>> 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
>>>>>
>>>>
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> 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
>>
>> _______________________________________________
>> yt-users mailing list
>> 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