dfm / python-fsps

Python bindings to Charlie Conroy's Flexible Stellar Population Synthesis (FSPS) Fortran code
https://python-fsps.readthedocs.io
MIT License
65 stars 38 forks source link

Function "Isochrones" in FSPS Python Library #95

Closed Nadezda68 closed 3 years ago

Nadezda68 commented 6 years ago

Hello, I need to work with output data from isochrones function in FSPS library. I tried to find any kind of documentation about units and names of output data which are presented as a huge Numpy array. My code is right down and my question is Where I can find information in details about these quantities and their units, some of them I know just because of their simple names but don't know about units? Or maybe it is just widespread denotations which I am not faced with before.

sp = fsps.StellarPopulation(compute_vega_mags=False, zcontinuous=1, sfh=0, logzsol=0.0, zred=0.725, dust_type=2, dust2=0.2)
iso = sp.isochrones()
print(iso)

Output: array with numbers........ [('age', '<f8'), ('log(Z)', '<f8'), ('mini', '<f8'), ('mact', '<f8'), ('logl', '<f8'), ('logt', '<f8'), ('logg', '<f8'), ('phase', '<f8'), ('composition', '<f8'), ('log(weight)', '<f8'), ('log(mdot)', '<f8'), ('v', '<f8'), ('u', '<f8'), ('b', '<f8'), and other filters.]

And a supplement question. Why for different age in this array I get different scale (numbers and their amount) of log(weight)? If I want to plot the dependence of the flux on age for defined mass it will be not convenient because you need sorting your data before. Am I misunderstanding how it works?

Thanks, Nadezda.

bd-j commented 6 years ago

Hi @NadyaYuil

The isochrones method was more of an internally used method, which is why it has little documentation. I haven't used it in awhile and I'm not actually sure of all the units! Briefly:

log(weight) depends on mini but also on the spacing between mini at a given age, which might change as a function of age. So you'll need a wide enough mass bin that these spacing changes don't affect you. Anyway for what you want to do it might be cleaner to do something like in https://github.com/dfm/python-fsps/blob/master/demos/specbymass.py

Nadezda68 commented 6 years ago

Good evening @bd-j ,

Thank you for your code, I saw it in details. Sorry for such late reply. I still exploring FSPS library, and I have another question.

When I create stellar population I want to get apparent magnitudes on different ages. What I get in output are values in the range from -1 to 7. It is extremely strange because these values are too high for the object with such redshift. Firstly, I thought that I got an absolute magnitude and calculate the distance modulus, but for my redshift its higher than 44. Hubble has a limit which around 34, so we cannot see such objects. I do it because further, I want to fit what I get from FSPS and real data from Hubble to derive the age of the stellar population in each of pixels for a galaxy. I really don't understand why magnitude are in such diapason? Can you please show me where I am wrong?

My code is down below:

sp = fsps.StellarPopulation(compute_vega_mags=False, zcontinuous=1, sfh=0, logzsol=-2, zred=4, dust_type=2, dust2=0.2)
bands = ['wfc_acs_f775w', 'wfc_acs_f850lp', 'wfc3_ir_f105w', 'wfc3_ir_f125w', 'wfc3_ir_f160w', 'irac_1', 'irac_2'] 

tage_list = np.logspace(-3,1,10)
flux = []

for i in range(len(tage_list)):
    flux.append(sp.get_mags(tage=tage_list[i], bands=bands))
flux=np.array(flux)
print(flux)

Output: array([[ 2.16753685, 2.39231437, 2.29188752, 2.16855974, 2.25384184, -0.77475411, 0.28833493], ........... [ 5.6093259 , 5.4865683 , 5.40710877, 5.35279918, 5.29673453, 6.43984946, 6.98246526]])

# Real data from Hubble:
i775 =  28.88,  z850 =  26.54,  Y105 =  26.18,   J125 =  26.16,  H160W = 26.20,  IRAC1 = 25.62, IRAC2 = 26.45

Thank you!

bd-j commented 6 years ago

Hi @NadyaYuil,

Two things.

  1. The spectra, magnitudes, and other quantities returnd by sp methods are for 1 solar mass formed (unless using tabular SFH, sfh=3) while the surviving stellar mass is indicated by the sp.stellar_mass attribute (this always a little less than 1.0 due to some stars dying, again unless sfh=3.) So if your object has a stellar mass of mstar then you will need to add -2.5*np.log10( mstar/sp.stellar_mass)
  1. When I run the code above I get magnitudes >45, i.e. including distance modulus (which would then give magnitudes similar to the real data for masses ~1e10 solar mass.) You might have an old version of python-fsps. Did you install with pip or following the instructions at http://dfm.io/python-fsps/current/installation/#installing-development-version ? If the former, please try pip uninstall fsps and then following the instructions for installing the development version.

Also I note that some of the ages in your list don't make sense for zred=4, when the universe was only ~1.5 Gyr old.

bd-j commented 3 years ago

units are now listed for the output isochrones() method, closing.