<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=""><div class="">Dear Nathan,</div><div class=""><br class=""></div><div class="">Thank you very much for your help.</div><div class="">I was using ds.add_field()</div><div class=""><br class=""></div><div class="">I have pasted my script and error message here:</div><div class=""><a href="http://paste.yt-project.org/show/wToLggLnTYVpMxeqJtln/" class="">http://paste.yt-project.org/show/wToLggLnTYVpMxeqJtln/</a></div><div class=""><br class=""></div><div class="">Many thanks,</div><div class="">Kuo-Chuan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 1, 2016, at 3:50 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" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><br class="Apple-interchange-newline"><br class=""><div class="gmail_quote">On Tue, Nov 1, 2016 at 2:40 PM, Kuo-Chuan Pan<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:pankuoch@msu.edu" target="_blank" class="">pankuoch@msu.edu</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" 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="m_-6801954723337001028Apple-tab-span" style="white-space: pre-wrap;">        </span>yt : [ERROR ] 2016-11-01 15:25:27,650 YTFieldUnitParseError: The field '('gas', 'Entropy')' has unparseable units 'kB’. </div></div></blockquote><div class=""><br class=""></div><div class="">Did you use ds.add_field as I showed in my previous e-mail or yt.add_field as you originally had in your last e-mail? You need to use ds.add_field as I showed in my code snippet for my workaround to work properly.</div><div class=""><br class=""></div><div class="">If you *did* use ds.add_field, can you pastebin the full script, along with any error messages and tracebacks you received upon running the script?</div><div class=""><br class=""></div><div class="">We have<span class="Apple-converted-space"> </span><a href="http://paste.yt-project.org/" class="">paste.yt-project.org</a><span class="Apple-converted-space"> </span>set up for this purpose.</div><div class=""><br class=""></div><div class="">-Nathan</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><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=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 1, 2016, at 2:52 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank" class="">nathan12343@gmail.com</a>> wrote:</div><br class="m_-6801954723337001028Apple-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" target="_blank" class="">https://bitbucket.org/yt_<wbr class="">analysis/yt/src/<wbr class="">334cceb2c6e197acf1a8c7f273ee9d<wbr class="">d0bd592f58/yt/frontends/flash/<wbr class="">fields.py?at=yt&fileviewer=<wbr class="">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="">   <span class="Apple-converted-space"> </span>from yt.units import kb</div><div class="">   <span class="Apple-converted-space"> </span>from yt.units.dimensions import energy, temperature<br class=""></div><div class=""><br class=""></div><div class="">   <span class="Apple-converted-space"> </span># load your dataset</div><div class="">   <span class="Apple-converted-space"> </span>ds = yt.load(...)</div><div class=""><br class=""></div><div class="">   <span class="Apple-converted-space"> </span>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="">   <span class="Apple-converted-space"> </span>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()/P<wbr class="">NS_DENSITY)**5))+PNS_ENTR</div><div style="font-size: 12.8px;" class="">         return kb*entrdens</div><div style="font-size: 12.8px;" class="">   <span class="Apple-converted-space"> </span>ds.add_field("Entropy",functio<wbr class="">n=_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 class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:pankuoch@msu.edu" target="_blank" class="">pankuoch@msu.edu</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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=""> <span class="Apple-converted-space"> </span>11 def _entrdens(field,data):</div><div class=""> <span class="Apple-converted-space"> </span>12     """</div><div class=""> <span class="Apple-converted-space"> </span>13     create a new derived field to show both entropy and density</div><div class=""> <span class="Apple-converted-space"> </span>14     """</div><div class=""> <span class="Apple-converted-space"> </span>15     dens = data["dens"]</div><div class=""> <span class="Apple-converted-space"> </span>16     entr = data["entr"]</div><div class=""> <span class="Apple-converted-space"> </span>17     entrdens = entr*(np.exp(-(dens.in_cgs()/P<wbr class="">NS_DENSITY)**5))+PNS_ENTR</div><div class=""> <span class="Apple-converted-space"> </span>18     return entrdens</div><div class=""> <span class="Apple-converted-space"> </span>19 yt.add_field("Entropy",functio<wbr class="">n=_entrdens,units="dimensionle<wbr class="">ss") </div><div class=""><div class="m_-6801954723337001028h5"><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_-6801954723337001028m_-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 class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:pankuoch@msu.edu" target="_blank" class="">pankuoch@msu.edu</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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.o<wbr class="">rg</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/lis<wbr class="">tinfo.cgi/yt-users-spacepope.<wbr class="">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" 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=""><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></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></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">yt-users mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:yt-users@lists.spacepope.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">yt-users@lists.spacepope.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a></div></blockquote></div><br class=""></body></html>