<div dir="ltr">Hi,<div><br></div><div>I've issued a pull request to yt_analysis, the change diverting from the norm for yt to output in proper units, but as Greg pointed out in the case of star formation rate density everyone uses comoving Mpc, so I think the change will be useful.  The original quantity doesn't make much sense, it was dividing Msol/yr at all redshifts by the proper volume at the last redshift.</div>
<div><br></div><div>The script should show identical curves offset by a tiny bit.</div><div><br></div><div>From</div><div>G.S.</div><div><br></div><div>#------------</div><div><div>from yt.mods import *</div><div>from yt.analysis_modules.star_analysis.api import *</div>
<div>import pylab</div><div><br></div><div>pf=load('HD1200/HD1200')</div><div>dd=pf.h.all_data()</div><div>sfr = StarFormationRate(pf, data_source=dd, bins=10)</div><div>sfr.write_out(name="StarFormationRate.out")</div>
<div>time, lookback, z, Msolyr, MsolyrMpc3, Msol, cumMsol=na.loadtxt('StarFormationRate.out',usecols=(0,1,2,3,4,5,6),skiprows=2,unpack=True)</div><div><br></div><div>cMpc3,=pylab.plot(z,Msolyr/(pf['CosmologyComovingBoxSize']/pf['CosmologyHubbleConstantNow'])**3)</div>
<div>New,=pylab.plot(z,MsolyrMpc3+3e-5)</div><div><br></div><div>pylab.legend([cMpc3,NewMpc3],</div><div>             ['[s$^{-1}$cMpc$^{-3}$]',</div><div>              'New'])</div><div><br></div><div>pylab.savefig('SFRD.eps')</div>
</div><div>#------------</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 9:36 AM, Geoffrey So <span dir="ltr"><<a href="mailto:gsiisg@gmail.com" target="_blank">gsiisg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi Greg,</div><div><br></div><div>My original script has them converted from proper to comoving and that's when I noticed the bug :)</div>
<div><br></div><div>Nathan,</div><div><br></div><div>I was trying to convey the idea, wasn't sure if what I described is the proper fix, I'll issue the PR if it tests out correctly.</div><div><br></div><div>From</div>
<div>G.S.<br><br>Sent from my iPhone</div><div><div class="h5"><div><br>On Apr 4, 2014, at 6:15 AM, Greg Bryan <<a href="mailto:gbryan@astro.columbia.edu" target="_blank">gbryan@astro.columbia.edu</a>> wrote:<br><br>
</div><blockquote type="cite"><div><div>Yes, although the star formation rate in cosmology is usually calculated in a comoving volume, not proper (see, e.g., <a href="http://arxiv.org/pdf/1403.0007v2.pdf" target="_blank">http://arxiv.org/pdf/1403.0007v2.pdf</a>).</div>
<div><br></div><div>Greg</div><br><div><div>On Apr 3, 2014, at 11:15 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:</div><br><blockquote type="cite"><div dir="ltr">
Hi Geoffrey,<div><br></div><div>I'm not very familiar with the star formation rate calculator, but if you think there is a bug I'd encourage you to submit a pull request with a fix.</div><div><br></div>

<div>-Nathan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 3, 2014 at 6:37 PM, Geoffrey So <span dir="ltr"><<a href="mailto:gsiisg@gmail.com" target="_blank">gsiisg@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There seems to be a bug in the star formation rate density calculation routine.  The volume is only the real 'proper volume' at the current redshift and not at any other redshifts, because it uses the current redshift in the calculation of proper volume in all redshifts.<div>



<br></div><div>#---------------------------------</div><div><div>from yt.mods import *</div><div>from yt.analysis_modules.star_analysis.api import *</div><div>import pylab</div><div><br></div><div>pf=load('HD1200/HD1200')</div>



<div>dd=pf.h.all_data()</div><div>sfr = StarFormationRate(pf, data_source=dd, bins=10)</div><div>sfr.write_out(name="StarFormationRate.out")</div><div>time, lookback, z, Msolyr, MsolyrMpc3, Msol, cumMsol=na.loadtxt('StarFormationRate.out',usecols=(0,1,2,3,4,5,6),skiprows=2,unpack=True)</div>



<div><br></div><div>cMpc3,=pylab.plot(z,Msolyr/(pf['CosmologyComovingBoxSize']/pf['CosmologyHubbleConstantNow'])**3)</div><div>currentz,=pylab.plot(z,MsolyrMpc3/(1+pf.current_redshift)**3+1e-5)</div><div>


Expect,=pylab.plot(z,MsolyrMpc3/(1+z)**3)</div>
<div><br></div><div>pylab.legend([cMpc3,currentz,Expect],</div><div>             ['[s$^{-1}$cMpc$^{-3}$]',</div><div>              'use only current z to fit',</div><div>              'Expected to fit'])</div>



<div><br></div><div>pylab.savefig('SFRD.eps')</div></div><div>#---------------------------------</div><div><br></div><div><br></div><div>in the file:</div><div>yt/analysis_modules/star_analysis/sfr_spectrum.py<br>



<div>line 151:</div><div><div>            self.Msol_yr_vol.append(self.mass_bins[i] / \</div><div>                (self.time_bins_dt[i] * tc / YEAR) / vol)</div></div></div><div><br></div><div>The vol is a fixed number instead of varying by the redshift, even though the numerator in solar masses per year is from different redshifts.</div>



<div><br></div><div>So I think a couple lines above it should create an empty array of vol</div><div>vol = []</div><div>In the loop</div><div>for i, time…</div><div>calculate the right volume vol[i]</div><div>Then instead of dividing by the constant vol, divide by vol[i] corresponding to the right redshift.</div>



<div><div>            self.Msol_yr_vol.append(self.mass_bins[i] / \</div><div>                (self.time_bins_dt[i] * tc / YEAR) / vol[i])</div></div><div><br></div><div>From</div><span><font color="#888888"><div>

G.S.</div><div><br></div><div><br></div>
</font></span></div>
<br>_______________________________________________<br>
yt-dev mailing list<br>
<a href="mailto:yt-dev@lists.spacepope.org" target="_blank">yt-dev@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>yt-dev mailing list<br><a href="mailto:yt-dev@lists.spacepope.org" target="_blank">yt-dev@lists.spacepope.org</a><br><a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a><br>
</blockquote></div><br><div>
<span style="border-collapse:separate;border-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;font-size:12px;white-space:normal;font-family:Helvetica;word-spacing:0px"><div style="word-wrap:break-word">
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">----------------------------------</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Greg Bryan</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
Associate Professor of Astronomy</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Department of Astronomy, Columbia University</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
1325 Pupin Physics Laboratories, Mail Code 5246</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">550 West 120th Street</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
New York, New York 10027 (USA)</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 12px/normal Helvetica;min-height:14px"><br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
email: <a href="mailto:gbryan@astro.columbia.edu" target="_blank">gbryan@astro.columbia.edu</a></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">phone: <a href="tel:%2B1%28212%29854-6837" value="+12128546837" target="_blank">+1(212)854-6837</a></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">fax  : <a href="tel:%2B1%28212%29854-8121" value="+12128548121" target="_blank">+1(212)854-8121</a></div><div><br></div><div><br></div></div><br>
</span></span><br>
</div>
<br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>yt-dev mailing list</span><br><span><a href="mailto:yt-dev@lists.spacepope.org" target="_blank">yt-dev@lists.spacepope.org</a></span><br>
<span><a href="http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org</a></span><br></div></blockquote></div></div></div></blockquote></div>
<br></div>