Comments (9)
At some point, I was advised to avoid instantiating fsps.StellarPopulation
more than once: the maintainers would be better equipped to answer precisely why, but I suspect it has to do with how these python bindings interface with the underlying fortran.
Try running your two code blocks as separate programs, write out the result for each, and compare them that way.
from python-fsps.
I have separated them but they still give different result
from python-fsps.
It's true that to be safe you want to have a single StellarPopulation object. But the issue here I think is more that the default SFH (used in your first sp
object) is a single age simple stellar population (sfh=0
). The tabular sp.sfr
value is not actually well-defined for such an SFH (since it is a delta function at age=0) and so the sfr
variable that you compute is filled with zeros and the resulting sfh=3
spectrum is garbage. I guess we could check for non-zero sfr inside set_tabular_sfh()
to warn users about this.
What I'd do instead is
import fsps
import matplotlib.pyplot as pl
sps = fsps.StellarPopulation()
# get the spectrum via the intrinsic SFH convolutions
sps.params["sfh"] = 4 #delayed_exponential
sdss_bands = fsps.find_filter("sdss")
mags = sps.get_mags(bands=sdss_bands)
age = (10 ** sps.log_age) / 1e9
sfr = sps.sfr
wavelength, spectrum = sps.get_spectrum(tage=13.7)
# get the spectrum from a tabular version
sps.params["sfh"] = 3
sps.set_tabular_sfh(age, sfr)
wavelength, spectrum1 = sps.get_spectrum(tage=13.7)
# Plot the SFR
fig, axes = pl.subplots(2, 1)
axes[0].plot(age, sfr, '-o')
axes[0].set_xlabel('Age (Gyr)')
axes[0].set_ylabel('SFR (M$_\odot$/yr')
axes[1].plot(wavelength, spectrum, label="via sfh=4")
axes[1].plot(wavelength, spectrum1, label="via sfh=3")
axes[1].set_xlim(1e3, 1e4)
axes[1].set_xlabel('$\lambda (\AA)$')
axes[1].set_ylabel('$f_\nu (L_\odot/Hz)$')
axes[1].legend(loc=0)
pl.show()
In fact you will probably still notice (smaller) differences. I'm pretty sure this is because for sfh=1, 4, or 5
all the calculations are done exactly, taking into the account the true exponential dependence of the SFR between ssp ages, whereas for sfh=3
the SFH is assumed to be piecewise linear between the provided tabular age points, which becomes a poor approximation to the true SFH as the age resolution decreases. But it could be good to do some more testing of that.
from python-fsps.
Thanks a lot for the answer!
from python-fsps.
Hi, I want to clarify that the value of age given by log_age is the age of universe or lookback time?
I made several model with single burst with different tstart and the later tstart (the bigger number) give smaller stellar mass.
So say if I want to specify the burst to start 3Gyr ago, should I put 11 or 3 in the tstart?
from python-fsps.
Is this with sfh=3
? I'm not sure how you'd do a burst that way. Also, by tstart do you mean the sf_start
parameter? Or the tburst
parameter? Both of those are only defined for sfh=1,4,5
from python-fsps.
for sfh=1, I change the tstart parameter
from python-fsps.
Yes, the times (sf_start
, tburst
, tage
, log_age
) are age of universe, not lookback time.
from python-fsps.
Just wanted to add a note here that the difference between the spectra obtained via SFH=3 and SFH=4 for delay-tau that I mentioned earlier in the thread was actually caused largely by an FSPS bug in tabular SFH calculations, now fixed by cconroy20/fsps#32
Remaining differences are much less than a percent for lambda > 1300 AA, and less than 5 percent blueward of that.
from python-fsps.
Related Issues (20)
- Tests are extremely slow on Windows
- Segmentation fault when importing fsps HOT 13
- Adding New Filters Documentation
- wrong installation? HOT 10
- Odd behavior with optical emission lines HOT 4
- Re-enable Windows wheel builds HOT 1
- Emission line extinction mechanism HOT 1
- Emission lines from post-AGB UV radiation
- I cannot install python-fsps HOT 2
- changing the emission line velocity width HOT 8
- Make cloudy_dust a setup variable
- issue of installing&Changing libraries HOT 7
- Not able to change isochrone on Mac M1 HOT 1
- SPS_SETUP ERROR: wavelength grid cannot be opened HOT 4
- Installation on Windows 11 Issue: "Invalid Escape Character" with pip Install HOT 1
- Error in SPS_SETUP HOT 4
- Build doesn't work on Windows HOT 1
- Clarification about SSP vs CSP generation HOT 2
- Question on AGN HOT 1
- Dead Kernel Upon sp = fsps.StellarPopulation(....)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-fsps.