; Computes the number and mass fraction of stars in the IMF ; above a given mass threshold ; Christoph Federrath, 2018 pro makeit, TYPE=type, MASSTHRESH=massthresh ; set default mass threshold to 10 solar masses if not keyword_set(massthresh) then massthresh = 10d0 ; call IMF to get the IMF (based on Chabrier 2005) if not keyword_set(type) then type='chabrier2005single' imf_obs, TYPE=type, MASSES=masses, IMF=imf, CMF=cmf, NBINS=100 ; plot the IMF plot, masses, imf, /xlog, /ylog, chars=2, xtit='Mass (Solar Masses)', ytit='Relative Number', $ xtickformat='tickformat_exponential', ytickformat='tickformat_exponential', psym=10, yrange=[1d-5,10] ; compute fraction of massive stars above 10 solar masses index_above_threshold = where(masses ge massthresh) number_fraction_above_threshold = 1d0 - cmf[index_above_threshold[0]] print, 'Number fraction of stars above '+string(massthresh,format='(F6.2)')+' solar masses = '+$ string(number_fraction_above_threshold*100, format='(F6.2)')+'%' ; compute mass fraction cumulative_mass_fraction = dblarr(n_elements(masses)) for i = 0, n_elements(masses)-2 do begin dm = masses[i+1]-masses[i] imf_val = (imf[i+1]+imf[i])/2d0 cumulative_mass_fraction[i+1] += cumulative_mass_fraction[i] + imf_val*dm endfor ; normalise cumulative_mass_fraction /= cumulative_mass_fraction[n_elements(masses)-1] ; print out mass_fraction_above_threshold = 1d0 - cumulative_mass_fraction[index_above_threshold[0]] print, 'Mass fraction of stars above '+string(massthresh,format='(F6.2)')+' solar masses = '+$ string(mass_fraction_above_threshold*100, format='(F6.1)')+'%' stop end