<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Nathan,<div class=""><br class=""></div><div class="">Thanks very much for your email and suggestions.</div><div class="">I followed your suggested code but it is not working.</div><div class="">yt gives an error message:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>yt : [ERROR    ] 2016-11-01 15:25:27,650 YTFieldUnitParseError: The field '('gas', 'Entropy')' has unparseable units 'kB’. </div><div class=""><br class=""></div><div class="">The vales of my “entr” field is already in “kB/baryon” (specific entropy) but the unit is incorrect.</div><div class="">Following your suggestions, I want to create two new units called “kB” and “baryon” (1.674e-24 g) </div><div class="">and override the “entr” and “Entropy” units to “kB/baryon” (from dimensionless). </div><div class="">Is it possible to do that?</div><div class=""><br class=""></div><div class="">Many thanks,</div><div class="">Kuo-Chuan</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 1, 2016, at 2:52 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" class="">nathan12343@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><span style="font-size:12.8px" class="">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" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">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 class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class=""><a href="https://bitbucket.org/yt_analysis/yt/src/334cceb2c6e197acf1a8c7f273ee9dd0bd592f58/yt/frontends/flash/fields.py?at=yt&fileviewer=file-view-default#fields.py-43" class="">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 class=""></div><div class=""><span style="font-size:12.8px" class=""><br class=""></span></div><div class=""><span style="font-size:12.8px" class="">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 class=""><br class=""></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 class=""><br class=""></div><div class=""><div class="">    from yt.units import kb</div><div class="">    from yt.units.dimensions import energy, temperature<br class=""></div><div class=""><br class=""></div><div class="">    # load your dataset</div><div class="">    ds = yt.load(...)</div><div class=""><br class=""></div><div class="">    ds.unit_registry.add('kB', 1.3806488e-16, dimensions=energy/temperature, tex_repr='k_{B}')</div><div class=""><br class=""></div><div class=""><div style="font-size:12.8px" class="">    def _entrdens(field,data):</div><div style="font-size:12.8px" class="">         """</div><div style="font-size:12.8px" class="">         create a new derived field to show both entropy and density</div><div style="font-size:12.8px" class="">         """</div><div style="font-size:12.8px" class="">         dens = data["dens"]</div><div style="font-size:12.8px" class="">         entr = data["entr"]</div><div style="font-size:12.8px" class="">         entrdens = entr*(np.exp(-(dens.in_cgs()/<wbr class="">PNS_DENSITY)**5))+PNS_ENTR</div><div style="font-size:12.8px" class="">         return kb*entrdens</div><div style="font-size:12.8px" class="">    ds.add_field("Entropy",<wbr class="">function=_entrdens, units="kB", display_name="Entropy per Baryon") </div></div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">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" class=""><br class=""></div><div style="font-size:12.8px" class="">Please feel free to open issues or pull requests about any of the things I raised above.</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">-Nathan</div><div style="font-size:12.8px" class=""><br class=""></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 1, 2016 at 1:25 PM, Kuo-Chuan Pan <span dir="ltr" class=""><<a href="mailto:pankuoch@msu.edu" target="_blank" class="">pankuoch@msu.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Dear Nathan,</div><div class=""><br class=""></div><div class="">Thanks very much for your help.</div><div class="">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 class=""><br class=""></div><div class="">The field “entr" is the entropy in my dataset. The derived field “Entropy” is the one I want to visualise. </div><div class="">PNS_DENSITY and PNS_ENTR are just constants. </div><div class=""><br class=""></div><div class="">Many thanks,</div><div class="">Kuo-Chuan</div><div class=""><br class=""></div><div class="">  11 def _entrdens(field,data):</div><div class="">  12     """</div><div class="">  13     create a new derived field to show both entropy and density</div><div class="">  14     """</div><div class="">  15     dens = data["dens"]</div><div class="">  16     entr = data["entr"]</div><div class="">  17     entrdens = entr*(np.exp(-(dens.in_cgs()/<wbr class="">PNS_DENSITY)**5))+PNS_ENTR</div><div class="">  18     return entrdens</div><div class="">  19 yt.add_field("Entropy",<wbr class="">function=_entrdens,units="<wbr class="">dimensionless") </div><div class=""><div class="h5"><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 1, 2016, at 2:20 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank" class="">nathan12343@gmail.com</a>> wrote:</div><br class="m_-3922443210749000739Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Kuo-Chuan,<div class=""><br class=""></div><div class="">Can you show us how you've defined your derived field?</div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">-Nathan</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 1, 2016 at 1:09 PM, Kuo-Chuan Pan <span dir="ltr" class=""><<a href="mailto:pankuoch@msu.edu" target="_blank" class="">pankuoch@msu.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear all,<br class="">
<br class="">
I have a custom new derived field based on density (g/cm^3) and entropy (kB/baryon but it is recognised as dimensionless).<br class="">
Currently, this new derived field is set to dimensionless (it should be kB/baryon).<br class="">
<br class="">
Could anyone teach me how to set this new derived filed to its correct unit (which should be kB/baryon)?<br class="">
Or is it possible to simply override the field label in my volume rendering plot before using save_annotated()?<br class="">
<br class="">
Many thanks,<br class="">
Kuo-Chuan<br class="">
______________________________<wbr class="">_________________<br class="">
yt-users mailing list<br class="">
<a href="mailto:yt-users@lists.spacepope.org" target="_blank" class="">yt-users@lists.spacepope.org</a><br class="">
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/lis<wbr class="">tinfo.cgi/yt-users-spacepope.<wbr class="">org</a><br class="">
</blockquote></div><br class=""></div>
______________________________<wbr class="">_________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" target="_blank" class="">yt-users@lists.spacepope.org</a><br class=""><a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank" class="">http://lists.spacepope.org/<wbr class="">listinfo.cgi/yt-users-<wbr class="">spacepope.org</a><br class=""></div></blockquote></div><br class=""></div></div></div><br class="">______________________________<wbr class="">_________________<br class="">
yt-users mailing list<br class="">
<a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank" class="">http://lists.spacepope.org/<wbr class="">listinfo.cgi/yt-users-<wbr class="">spacepope.org</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br class=""></div></blockquote></div><br class=""></div></body></html>