[yt-users] Plotting SFRs

Nathan Goldbaum nathan12343 at gmail.com
Thu Oct 5 07:43:50 PDT 2017


Hi Ashley,

That depends on the star formation rate prescription you are using. The
formula in the cookbook recipe calculates the star formation rate based on
the masses of particles that formed over a small time period in the past.
The star formation rate calculated by the recipe in a given time bin is the
initial masses of star particles that formed in that bin divided by the
width of the time bin. In the limit where the width of the time bin goes to
zero, the instantaneous star formation rate and the star formation rate you
measure through this method should agree.

If your star particles participate in a feedback algorithm and lose mass or
change mass for any other reason, that would impact the star formation
rates one would measure with this algorithm. In this case, one should use
the original mass of the star particles, which would need to be recorded
somehow if the masses of newly formed star particles aren't known a priori.

A good check to make sure you're getting the right answer is to compute the
instantaneous star formation rate in a snapshot early in the simulation and
compare it with the star formation rate you measured at the time of that
snapshot based on the star particles present in the *final* snapshot.
Assuming that you are forming lots of star particles in a given time bin
and that your star formation algorithm is stochastic, these numbers should
match closely although you will likely not get perfect agreement.

For example, see Figure 1 of my 2015 paper (
http://adsabs.harvard.edu/abs/2015ApJ...814..131G). The code used to
generate the figure is available in these two notebooks:

http://nbviewer.jupyter.org/urls/bitbucket.org/ngoldbaum/galaxy_analysis/raw/db50e8f3ae7ea78ba215d5ce1295085c5305f86e/helper_scripts/sfr.ipynb
http://nbviewer.jupyter.org/urls/bitbucket.org/ngoldbaum/galaxy_analysis/raw/db50e8f3ae7ea78ba215d5ce1295085c5305f86e/helper_scripts/sfr_figure.ipynb

Note that this paper did not include the effects of feedback, so there
isn't any attempt to correct for the fact that the masses of star
particles. However, for my 2016 paper I did account for that effect and
just used the fixed 300 solar masses each new star particle in my
simulation is created with. See Figure 3 of my 2016 paper (
http://adsabs.harvard.edu/abs/2016ApJ...827...28G) and this notebook:

http://nbviewer.jupyter.org/urls/bitbucket.org/ngoldbaum/galaxy_analysis/raw/db50e8f3ae7ea78ba215d5ce1295085c5305f86e/helper_scripts/star_formation_plot.ipynb

Hope that's helpful,

Nathan

On Thu, Oct 5, 2017 at 9:13 AM, <ajarvis at star.sr.bham.ac.uk> wrote:

> Hi Nathan,
>
> I managed to implement the filter definition that you provided, but I have
> come across another problem. When I try to generate the SFR plots for the
> simulation at different time steps, there is always a sharp decline in the
> rate around 25Myr before the output time of the data dump (see attached
> plots).
>
> Is this happening because of something in the simulation itself, e.g.
> there is a delay between the region reaching a given density limit and the
> star particle actually being created (to represent the formation time of
> the stars), or is it being caused by something in the yt plotting process?
>
> Many thanks,
> Ashley
>
>
> https://i.imgur.com/mjCQvZy.png
> https://i.imgur.com/Cv5D1HK.png
> https://i.imgur.com/6ZA2xgq.png
>
>
>
> > On Wed, Sep 13, 2017 at 7:58 AM, Ashley Jarvis
> > <ajarvis at star.sr.bham.ac.uk>
> > wrote:
> >
> >> 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?
> >>
> >
> > Yup, you can combine boolean arrays using boolean operators in Numpy. For
> > your problem it would look like this:
> >
> >     def formed_star(pfilter, data):
> >         # identify stars (particle_type 2) that have creation times after
> > the beginning
> >         # of the simulation
> >         filter = (data["all", "creation_time"] > 0) & (data['all',
> > 'particle_type'] == 2)
> >         return filter
> >
> > -Nathan
> >
> >
> >> Many thanks,
> >> Ashley
> >>
> >>
> >>
> >> On 12 Sep 2017, at 21:57, nathan12343 at 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)
> >> 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-particle-filters-to-calculate-star-formation-rates
> >>
> >> 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 <stonnes at 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 <
> >>> ajarvis at 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/a
> >>>> nalyzing/analysis_modules/star_analysis.html#star-formation-rate) 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 at lists.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 at gmail.com
> >>> _______________________________________________
> >>> yt-users mailing list
> >>> yt-users at lists.spacepope.org
> >>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >>>
> >> _______________________________________________
> >> yt-users mailing list
> >> yt-users at lists.spacepope.org
> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >>
> >>
> >>
> >> _______________________________________________
> >> yt-users mailing list
> >> yt-users at lists.spacepope.org
> >> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >>
> >>
> > _______________________________________________
> > yt-users mailing list
> > yt-users at lists.spacepope.org
> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20171005/62438cdd/attachment-0001.html>


More information about the yt-users mailing list