<div dir="ltr">Hi, Stephanie--<div><br></div><div>I do this kind of thing with field_parameters. On some data object, you call </div><div>>>> object.set_field_parameter('vzmean',478)</div><div>then in your field definition, I do<br>
</div><div>def _Eturb(field,data):</div><div> vzmean = data.get_field_parameter('vzmean')</div><div> return data['z-velocity']-vzmean</div><div>add_field( 'Eturb', _Eturb, validators=[ValidateParameter('vzmean')])</div>
<div><br></div><div><div>So in your analysis, you</div><div>1.) define some object, as you're doing,<br></div><div>2.) set the field parameters on that object</div><div>3.) call your function</div></div><div><br></div>
<div>and to define the function, you need to</div><div>1.) call get_field_parameter to retrieve the value</div><div>2.) use the ValidateParameter validator to have yt error check that you have the field defined. (This, I believe, should be a list of ValidateParameter for each vxmean, vymean, and vzmean. Alternatively, you can supply a bulk velocity as a vector, which is my preference.)</div>
<div><br></div><div>I hope that helps. Let me know if you want me to clarify anything.</div><div>d.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 3:49 PM, Stephanie Tonnesen <span dir="ltr"><<a href="mailto:stonnes@gmail.com" target="_blank">stonnes@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>Hi yt-users!<br><br></div>So I want to calculate the turbulent energy in a stripped tail of gas. This tail is moving with a bulk flow in the z-direction, which varies as a function of z, and is rotating, and v_theta will also likely change as a function of z (and while I am at it, might as well check v_r). So I would like to do something like this:<br>
<br></div>def _Eturb(field,data):<br></div> vrmean = value I calculate in the code<br></div> vthetamean = value I calculate in the code<br></div> vzmean = value I calculate in the code<br></div> return(pow(data["cyl_RadialVelocity"]-vrmean,2) + pow(data["cyl_TangentialVelocity"]-vthetamean,2) + pow(data["z-velocity"]-vzmean,2))<br>
<br></div>add_field("Eturb",function=_Eturb,units="velocityunits")<br><br>totalEturb = np.zeros(100,float)<br>pf = load("id0/rps."+outstring[i]+"<div>.vtk",parameters={"TimeUnits":9.78262,"LengthUnits":26.,"DensityUnits":9.999e-30,"VelocityUnits":2.6e8})<br>
<br></div><div>alld = pf.h.all_data()<br></div><div>i = 0<br></div><div>while i < 100:<br></div><div> disk = pf.h.disk([0.0,0.0,i*0.385/2.],[0.0,0.0,1.0],1.0,0.385)<br></div><div> vrmean = disk.quantities["WeightedAverageQuantity"]("cyl_RadialVelocity","Ones")<br>
</div><div> vthetamean = disk.quantities["WeightedAverageQuantity"]("cyl_TangentialVelocity","Ones")<br></div><div> vzmean = disk.quantities["WeightedAverageQuantity"]("z-velocity","Ones")<br>
<br></div><div> totalEturb[i] = disk.quantities["TotalQuantity"]["Eturb"]<br></div><div> i = i+1<br><br></div>I am not sure if/how I can make the def statement read in vrmean, vthetamean, and vzmean?<br>
<br></div><div>Thanks!<span class="HOEnZb"><font color="#888888"><br><br>Stephanie<br></font></span></div></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">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>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">-- Sent from a computer.<br></div>
</div>