コード例 #1
0
ファイル: imf_figure.py プロジェクト: adeleplunkett/imf
from imf import coolplot,kroupa,make_cluster
import numpy as np


if __name__ == "__main__":
    import pylab as pl
    pl.matplotlib.style.use('classic')

    pl.rc('font',size=30)
    pl.figure(1, figsize=(20,16))
    pl.clf()
    cluster,yax,colors = coolplot(1000, massfunc=kroupa)
    pl.scatter(cluster, yax, c=colors, s=np.log10(cluster+3)*85)
    pl.gca().set_xscale('log')

    masses = np.logspace(np.log10(cluster.min()), np.log10(cluster.max()),10000)

    pl.plot(masses,np.log10(kroupa(masses)),'r--',linewidth=2,alpha=0.5)
    pl.xlabel("Stellar Mass")
    pl.ylabel("log(dN(M)/dM)")
    pl.gca().axis([min(cluster)/1.1,max(cluster)*1.1,min(yax)-0.2,max(yax)+0.5])
    pl.savefig("plots/imf.png",bbox_inches='tight')

    #figure(2)
    #clf()
    #def cloud_massfunc(mass,m0=1e3,alpha=1.1):
    #    return (mass/m0)**-alpha

    #clouds = make_cluster(1e8, massfunc=cloud_massfunc)
コード例 #2
0
    pl.matplotlib.style.use('classic')
    pl.rc('font',size=30)
    pl.close(1)

    # make three figures of dN/dM vs M, one for each mass function,
    # then do it again in log-scale
    for massfunc in (imf.kroupa, imf.chabrier2005, imf.salpeter):

        # this is not a recommended way to get object names, don't do it in general.
        # (not all classes are guaranteed to have names; I know they do in this
        # case because I made and initialized the classes)
        name = massfunc.__class__.__name__

        pl.figure(1, figsize=(10,8))
        pl.clf()
        cluster,yax,colors = coolplot(1000, massfunc=massfunc)
        pl.scatter(cluster, yax, c=colors, s=np.log10(cluster+3)*85,
                   linewidths=0.5, edgecolors=(0,0,0,0.25), alpha=0.95)
        pl.gca().set_xscale('log')

        masses = np.logspace(np.log10(cluster.min()), np.log10(cluster.max()),10000)

        pl.plot(masses,np.log10(massfunc(masses)),'r--',linewidth=2,alpha=0.5)
        pl.xlabel("Stellar Mass")
        pl.ylabel("log(dN(M)/dM)")
        pl.gca().axis([min(cluster)/1.1,max(cluster)*1.1,min(yax)-0.2,max(yax)+0.5])
        pl.savefig("{0}_imf_figure_log.png".format(name),bbox_inches='tight', dpi=150)
        pl.savefig("{0}_imf_figure_log.pdf".format(name),bbox_inches='tight')

        pl.figure(2, figsize=(20,16))
        pl.clf()
コード例 #3
0
ファイル: imf_figure.py プロジェクト: acviana/agpy
from imf import coolplot,kroupa,make_cluster
import numpy as np


if __name__ == "__main__":
    import pylab as pl
    pl.rc('font',size=30)
    pl.figure(1)
    pl.clf()
    cluster,yax,colors = coolplot(1000, massfunc=kroupa)
    pl.scatter(cluster, yax, c=colors, s=np.log10(cluster+3)*85)
    pl.gca().set_xscale('log')

    masses = np.logspace(np.log10(cluster.min()), np.log10(cluster.max()),10000)

    pl.plot(masses,np.log10(kroupa(masses)),'r--',linewidth=2,alpha=0.5)
    pl.xlabel("Stellar Mass")
    pl.ylabel("log(dN(M)/dM)")
    pl.gca().axis([min(cluster)/1.1,max(cluster)*1.1,min(yax)-0.2,max(yax)+0.5])
    pl.savefig("plots/imf.png",bbox_inches='tight')

    #figure(2)
    #clf()
    #def cloud_massfunc(mass,m0=1e3,alpha=1.1):
    #    return (mass/m0)**-alpha

    #clouds = make_cluster(1e8, massfunc=cloud_massfunc)