<div dir="ltr">Which yt version is this? Can you reproduce it on yt 3.3.2?<div><br></div><div>Does the following simple test script work?</div><div><br></div><div><div style="font-size:12.8px">    from yt.units import kb</div><div style="font-size:12.8px">    from yt.units.dimensions import energy, temperature<br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">    # load your dataset</div><div style="font-size:12.8px">    ds = yt.load(...)</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">    ds.unit_registry.add('kB', 1.3806488e-16, dimensions=energy/temperature, tex_repr='k_{B}')</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><div style="font-size:12.8px">    def _entrdens(field,data):</div><span class="gmail-im"><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></span><div style="font-size:12.8px">         return data['ones']</div><div style="font-size:12.8px">    ds.add_field("Entropy",functio<wbr>n=_entrdens, units="kB", display_name="Entropy per Baryon")</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">    ad = ds.all_data()</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">    print ad['Entropy']</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 3:13 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"><span class=""><div>Dear Nathan,</div><div><br></div><div>Thanks very much for your help.</div></span><div>That was a stupid mistake and the error message is different with the previous one I said. </div><div>If I changed to kb, the error message is:</div><div><br></div><div><div>P014 yt : [ERROR    ] 2016-11-01 16:11:53,531 YTFieldUnitParseError: The field '('gas', 'Entropy')' has unparseable units 'kB'.</div><div>  File "volume_rendering.py", line 164, in <module></div><div>    plot_a_vr(fn,cycle,rotate=<wbr>False)</div><div>  File "volume_rendering.py", line 101, in plot_a_vr</div><div>    tfh.set_bounds()</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>visualization/volume_<wbr>rendering/transfer_function_<wbr>helper.py", line 66, in set_bounds</div><div>    bounds = self.ds.h.all_data().<wbr>quantities['Extrema'](self.<wbr>field, non_zero=True)</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/derived_<wbr>quantities.py", line 510, in __call__</div><div>    rv = super(Extrema, self).__call__(fields, non_zero)</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/derived_<wbr>quantities.py", line 67, in __call__</div><div>    sto.result = self.process_chunk(ds, *args, **kwargs)</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/derived_<wbr>quantities.py", line 518, in process_chunk</div><div>    fd = data[field]</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/data_containers.<wbr>py", line 272, in __getitem__</div><div>    self.get_data(f)</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/data_containers.<wbr>py", line 1192, in get_data</div><div>    self._generate_fields(fields_<wbr>to_generate)</div><div>  File "/Users/pan/anaconda2/lib/<wbr>python2.7/site-packages/yt/<wbr>data_objects/data_containers.<wbr>py", line 1245, in _generate_fields</div><div>    raise YTFieldUnitParseError(fi)</div><div>P015 yt : [ERROR    ] 2016-11-01 16:11:53,572 YTFieldUnitParseError: The field '('gas', 'Entropy')' has unparseable units 'kB'.</div><div>------------------------------<wbr>------------------------------<wbr>--------------</div></div><div><br></div><div>Many thanks,</div><div>Kuo-Chuan</div><div><div class="h5"><br><div><blockquote type="cite"><div>On Nov 1, 2016, at 4:03 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br class="m_-7242283318553275953Apple-interchange-newline"><div><div dir="ltr">At the top of your script, you have:<div><br></div><div>from yt.units import kb<br></div><div><br></div><div>but later you have:</div><div><br></div><div>return kB*entrdens<br></div><div><br></div><div>It should be:</div><div><br></div><div>return kb*entrdens<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 3:00 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>Thank you very much for your help.</div><div>I was using ds.add_field()</div><div><br></div><div>I have pasted my script and error message here:</div><div><a href="http://paste.yt-project.org/show/wToLggLnTYVpMxeqJtln/" target="_blank">http://paste.yt-project.org/sh<wbr>ow/wToLggLnTYVpMxeqJtln/</a></div><div><br></div><div>Many thanks,</div><div>Kuo-Chuan</div><div><div class="m_-7242283318553275953h5"><div><br></div><br><div><blockquote type="cite"><div>On Nov 1, 2016, at 3:50 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br class="m_-7242283318553275953m_-5907052106927155467Apple-interchange-newline"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><br class="m_-7242283318553275953m_-5907052106927155467Apple-interchange-newline"><br><div class="gmail_quote">On Tue, Nov 1, 2016 at 2:40 PM, Kuo-Chuan Pan<span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:pankuoch@msu.edu" target="_blank">pankuoch@msu.edu</a>></span><span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>wrote:<br><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">Dear Nathan,<div><br></div><div>Thanks very much for your email and suggestions.</div><div>I followed your suggested code but it is not working.</div><div>yt gives an error message:</div><div><span class="m_-7242283318553275953m_-5907052106927155467m_-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><br></div><div>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><br></div><div>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><br></div><div>We have<span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span><a href="http://paste.yt-project.org/" target="_blank">paste.yt-project.org</a><span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>set up for this purpose.</div><div><br></div><div>-Nathan</div><div> </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"><div><br></div><div>The vales of my “entr” field is already in “kB/baryon” (specific entropy) but the unit is incorrect.</div><div>Following your suggestions, I want to create two new units called “kB” and “baryon” (1.674e-24 g) </div><div>and override the “entr” and “Entropy” units to “kB/baryon” (from dimensionless). </div><div>Is it possible to do that?</div><div><br></div><div>Many thanks,</div><div>Kuo-Chuan</div><div><div class="m_-7242283318553275953m_-5907052106927155467h5"><div><br></div><div><br><div><blockquote type="cite"><div>On Nov 1, 2016, at 2:52 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br class="m_-7242283318553275953m_-5907052106927155467m_-6801954723337001028Apple-interchange-newline"><div><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" target="_blank">https://bitbucket.org/yt_analy<wbr>sis/yt/src/334cceb2c6e197acf1a<wbr>8c7f273ee9dd0bd592f58/yt/front<wbr>ends/flash/fields.py?at=yt&<wbr>fileviewer=file-view-default#<wbr>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>   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>from yt.units import kb</div><div>   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>from yt.units.dimensions import energy, temperature<br></div><div><br></div><div>   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span># load your dataset</div><div>   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>ds = yt.load(...)</div><div><br></div><div>   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>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">   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>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()/P<wbr>NS_DENSITY)**5))+PNS_ENTR</div><div style="font-size:12.8px">         return kb*entrdens</div><div style="font-size:12.8px">   <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>ds.add_field("Entropy",funct<wbr>ion=_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 class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:pankuoch@msu.edu" target="_blank">pankuoch@msu.edu</a>></span><span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>wrote:<br><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"><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> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>11 def _entrdens(field,data):</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>12     """</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>13     create a new derived field to show both entropy and density</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>14     """</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>15     dens = data["dens"]</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>16     entr = data["entr"]</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>17     entrdens = entr*(np.exp(-(dens.in_cgs()/P<wbr>NS_DENSITY)**5))+PNS_ENTR</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>18     return entrdens</div><div> <span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>19 yt.add_field("Entropy",functio<wbr>n=_entrdens,units="dimensionle<wbr>ss") </div><div><div class="m_-7242283318553275953m_-5907052106927155467m_-6801954723337001028h5"><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_-7242283318553275953m_-5907052106927155467m_-6801954723337001028m_-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 class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:pankuoch@msu.edu" target="_blank">pankuoch@msu.edu</a>></span><span class="m_-7242283318553275953m_-5907052106927155467Apple-converted-space"> </span>wrote:<br><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><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.o<wbr>rg</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/lis<wbr>tinfo.cgi/yt-users-spacepope.o<wbr>rg</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" 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>______________________________<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/lis<wbr>tinfo.cgi/yt-users-spacepope.o<wbr>rg</a><br></div></blockquote></div><br></div></div></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.o<wbr>rg</a><br><br></blockquote></div><br></div></div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">______________________________<wbr>_________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a></div></blockquote></div><br></div></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>
______________________________<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>