コード例 #1
0
ファイル: tau_indecies.py プロジェクト: eigenbrot/snakes
def make_galaxies(tausf_list = deftlst, ma11 = False, vdisp=200.0):

    if ma11:
        fraclist = ma11_fraclist
        modellist = ['/d/monk/eigenbrot/WIYN/14B-0456/anal/MA11_models/ma11_cha_{}.fits'.format(i) for i in ['0005Z','005Z','05Z','1Z','2Z']]
    else:
        fraclist = bc03_fraclist
        modellist = ['/d/monk/eigenbrot/WIYN/14B-0456/anal/models/bc03_{}_ChabIMF.fits'.format(i) for i in ['solarZ','004Z','0004Z','0001Z','008Z','05Z']]
    
    for z in range(len(modellist)):
        #get the length of the wavelength vector
        tmp = tm.make_galaxy('tmp',SSPs=modellist[z],makeplot=False,writeoutput=False)
        nwave = tmp['wave'].size
        output = np.zeros((len(tausf_list), nwave))
        outhdu = pyfits.PrimaryHDU()
        for i, t in enumerate(tausf_list):
            if ma11:
                galname = 'ma11_gal_t{}'.format(t)
            else:
                galname = 'bc03_gal_t{}'.format(t)
            gal = tm.make_galaxy(galname,tau_sf = t,
                                 SSPs=modellist[z],makeplot=False,
                                 writeoutput=False,vdisp=vdisp)
            output[i,:] = gal['flux']/np.mean(gal['flux'])
            outhdu.header.update('TSF{:02n}'.format(i+1),t)

        outhdu.data = output
        outhdu.header.update('Z',fraclist[z])
        outhdu.header.update('CTYPE1','LINEAR')
        outhdu.header.update('CRPIX1',1)
        outhdu.header.update('CRVAL1',gal['wave'].min())
        outhdu.header.update('CDELT1',np.mean(np.diff(gal['wave'])))
        outhdu.header.update('CTYPE2','LINEAR')
        outhdu.header.update('CRPIX2',1)
        outhdu.header.update('CRVAL2',len(tausf_list))
        outhdu.header.update('CDELT2',1)
        if ma11:
            outhdu.writeto('MA11_Z{:04n}_tau.fits'.format(fraclist[z]*1000),clobber=True)
        else:
            outhdu.writeto('BC03_Z{:04n}_tau.fits'.format(fraclist[z]*1000),clobber=True)
        
    return
コード例 #2
0
ファイル: SN_tests.py プロジェクト: eigenbrot/snakes
def make_monte(taulist = [0.1,1,2,4,10], SNlist = [5,10,20,40,60],
               N = 10, SNmin = 5450., SNmax = 5550., lightmin = 5450., lightmax = 5550.):
    
    # modellist = ['/d/monk/eigenbrot/WIYN/14B-0456/anal/models/bc03_{}_ChabIMF.fits'.format(i) for i in ['solarZ','004Z','0004Z','0001Z','008Z','05Z']]
    DFK_model = '/d/monk/eigenbrot/WIYN/14B-0456/anal/DFK/models/DFK_allZ_vardisp.fits'
    fraclist = np.array([1,0.2,0.02,0.005,0.4,2.5])
    ssp = '/d/monk/eigenbrot/WIYN/14B-0456/anal/models/bc03_008Z_ChabIMF.fits'
    if type(N) is not list:
        N = [N]
    for SN in SNlist:
        direc = 'SN{}'.format(SN)
        if not os.path.exists(direc):
            os.makedirs(direc)
        filename = '{}/run.pro'.format(direc)
        if os.path.exists(filename):
            n=2
            filename = '{}_{}.pro'.format(filename.split('.pro')[0],n)
            while os.path.exists(filename):
                n += 1
                filename = '{}_{}.pro'.format(filename.split('_')[0],n)

        f = open(filename,'w')
        for tau in taulist:
            for i in range(*N):
                name = '{}/SN{:02}_t{:03}_N{:03}'.format(direc,SN,tau,i+1)
                print name
                if i == N[0] - 1:
                    tm.make_galaxy(name,SSPs=ssp,SN=SN,tau_sf=tau,lightmin = lightmin, lightmax = lightmax,SNmin = SNmin, SNmax = SNmax,
                                   makeplot=True)
                else:
                    tm.make_galaxy(name,SSPs=ssp,SN=SN,tau_sf=tau,lightmin = lightmin, lightmax = lightmax,SNmin = SNmin, SNmax = SNmax,
                                   makeplot=False)
                f.write("do_simple_allZ2, '{0:}.ms_lin.fits', '{0:}.me_lin.fits', '{0:}_fit.dat', wavemin=3800., wavemax=6800., fitregion=[3850., 6650.], emmaskw=500., lightmin={1:}, lightmax={2:}, model='{3:}'\n".format(os.path.basename(name),lightmin,lightmax,DFK_model))
                # for z in range(fraclist.size):
                    # f.write("do_simple, '{0:}.ms_lin.fits', '{0:}.me_lin.fits', '{0:}_Z{1:04}_fit.dat', wavemin=3750., wavemax=6800., lightmin={2:}, lightmax={3:}, model='{4:}'\n".format(os.path.basename(name),int(fraclist[z]*1000),lightmin,lightmax,modellist[z]))
        f.close()
    return