<div dir="ltr"><div dir="auto">Hi Ashley,</div><div dir="auto"><br></div><div dir="auto">Unfortunately Stephanie's suggestion won't work, since units like Mpccm, which depend on details of the dataset, aren't available in yt.units. In particular the conversion from comoving megaparsecs to physical units depends on redshift and assumed cosmology.</div><div dir="auto"><br></div><div dir="auto">I think what's happening here is that you are dealing with a non-cosmological simulation which does not have Mpccm defined.</div><div dir="auto"><br></div><div>It looks like yt's StarFormationRate class that you're trying to use assumes that it's being passed an output from a cosmological simulation and is failing in a less than graceful fashion when you try pass a non-cosmological output. We should probably emphasize more in the documentation that StarFormationRate only accepts a cosmological output (or improve it so that it *can* work with non-cosmological outputs) and improve the error message you saw. If you'd like to file an issue about this documentation problem (at <a href="https://github.com/yt-project/yt/issues/new">https://github.com/yt-project/yt/issues/new</a>) that will help us to avoid losing track of this deficiency.</div><div><br></div><div>Rather than using the StarFormationRate class, I'd suggest looking at this example in the cookbook section of the docs:</div><div><br></div><div><a href="http://yt-project.org/doc/cookbook/calculating_information.html#using-particle-filters-to-calculate-star-formation-rates" target="_blank">http://yt-project.org/doc/<wbr>cookbook/calculating_<wbr>information.html#using-<wbr>particle-filters-to-calculate-<wbr>star-formation-rates</a><br></div><div><br></div><div>To adapt that example for your data, you're going to need to figure out how to select the star particles in your simulation and then either adapt the particle filter definition in the example for your data, or if you are using a frontend like Gadget where the output format defines a star particle type, just use that instead of the particle filter. The rest of the cookbook recipe just uses numpy to bin the star particle ages according to the formation time of the particle, and then backs out the star formation rate history.</div><div><br></div><div>Hope that helps,</div><div><br></div><div>Nathan</div><div dir="auto"><br></div><div class="gmail_quote"><div>On Tue, Sep 12, 2017 at 3:23 PM Stephanie Tonnesen <<a href="mailto:stonnes@gmail.com" target="_blank">stonnes@gmail.com</a>> wrote:<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><div dir="auto">I am not sure, but the first thing I would do would be to add</div><div dir="auto"><br></div><div dir="auto">from yt.units import Mpccm </div><div dir="auto"><br></div><div dir="auto">At the top and see what happens next. </div><div dir="auto"><br></div><div dir="auto">Best,</div><div dir="auto">Stephanie </div></div><div><br><div class="gmail_quote"><div>On Tue, Sep 12, 2017 at 11:36 AM Ashley Jarvis <<a href="mailto:ajarvis@star.sr.bham.ac.uk" target="_blank">ajarvis@star.sr.bham.ac.uk</a>> wrote:<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 style="word-wrap:break-word">Hi all,<div><br></div><div>I’m attempting to adapt the example script for plotting star formation rates (found at <a href="http://yt-project.org/doc/analyzing/analysis_modules/star_analysis.html#star-formation-rate" target="_blank">http://yt-project.org/doc/a<wbr>nalyzing/analysis_modules/star<wbr>_analysis.html#star-formation-<wbr>rate</a>) to work with output data from a simulation run using Enzo. However, when I attempt to run the script, I get the following error:</div><div><br></div><div>———————————————————</div><div><br></div><div>File "PlotSFR.py", line 26, in <module><br>    sfr = StarFormationRate(data, star_mass=mass_old, star_creation_time=ct_old, volume=sp.volume())<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/analysis<wbr>_modules/star_analysis/sfr_<wbr>spectrum.py", line 115, in __init__<br>    self._ds.quan(1.0, 'Mpccm**3').units<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>yt_array.py", line 1355, in __new__<br>    dtype=dtype, bypass_validation=bypass_valid<wbr>ation)<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>yt_array.py", line 430, in __new__<br>    units = Unit(input_units, registry=registry)<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>unit_object.py", line 257, in __new__<br>    unit_data = _get_unit_data_from_expr(unit_<wbr>expr, registry.lut)<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>unit_object.py", line 572, in _get_unit_data_from_expr<br>    unit_data = _get_unit_data_from_expr(unit_<wbr>expr.args[0], unit_symbol_lut)<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>unit_object.py", line 566, in _get_unit_data_from_expr<br>    return _lookup_unit_symbol(str(unit_e<wbr>xpr), unit_symbol_lut)<br>  File "/usr/local/anaconda/lib/pytho<wbr>n2.7/site-packages/yt/units/<wbr>unit_object.py", line 657, in _lookup_unit_symbol<br>    "symbols." % symbol_str)<br>yt.units.unit_registry.UnitPar<wbr>seError: Could not find unit symbol 'Mpccm' in the provided symbols.</div><div><br></div><div>———————————————————</div><div><br></div><div>I am using version 3.3.5 of yt.</div><div><br></div><div>Does anyone know how I can resolve this? Any suggestions would be greatly appreciated.</div><div><br></div><div>Thanks,</div><div>Ashley</div><div><br></div><div><br></div><div><br></div></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" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
</blockquote></div></div><div>-- <br></div><div><div><div><div><div><font face="garamond,serif">--<br>Dr. Stephanie Tonnesen<br></font></div><font face="garamond,serif">Alvin E. Nashman Postdoctoral Fellow<br></font></div><font face="garamond,serif">Carnegie Observatories, Pasadena, CA<br></font></div><font face="garamond,serif"><a href="mailto:stonnes@gmail.com" target="_blank">stonnes@gmail.com</a><br></font></div></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" rel="noreferrer" target="_blank">http://lists.spacepope.org/lis<wbr>tinfo.cgi/yt-users-spacepope.<wbr>org</a><br>
</blockquote></div></div>