Hi Elizabeth,<div><br></div><div>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. </div>
<div><br></div><div>Best,</div><div>Sam</div><div><br><div class="gmail_quote">On Thu, Aug 11, 2011 at 2:53 PM, Elizabeth Tasker <span dir="ltr"><<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Sam,<br>
<br>
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:<br>
<br>
add_field("RayTest", function=_RayTest, validators=[ValidateParameter(<u></u>"disk_vector")])<br>
<br>
works while<br>
<br>
add_field("RayTest", function=_RayTest, validators=[ValidateParameter(<u></u>"disk_vector"), ValidateParameter("disk_<u></u>center"), ValidateSpatial(1, ["x-velocity", "y-velocity", "z-velocity", "x", "y", "z"])])<br>
<br>
does not.Which it why it didn't work in my longer script.<br>
<br>
Perhaps I've put the format in incorrectly?<br>
<br>
Elizabeth<br><font color="#888888">
<br>
<br>
<br>
Elizabeth Tasker wrote:<br>
</font><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Hi Sam,<br>
<br>
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.<br>
<br>
Thanks loads for the example.<br>
<br>
Elizabeth<br>
<br>
Sam Skillman wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Hi Elizabeth,<br>
<br>
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:<br>
<br>
from yt.mods import *<br>
<br>
def _RayTest(field, data):<br>
<br>
center = data.get_field_parameter("<u></u>center")<br>
h_vec = na.array(data.get_field_<u></u>parameter("height_vector"))<br>
<br>
print "center :", center, "h_vec: ", h_vec<br>
<br>
return data["Density"]<br>
<br>
add_field("RayTest", function=_RayTest)<br>
<br>
# Grab data<br>
fn = "GravPotential/DD0301/GT_<u></u>BTAccel_256AMR4_PeHeat_sf5_<u></u>SNe_0301"<br>
pf = load(fn)<br>
ray1 = pf.h.ray((2.0, 2.0 ,2.0), (12.0, 12.0, 12.0)) ray1.set_field_parameter('<u></u>height_vector',na.array([0.,0.<u></u>,1.]))<br>
ray1.set_field_parameter('<u></u>center',[0.5]*3)<br>
ray1["RayTest"]<br>
<br>
When I run this I get: center : [0.5, 0.5, 0.5] h_vec: [ 0. 0. 1.]<br>
<br>
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.<br>
Best,<br>
Sam<br>
<br></div><div><div></div><div>
On Wed, Aug 10, 2011 at 9:36 AM, Elizabeth Tasker <<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a> <mailto:<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a>>> wrote:<br>
<br>
Hi Matt,<br>
<br>
I think this script explains what I mean. When I run it, I get:<br>
<br>
/1/home/taskere/yt/yt/data_<u></u>objects/field_info_container.<u></u>py in<br>
__call__(self, data)<br>
357 doesnt_have.append(p)<br>
358 if len(doesnt_have) > 0:<br>
--> 359 raise NeedsParameter(doesnt_have)<br>
360 return True<br>
361<br>
<br>
NeedsParameter: (['height_vector'])<br>
<br>
<br>
As a side note, I think 'ray' sets its own value for the field<br>
parameter, "center", making it the start of the ray. If that's<br>
true, does it have problems for calling radius? e.g.<br>
<br>
ray["Radius"]<br>
<br>
where radius would need to be the center of the object, not<br>
necessarily the start of the ray? (This particular issue wouldn't<br>
affect me, but I thought it might bite someone later).<br>
<br>
Elizabeth<br>
<br>
<br>
<br>
Matthew Turk wrote:<br>
<br>
<br>
Hi Elizabeth,<br>
<br>
Could you elaborate on what you mean, and provide an example<br>
script?<br>
<br>
Thanks,<br>
<br>
-Matt<br>
<br>
On Aug 10, 2011 7:22 AM, "Elizabeth Tasker"<br>
<<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a> <mailto:<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a>><br></div></div><div><div></div><div>
<mailto:<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a> <mailto:<a href="mailto:taskere@mcmaster.ca" target="_blank">taskere@mcmaster.ca</a>>>> wrote:<br>
> Hi,<br>
><br>
> I'm having problems passing parameters to a ray object. I'm<br>
trying:<br>
><br>
> ray1 = pf.h.ray( com[c], com[nearestcore], field_parameters =<br>
> {'height_vector':na.array([0,<u></u>0,1]), 'center':dd.center})<br>
> Omega0 = ray1["Omega"]<br>
><br>
> and I also tried out:<br>
><br>
> ray1.set_field_parameter("<u></u>height_vector", na.array([0,0,1]))<br>
> ray1.set_field_parameter("<u></u>center", dd.center)<br>
><br>
> But it can't recognise them.<br>
><br>
> Elizabeth<br>
> ______________________________<u></u>_________________<br>
> yt-users mailing list<br>
> <a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<mailto:<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.<u></u>spacepope.org</a>><br>
<mailto:<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.<u></u>spacepope.org</a><br>
<mailto:<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.<u></u>spacepope.org</a>>><br>
<br>
> <a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
------------------------------<u></u>------------------------------<u></u>------------<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.<u></u>spacepope.org</a>><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
<br>
<br>
______________________________<u></u>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a> <mailto:<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.<u></u>spacepope.org</a>><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
<br>
<br>
------------------------------<u></u>------------------------------<u></u>------------<br>
<br>
______________________________<u></u>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
<br>
</div></div></blockquote><div><div></div><div>
<br>
______________________________<u></u>_________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/<u></u>listinfo.cgi/yt-users-<u></u>spacepope.org</a><br>
</div></div></blockquote>
<br>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div>
</div>