<div dir="ltr"><div><span style="font-size:12.8px">One could argue that it would be useful for save_annotated to optionally take a fully user-specified colorbar label. That's not the case now but it would be a relatively easy modification.</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Your 'entr' field isn't being recognized by yt with units because it's not a field that is "known" by yt in the FLASH frontend:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><a href="https://bitbucket.org/yt_analysis/yt/src/334cceb2c6e197acf1a8c7f273ee9dd0bd592f58/yt/frontends/flash/fields.py?at=yt&fileviewer=file-view-default#fields.py-43">https://bitbucket.org/yt_analysis/yt/src/334cceb2c6e197acf1a8c7f273ee9dd0bd592f58/yt/frontends/flash/fields.py?at=yt&fileviewer=file-view-default#fields.py-43</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Specifically, it does not appear in the known_other_fields tuple in the flash fields.py file. If entr is not specific to your version of FLASH it may be worthwhile to add an entry there so that the entr field is read in with the correct units.</span></div><div><br></div>Similarly, kB isn't a unit that the yt unit system understands out of the box (although I think one could make a case that it's worth including). There is a way to add new units to the unit system though:<div><br></div><div><div>    from yt.units import kb</div><div>    from yt.units.dimensions import energy, temperature<br></div><div><br></div><div>    # load your dataset</div><div>    ds = yt.load(...)</div><div><br></div><div>    ds.unit_registry.add('kB', 1.3806488e-16, dimensions=energy/temperature, tex_repr='k_{B}')</div><div><br></div><div><div style="font-size:12.8px">    def _entrdens(field,data):</div><div style="font-size:12.8px">         """</div><div style="font-size:12.8px">         create a new derived field to show both entropy and density</div><div style="font-size:12.8px">         """</div><div style="font-size:12.8px">         dens = data["dens"]</div><div style="font-size:12.8px">         entr = data["entr"]</div><div style="font-size:12.8px">         entrdens = entr*(np.exp(-(dens.in_cgs()/<wbr>PNS_DENSITY)**5))+PNS_ENTR</div><div style="font-size:12.8px">         return kb*entrdens</div><div style="font-size:12.8px">    ds.add_field("Entropy",<wbr>function=_entrdens, units="kB", display_name="Entropy per Baryon") </div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">And then make your volume rendering as you were doing before. It should show up in the label as "Entropy per baryon" and with units of "kB".</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Please feel free to open issues or pull requests about any of the things I raised above.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">-Nathan</div><div style="font-size:12.8px"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 1:25 PM, Kuo-Chuan Pan <span dir="ltr"><<a href="mailto:pankuoch@msu.edu" target="_blank">pankuoch@msu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Dear Nathan,</div><div><br></div><div>Thanks very much for your help.</div><div>entropy is a filed in my FLASH dataset. The unit of entropy is kB/baryon in the code but it is recognised as dimensionless in yt.</div><div><br></div><div>The field “entr" is the entropy in my dataset. The derived field “Entropy” is the one I want to visualise. </div><div>PNS_DENSITY and PNS_ENTR are just constants. </div><div><br></div><div>Many thanks,</div><div>Kuo-Chuan</div><div><br></div><div>  11 def _entrdens(field,data):</div><div>  12     """</div><div>  13     create a new derived field to show both entropy and density</div><div>  14     """</div><div>  15     dens = data["dens"]</div><div>  16     entr = data["entr"]</div><div>  17     entrdens = entr*(np.exp(-(dens.in_cgs()/<wbr>PNS_DENSITY)**5))+PNS_ENTR</div><div>  18     return entrdens</div><div>  19 yt.add_field("Entropy",<wbr>function=_entrdens,units="<wbr>dimensionless") </div><div><div class="h5"><div><br></div><br><div><blockquote type="cite"><div>On Nov 1, 2016, at 2:20 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br class="m_-3922443210749000739Apple-interchange-newline"><div><div dir="ltr">Hi Kuo-Chuan,<div><br></div><div>Can you show us how you've defined your derived field?</div><div><br></div><div>Is entropy a derived field as well or is it a field that's included in your dataset? This is the entropy per baryon, right?</div><div><br></div><div>-Nathan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 1:09 PM, Kuo-Chuan Pan <span dir="ltr"><<a href="mailto:pankuoch@msu.edu" target="_blank">pankuoch@msu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br>
<br>
I have a custom new derived field based on density (g/cm^3) and entropy (kB/baryon but it is recognised as dimensionless).<br>
Currently, this new derived field is set to dimensionless (it should be kB/baryon).<br>
<br>
Could anyone teach me how to set this new derived filed to its correct unit (which should be kB/baryon)?<br>
Or is it possible to simply override the field label in my volume rendering plot before using save_annotated()?<br>
<br>
Many thanks,<br>
Kuo-Chuan<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>
</blockquote></div><br></div>
______________________________<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" target="_blank">http://lists.spacepope.org/<wbr>listinfo.cgi/yt-users-<wbr>spacepope.org</a><br></div></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></div>