<div dir="ltr">you need to write ejected density as a raw string in python so it doesn't interpret a "_" as a subscript.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 28, 2016 at 4:09 PM, 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>Hi Nathan, <br><br></div>Thank you very much for the quick solution, As an appreciation I am uploading the new render for the derived field. A bit of work has to be done with the LaTex labeling I guess,  but for now I will just customize the label. <br><br></div>Thanks<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">Tazkera<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 28, 2016 at 11:04 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"><span><div>On Sat, Aug 27, 2016 at 8:43 PM, tazkera haque <span dir="ltr"><<a href="mailto:h.tazkera@gmail.com" target="_blank">h.tazkera@gmail.com</a>></span> wrote:<br></div></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi yt people, <div><br></div><div>I just updated to yt 3.3.1 to use all the new features of volume rendering. I am trying to render ejected density which is a derived field and draw the coordinate triads, domain boundary along with labels showing the log range of ejected density. my code is attached. While my code worked fine with default field 'density', the following figure was produced for 'density', but I am getting error when the source field is set to 'ejected_density'. </div></div></blockquote><div><br></div></span><div>Hi Tazkera,</div><div><br></div><div>First, very nice rendering!</div><div><br></div><div>As for your error, this is due to a bug in yt --- thank you for the report! I have issued a pull request so this bug can be fixed for yt 3.3.2:</div><div><br></div><div><a href="https://bitbucket.org/yt_analysis/yt/pull-requests/2351" target="_blank">https://bitbucket.org/yt_analy<wbr>sis/yt/pull-requests/2351</a><br></div><div><br></div><div>For your specific use case, the easiest way to work around this without applying my bugfix is to change how you're creating the ejected_density derived field. Instead of using the @derived_field decorator, it will work correctly if you use the ds.add_field function. To make that explicit, where you currently have:</div><div><br></div><div><div>    @derived_field(name = "ejected_density", units = "g/cm**3")</div><div>    def _get_ejected_density(field, data):</div><div>        E = 0.5* data["cell_mass"]* (data["velx"]**2+data["vely"]*<wbr>*2+data["velz"]**2)+ data["gpot"]*data["cell_mass"]</div><div>        return ((np.array(E)>=0)*1)*data["den<wbr>sity"]</div></div><div><br></div><div>    ds = yt.load(...)</div><div><br></div><div>You will instead have:</div><div><br></div><div>    def _get_ejected_density(field, data):</div><div>        E = 0.5* data["cell_mass"]* (data["velx"]**2+data["vely"]*<wbr>*2+data["velz"]**2)+ data["gpot"]*data["cell_mass"]</div><div>        return ((np.array(E)>=0)*1)*data["den<wbr>sity"]</div><div><br></div><div>    ds = yt.load(...)</div><div><br></div><div>    ds.add_field(function=_get_eje<wbr>cted_density, name='ejected_density', units='g/cm**3')</div><div><br></div><div>What's happening is that if you use the @derived_field decorator, yt's field machinery doesn't associate the derived field you add to a specific dataset. This is normally fine, but when the field tries to generate a nice LaTeX label for the field, it assumes that a dataset is available (e.g. for fields with units like 'code_mass/code_length**3' where we need to have a dataset available to know what 'code_mass' or 'code_length' mean). This isn't true for locally defined fields, causing the crash you're seeing.</div><div><br></div><div>Sorry about the need for the workaround, but thank you again for the detailed report and script, which were key for me to be able to see what was going wrong and reproduced the bug locally.</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Also the 'density' figure still does not show either the coordinate triads or the domain boundary. I would appreciate your help to fix the error and thanks in advance.</div></div></blockquote><div><br></div></span><div>This is probably because the alpha values you're setting in annotate_axes and annotate_domain are too low for this rendering. Try increasing them.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span><div dir="ltr"><div><br></div><div><div><b>Traceback (most recent call last):</b></div><div><b>  File "volume_render_test.py", line 117, in <module></b></div><div><b>    text_annotate=[[(.1, 1.05), text_string]])</b></div><div><b>  File "/work/03858/thaque56/sw/yt-ne<wbr>w-3.3/yt-conda/lib/python2.7/s<wbr>ite-packages/yt/visualization/<wbr>volume_rendering/scene.py", line 395, in save_annotated</b></div><div><b>    label = rs.data_source.ds._get_field_i<wbr>nfo(rs.field).get_label()</b></div><div><b>  File "/work/03858/thaque56/sw/yt-ne<wbr>w-3.3/yt-conda/lib/python2.7/s<wbr>ite-packages/yt/fields/derived<wbr>_field.py", line 225, in get_label</b></div><div><b>    units = Unit(self.units, registry=self.ds.unit_registry<wbr>)</b></div><div><b>AttributeError: 'NoneType' object has no attribute 'unit_registry'</b></div></div><div><b><br></b></div><div><b><br></b></div><div><b>Thanks</b></div><span><font color="#888888"><div><b>Tazkera</b></div></font></span></div>
<br></span>______________________________<wbr>_________________<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/lis<wbr>tinfo.cgi/yt-users-spacepope.o<wbr>rg</a><br>
<br></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<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/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-users-<wbr>spacepope.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Michael Zingale</div><div>Associate Professor</div><div><br></div><div>Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY 11794-3800</div><div><i>phone</i>:  631-632-8225</div><div><i>e-mail</i>: <a href="mailto:Michael.Zingale@stonybrook.edu" target="_blank">Michael.Zingale@stonybrook.edu</a></div><div><i>web</i>: <a href="http://www.astro.sunysb.edu/mzingale" target="_blank">http://www.astro.sunysb.edu/mzingale</a></div><div>github: <a href="http://github.com/zingale" target="_blank">http://github.com/zingale</a></div><div><br></div></div></div></div>
</div>