<div dir="ltr">Hello Turhan<br><div><br></div><div>Try this whether it works or helps you or not. <br></div><div><br><b><br>def _Varlist(field, data):<br> varlist = [data["Gx"], data["Gy"], data["Gz"]]<br> return varlist<br>yt.add_field("varlist", function=_Varlist, take_log=False, units="code length/ code time**2")<br><br> slc = yt.SlicePlot(ds, 'z', 'varlist', origin="native")<br><br></b></div><div>I hope it will work.<br><br><br><br></div><div>Regrads<br></div><div>Prateek<br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 27, 2016 at 4:19 PM, Prateek Gupta <span dir="ltr"><<a href="mailto:prateekgidolia@gmail.com" target="_blank">prateekgidolia@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>Hello Tazkera<br><br>As much I understood, you want to store values of Gx, Gy, Gz in array named varlist. But your syntax<br>varlist = ['Gx', 'Gy', 'Gz']<br></div><div>will not store values of Gx, Gy, Gz. It stores Gx, Gy, Gz as strings in varlist.<br></div><div>if you want to store values you have to write syntax as <br></div><div>varlist = [Gx, Gy, Gz]<br><br></div><div>But this will also not work for you. Because if you want to take the slice plot then you have to define varlist as field I think.<br></div><div>I will try to solve it. And we will wait for Nathan reply also.<br><br><br></div><div>Regards<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Prateek <br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 25, 2016 at 7:24 AM, tazkera haque <span dir="ltr"><<a href="mailto:h.tazkera@gmail.com" target="_blank">h.tazkera@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>Hi Prateek and Nathan, <br><br></div>thanks for your suggestion, I did accordingly, and seems the field is not add up properly. I have attached the error.<br></div><br>At this point I would ask you to kindly take a look at my code too, i am new in python and I want to make sure I am not doing other things wrong along with it. <br><br></div>I am trying to make slice plots of gravitational acceleration through z-axis from the FLASH plotfiles and make a folder with it. <br></div>thanks in advance. <br><br></div>Turhan<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 24, 2016 at 9:20 AM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Jun 24, 2016 at 6:40 AM, Prateek Gupta <span dir="ltr"><<a href="mailto:prateekgidolia@gmail.com" target="_blank">prateekgidolia@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">Hello Turhan,<div><br><div>I am not sure but I think this will work, you can try this...</div><div><br></div><div><br></div><div><b>ds = yt.load("data_file_Name")</b></div><div><b>grad = ds.add_gradient_fields(("gas","gravitational_potential"))<br></b></div><div><br></div><div><b>grad </b>list will have a list of new field names which representing the 3 different components of the field and the magnitude of the gradient , e.g., "<i>gravitational_potential_gradient_x</i>" , "<i>gravitational_potential_gradient_y</i>" , "<i>gravitational_potential_gradient_z</i>" and "<i>gravitational_potential_gradient_magnitude</i>"</div><div><br></div><div>Now for getting the negative gradient of gravitational potential we can derive field as follows:</div><div><br></div><div><br></div><div><b>####...x-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientX(field, data)</b></div><div><b> Gx = -1.0*data["gravitational_potential_gradient_x"]</b></div><div><b> return Gx</b></div><div><b>yt.add_field("Gx", function=_GradientX, take_log=False, units="code length/ code time**2")<br></b></div></div><div><b><br></b></div><div><div><b>####...y-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientY(field, data)</b></div><div><b> Gy = -1.0*data["gravitational_potential_gradient_y"]</b></div><div><b> return Gx</b></div><div><b>yt.add_field("Gy", function=_GradientY, take_log=False, units="</b><b>code length/ code time**2</b><b>")</b></div></div><div><b><br></b></div><div><div><b>####...z-component of negative of gradient of gravitational potential...</b></div><div><b>def _GradientZ(field, data)</b></div><div><b> Gz = -1.0*data["gravitational_potential_gradient_z"]</b></div><div><b> return Gz</b></div><div><b>yt.add_field("Gz", function=_GradientZ, take_log=False, units="</b><b>code length/ code time**2</b><b>")</b></div></div><div><b><br></b></div><div><br></div><div><br></div><div>Otherwise you can do this also, </div><div><b>grad = -1.0*ds.add_gradient_fields(("gas","gravitational_potential"))<br></b></div></div></blockquote><div><br></div></span><div>This isn't quite right. The ds.add_gradient_fields function returns a set of field names, not a field object itself. If you want to add the negative signs to the field definition, you'll need to define some derived fields as Prateek suggested above.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir="ltr"><div><b></b></div><div><br></div><div>I think this will work but this will also make the magnitude negative. But if you want to use only 3-components then this works and you can access it , e.g., <b>data["gravitational_potential_gradient_x"]</b> and similar for y and z component.</div><div><br></div><div><br></div><div><br></div><div>Please let me know if this work.</div><div><br></div><div><br></div><div><br></div><div>Regards</div><span><font color="#888888"><div>Prateek Gupta</div></font></span></div>
<br></span>_______________________________________________<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" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div></div>
<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" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
</div></div><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" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>