Thanks for your help. I have submitted a new issue about the documentation problem as you suggested. I have used the other example to produce a plot, but I’m not sure if the particles are being filtered correctly. I am using Enzo simulation data. I think I want to select all particles that are stars, and then only keep those that have a creation time greater than 0; I am unsure how to do this. Is it possible to combine two conditions within the filter definition? Many thanks, Ashley
On 12 Sep 2017, at 21:57, nathan12343@gmail.com wrote:
Hi Ashley,
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.
I think what's happening here is that you are dealing with a non-cosmological simulation which does not have Mpccm defined.
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 https://github.com/yt-project/yt/issues/new https://github.com/yt-project/yt/issues/new) that will help us to avoid losing track of this deficiency.
Rather than using the StarFormationRate class, I'd suggest looking at this example in the cookbook section of the docs:
http://yt-project.org/doc/cookbook/calculating_information.html#using-partic... http://yt-project.org/doc/cookbook/calculating_information.html#using-partic...
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.
Hope that helps,
Nathan
On Tue, Sep 12, 2017 at 3:23 PM Stephanie Tonnesen
mailto:stonnes@gmail.com> wrote: I am not sure, but the first thing I would do would be to add from yt.units import Mpccm
At the top and see what happens next.
Best, Stephanie
On Tue, Sep 12, 2017 at 11:36 AM Ashley Jarvis
mailto:ajarvis@star.sr.bham.ac.uk> wrote: Hi all, I’m attempting to adapt the example script for plotting star formation rates (found at http://yt-project.org/doc/analyzing/analysis_modules/star_analysis.html#star... http://yt-project.org/doc/analyzing/analysis_modules/star_analysis.html#star...) to work with output data from a simulation run using Enzo. However, when I attempt to run the script, I get the following error:
———————————————————
File "PlotSFR.py", line 26, in <module> sfr = StarFormationRate(data, star_mass=mass_old, star_creation_time=ct_old, volume=sp.volume()) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/analysis_modules/star_analysis/sfr_spectrum.py", line 115, in __init__ self._ds.quan(1.0, 'Mpccm**3').units File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/yt_array.py", line 1355, in __new__ dtype=dtype, bypass_validation=bypass_validation) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/yt_array.py", line 430, in __new__ units = Unit(input_units, registry=registry) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/unit_object.py", line 257, in __new__ unit_data = _get_unit_data_from_expr(unit_expr, registry.lut) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/unit_object.py", line 572, in _get_unit_data_from_expr unit_data = _get_unit_data_from_expr(unit_expr.args[0], unit_symbol_lut) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/unit_object.py", line 566, in _get_unit_data_from_expr return _lookup_unit_symbol(str(unit_expr), unit_symbol_lut) File "/usr/local/anaconda/lib/python2.7/site-packages/yt/units/unit_object.py", line 657, in _lookup_unit_symbol "symbols." % symbol_str) yt.units.unit_registry.UnitParseError: Could not find unit symbol 'Mpccm' in the provided symbols.
———————————————————
I am using version 3.3.5 of yt.
Does anyone know how I can resolve this? Any suggestions would be greatly appreciated.
Thanks, Ashley
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org mailto:yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org -- -- Dr. Stephanie Tonnesen Alvin E. Nashman Postdoctoral Fellow Carnegie Observatories, Pasadena, CA stonnes@gmail.com mailto:stonnes@gmail.com _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org mailto:yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org