Commit 132ee572 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 40d93d8b
This diff is collapsed.
......@@ -56,7 +56,7 @@ def reddening(wave, flux, ebv = 0.0, law = 'calzetti', Rv = 4.05):
fluxNew = flux / (10. ** (0.4 * ebv * curve))
return fluxNew
def flux_to_mag(wave, flux, filepath, band='GAIA_bp'):
def flux_to_mag(wave, flux, band='GAIA_bp'):
"""Convert flux of given spectra to magnitude
Args:
......@@ -70,12 +70,9 @@ def flux_to_mag(wave, flux, filepath, band='GAIA_bp'):
# /home/yan/MCI_sim/MCI_input/SED_Code/data
import os
#parent = os.path.dirname(os.path.realpath(__file__))
parent=filepath
band = ascii.read(parent+'/SED_Code/seddata/' + band + '.dat')
parent = os.path.dirname(os.path.realpath(__file__))
band = ascii.read(parent+'/seddata/' + band + '.dat')
wave0= band['col1']
curv0= band['col2']
......@@ -92,7 +89,7 @@ def flux_to_mag(wave, flux, filepath, band='GAIA_bp'):
return -2.5 * np.log10(Tflux)
def calibrate(wave, flux, mag, filepath,band='GAIA_bp'):
def calibrate(wave, flux, mag, band='GAIA_bp'):
"""
Calibrate the spectra according to the magnitude.
......@@ -105,7 +102,7 @@ def calibrate(wave, flux, mag, filepath,band='GAIA_bp'):
Returns:
float: Flux of calibrated spectra. Units: 1e-17 erg/s/A/cm^2
"""
inst_mag = flux_to_mag(wave, flux,filepath ,band = band)
inst_mag = flux_to_mag(wave, flux, band = band)
instflux = 10 ** (-0.4 * inst_mag)
realflux = (mag * u.STmag).to(u.erg/u.s/u.cm**2/u.AA).value
......@@ -123,12 +120,12 @@ class Gal_Temp():
Template of Galaxy SED
"""
def __init__(self,parent):
def __init__(self):
import os
self.parent = parent
parent = os.path.dirname(os.path.realpath(__file__))
hdulist = fits.open(self.parent+'/SED_Code/seddata/galaxy_temp.fits')
hdulist = fits.open(parent+'/seddata/galaxy_temp.fits')
self.wave = hdulist[1].data['wave']
self.flux = hdulist[2].data
self.age_grid = hdulist[3].data['logAge']
......@@ -141,43 +138,43 @@ class Gal_Temp():
redshift (float, optional): redshift of spectra. Defaults to 0.
"""
wave = self.wave * (1 + redshift)
self.umag = flux_to_mag(wave, self.flux, self.parent,band='SDSS_u')
self.gmag = flux_to_mag(wave, self.flux, self.parent,band='SDSS_g')
self.rmag = flux_to_mag(wave, self.flux, self.parent,band='SDSS_r')
self.imag = flux_to_mag(wave, self.flux, self.parent,band='SDSS_i')
self.zmag = flux_to_mag(wave, self.flux, self.parent,band='SDSS_z')
self.umag = flux_to_mag(wave, self.flux, band='SDSS_u')
self.gmag = flux_to_mag(wave, self.flux, band='SDSS_g')
self.rmag = flux_to_mag(wave, self.flux, band='SDSS_r')
self.imag = flux_to_mag(wave, self.flux, band='SDSS_i')
self.zmag = flux_to_mag(wave, self.flux, band='SDSS_z')
class Star_Temp():
"""
Template of Stellar SED
"""
def __init__(self, parent):
#import os
#parent = os.path.dirname(os.path.realpath(__file__))
def __init__(self):
##/home/yan/MCI_sim_Fabu/MCI_inputData/SED_Code
self.parent = parent
import os
hdulist = fits.open(parent+'/SED_Code/seddata/stellar_temp.fits')
parent = os.path.dirname(os.path.realpath(__file__))
###print("获取其父目录——" + parent) # 从当前文件路径中获取目录
hdulist = fits.open(parent+'/seddata/stellar_temp.fits')
self.wave = hdulist[1].data['wave']
self.flux = hdulist[2].data
self.Teff_grid = hdulist[3].data['Teff']
self.FeH_grid = hdulist[3].data['FeH']
self.bpmag = flux_to_mag(self.wave, self.flux, band='GAIA_bp')
self.rpmag = flux_to_mag(self.wave, self.flux, band='GAIA_rp')
def toMag(self):
wave = self.wave
self.bpmag = flux_to_mag(wave, self.flux, self.parent,band='GAIA_bp')
self.rpmag = flux_to_mag(wave, self.flux, self.parent,band='GAIA_rp')
self.bpmag = flux_to_mag(wave, self.flux, band='GAIA_bp')
self.rpmag = flux_to_mag(wave, self.flux, band='GAIA_rp')
# -------------
# SED Modelling
def Model_Stellar_SED(wave, bp, rp, temp, filepath):
def Model_Stellar_SED(wave, bp, rp, temp):
"""Modelling stellar SED based on bp, rp magnitude
Args:
......@@ -197,7 +194,7 @@ def Model_Stellar_SED(wave, bp, rp, temp, filepath):
idx = np.argmin(np.abs(colors - color0))
flux0 = temp.flux[idx]
flux1 = np.interp(wave, temp.wave, flux0)
flux = calibrate(wave, flux1, rp, filepath, band = 'GAIA_rp')
flux = calibrate(wave, flux1, rp, band = 'GAIA_rp')
return flux
def Model_Galaxy_SED(wave, ugriz, z, temp):
......
This diff is collapsed.
This diff is collapsed.
3630.0 0.0000000000
3655.0 0.0003000000
3680.0 0.0008000000
3705.0 0.0013000000
3730.0 0.0019000000
3755.0 0.0024000000
3780.0 0.0034000000
3805.0 0.0055000000
3830.0 0.0103000000
3855.0 0.0194000000
3880.0 0.0326000000
3905.0 0.0492000000
3930.0 0.0686000000
3955.0 0.0900000000
3980.0 0.1123000000
4005.0 0.1342000000
4030.0 0.1545000000
4055.0 0.1722000000
4080.0 0.1873000000
4105.0 0.2003000000
4130.0 0.2116000000
4155.0 0.2214000000
4180.0 0.2301000000
4205.0 0.2378000000
4230.0 0.2448000000
4255.0 0.2513000000
4280.0 0.2574000000
4305.0 0.2633000000
4330.0 0.2691000000
4355.0 0.2747000000
4380.0 0.2801000000
4405.0 0.2852000000
4430.0 0.2899000000
4455.0 0.2940000000
4480.0 0.2979000000
4505.0 0.3016000000
4530.0 0.3055000000
4555.0 0.3097000000
4580.0 0.3141000000
4605.0 0.3184000000
4630.0 0.3224000000
4655.0 0.3257000000
4680.0 0.3284000000
4705.0 0.3307000000
4730.0 0.3327000000
4755.0 0.3346000000
4780.0 0.3364000000
4805.0 0.3383000000
4830.0 0.3403000000
4855.0 0.3425000000
4880.0 0.3448000000
4905.0 0.3472000000
4930.0 0.3495000000
4955.0 0.3519000000
4980.0 0.3541000000
5005.0 0.3562000000
5030.0 0.3581000000
5055.0 0.3597000000
5080.0 0.3609000000
5105.0 0.3613000000
5130.0 0.3609000000
5155.0 0.3595000000
5180.0 0.3581000000
5205.0 0.3558000000
5230.0 0.3452000000
5255.0 0.3194000000
5280.0 0.2807000000
5305.0 0.2339000000
5330.0 0.1839000000
5355.0 0.1352000000
5380.0 0.0911000000
5405.0 0.0548000000
5430.0 0.0295000000
5455.0 0.0166000000
5480.0 0.0112000000
5505.0 0.0077000000
5530.0 0.0050000000
5555.0 0.0032000000
5580.0 0.0021000000
5605.0 0.0015000000
5630.0 0.0012000000
5655.0 0.0010000000
5680.0 0.0009000000
5705.0 0.0008000000
5730.0 0.0006000000
5755.0 0.0005000000
5780.0 0.0003000000
5805.0 0.0001000000
5830.0 0.0000000000
6430.0 0.0000000000
6455.0 0.0001000000
6480.0 0.0003000000
6505.0 0.0004000000
6530.0 0.0004000000
6555.0 0.0003000000
6580.0 0.0003000000
6605.0 0.0004000000
6630.0 0.0009000000
6655.0 0.0019000000
6680.0 0.0034000000
6705.0 0.0056000000
6730.0 0.0103000000
6755.0 0.0194000000
6780.0 0.0344000000
6805.0 0.0561000000
6830.0 0.0839000000
6855.0 0.1164000000
6880.0 0.1528000000
6905.0 0.1948000000
6930.0 0.2408000000
6955.0 0.2857000000
6980.0 0.3233000000
7005.0 0.3503000000
7030.0 0.3759000000
7055.0 0.3990000000
7080.0 0.4162000000
7105.0 0.4233000000
7130.0 0.4165000000
7155.0 0.3943000000
7180.0 0.3760000000
7205.0 0.3823000000
7230.0 0.3918000000
7255.0 0.3892000000
7280.0 0.3828000000
7305.0 0.3820000000
7330.0 0.3884000000
7355.0 0.3872000000
7380.0 0.3821000000
7405.0 0.3787000000
7430.0 0.3759000000
7455.0 0.3727000000
7480.0 0.3681000000
7505.0 0.3618000000
7530.0 0.3565000000
7555.0 0.3554000000
7580.0 0.3478000000
7605.0 0.1473000000
7630.0 0.2096000000
7655.0 0.2648000000
7680.0 0.3300000000
7705.0 0.3256000000
7730.0 0.3223000000
7755.0 0.3179000000
7780.0 0.3129000000
7805.0 0.3077000000
7830.0 0.3026000000
7855.0 0.2980000000
7880.0 0.2944000000
7905.0 0.2921000000
7930.0 0.2916000000
7955.0 0.2921000000
7980.0 0.2927000000
8005.0 0.2923000000
8030.0 0.2896000000
8055.0 0.2840000000
8080.0 0.2758000000
8105.0 0.2642000000
8130.0 0.2427000000
8155.0 0.2091000000
8180.0 0.1689000000
8205.0 0.1276000000
8230.0 0.0901000000
8255.0 0.0603000000
8280.0 0.0378000000
8305.0 0.0218000000
8330.0 0.0117000000
8355.0 0.0068000000
8380.0 0.0048000000
8405.0 0.0033000000
8430.0 0.0020000000
8455.0 0.0013000000
8480.0 0.0010000000
8505.0 0.0009000000
8530.0 0.0009000000
8555.0 0.0008000000
8580.0 0.0005000000
8605.0 0.0002000000
8630.0 0.0000000000
5380.0 0.0000000000
5405.0 0.0014000000
5430.0 0.0099000000
5455.0 0.0259000000
5480.0 0.0497000000
5505.0 0.0807000000
5530.0 0.1186000000
5555.0 0.1625000000
5580.0 0.2093000000
5605.0 0.2555000000
5630.0 0.2975000000
5655.0 0.3326000000
5680.0 0.3609000000
5705.0 0.3834000000
5730.0 0.4010000000
5755.0 0.4147000000
5780.0 0.4253000000
5805.0 0.4333000000
5830.0 0.4395000000
5855.0 0.4446000000
5880.0 0.4489000000
5905.0 0.4527000000
5930.0 0.4563000000
5955.0 0.4599000000
5980.0 0.4634000000
6005.0 0.4665000000
6030.0 0.4689000000
6055.0 0.4703000000
6080.0 0.4711000000
6105.0 0.4717000000
6130.0 0.4727000000
6155.0 0.4744000000
6180.0 0.4767000000
6205.0 0.4792000000
6230.0 0.4819000000
6255.0 0.4844000000
6280.0 0.4867000000
6305.0 0.4887000000
6330.0 0.4902000000
6355.0 0.4909000000
6380.0 0.4912000000
6405.0 0.4912000000
6430.0 0.4912000000
6455.0 0.4914000000
6480.0 0.4915000000
6505.0 0.4912000000
6530.0 0.4901000000
6555.0 0.4878000000
6580.0 0.4852000000
6605.0 0.4818000000
6630.0 0.4697000000
6655.0 0.4421000000
6680.0 0.4009000000
6705.0 0.3499000000
6730.0 0.2924000000
6755.0 0.2318000000
6780.0 0.1715000000
6805.0 0.1152000000
6830.0 0.0687000000
6855.0 0.0380000000
6880.0 0.0212000000
6905.0 0.0134000000
6930.0 0.0099000000
6955.0 0.0076000000
6980.0 0.0055000000
7005.0 0.0039000000
7030.0 0.0027000000
7055.0 0.0020000000
7080.0 0.0015000000
7105.0 0.0012000000
7130.0 0.0010000000
7155.0 0.0007000000
7180.0 0.0004000000
7205.0 0.0002000000
7230.0 0.0000000000
2980.0 0.0000000000
3005.0 0.0001000000
3030.0 0.0005000000
3055.0 0.0013000000
3080.0 0.0026000000
3105.0 0.0052000000
3130.0 0.0093000000
3155.0 0.0161000000
3180.0 0.0240000000
3205.0 0.0323000000
3230.0 0.0405000000
3255.0 0.0485000000
3280.0 0.0561000000
3305.0 0.0634000000
3330.0 0.0700000000
3355.0 0.0756000000
3380.0 0.0803000000
3405.0 0.0848000000
3430.0 0.0883000000
3455.0 0.0917000000
3480.0 0.0959000000
3505.0 0.1001000000
3530.0 0.1029000000
3555.0 0.1044000000
3580.0 0.1053000000
3605.0 0.1063000000
3630.0 0.1075000000
3655.0 0.1085000000
3680.0 0.1084000000
3705.0 0.1064000000
3730.0 0.1024000000
3755.0 0.0966000000
3780.0 0.0887000000
3805.0 0.0787000000
3830.0 0.0672000000
3855.0 0.0549000000
3880.0 0.0413000000
3905.0 0.0268000000
3930.0 0.0145000000
3955.0 0.0075000000
3980.0 0.0042000000
4005.0 0.0022000000
4030.0 0.0010000000
4055.0 0.0006000000
4080.0 0.0004000000
4105.0 0.0002000000
4130.0 0.0000000000
7730.0 0.0000000000
7755.0 0.0000000000
7780.0 0.0001000000
7805.0 0.0001000000
7830.0 0.0001000000
7855.0 0.0002000000
7880.0 0.0002000000
7905.0 0.0003000000
7930.0 0.0005000000
7955.0 0.0007000000
7980.0 0.0011000000
8005.0 0.0017000000
8030.0 0.0027000000
8055.0 0.0040000000
8080.0 0.0057000000
8105.0 0.0079000000
8130.0 0.0106000000
8155.0 0.0139000000
8180.0 0.0178000000
8205.0 0.0222000000
8230.0 0.0271000000
8255.0 0.0324000000
8280.0 0.0382000000
8305.0 0.0446000000
8330.0 0.0511000000
8355.0 0.0564000000
8380.0 0.0603000000
8405.0 0.0637000000
8430.0 0.0667000000
8455.0 0.0694000000
8480.0 0.0717000000
8505.0 0.0736000000
8530.0 0.0752000000
8555.0 0.0765000000
8580.0 0.0775000000
8605.0 0.0782000000
8630.0 0.0786000000
8655.0 0.0787000000
8680.0 0.0785000000
8705.0 0.0780000000
8730.0 0.0772000000
8755.0 0.0763000000
8780.0 0.0751000000
8805.0 0.0738000000
8830.0 0.0723000000
8855.0 0.0708000000
8880.0 0.0693000000
8905.0 0.0674000000
8930.0 0.0632000000
8955.0 0.0581000000
8980.0 0.0543000000
9005.0 0.0526000000
9030.0 0.0523000000
9055.0 0.0522000000
9080.0 0.0512000000
9105.0 0.0496000000
9130.0 0.0481000000
9155.0 0.0473000000
9180.0 0.0476000000
9205.0 0.0482000000
9230.0 0.0476000000
9255.0 0.0447000000
9280.0 0.0391000000
9305.0 0.0329000000
9330.0 0.0283000000
9355.0 0.0264000000
9380.0 0.0271000000
9405.0 0.0283000000
9430.0 0.0275000000
9455.0 0.0254000000
9480.0 0.0252000000
9505.0 0.0256000000
9530.0 0.0246000000
9555.0 0.0244000000
9580.0 0.0252000000
9605.0 0.0258000000
9630.0 0.0265000000
9655.0 0.0274000000
9680.0 0.0279000000
9705.0 0.0271000000
9730.0 0.0252000000
9755.0 0.0236000000
9780.0 0.0227000000
9805.0 0.0222000000
9830.0 0.0216000000
9855.0 0.0208000000
9880.0 0.0196000000
9905.0 0.0183000000
9930.0 0.0171000000
9955.0 0.0160000000
9980.0 0.0149000000
10005.0 0.0138000000
10030.0 0.0128000000
10055.0 0.0118000000
10080.0 0.0108000000
10105.0 0.0099000000
10130.0 0.0091000000
10155.0 0.0083000000
10180.0 0.0075000000
10205.0 0.0068000000
10230.0 0.0061000000
10255.0 0.0055000000
10280.0 0.0050000000
10305.0 0.0045000000
10330.0 0.0041000000
10355.0 0.0037000000
10380.0 0.0033000000
10405.0 0.0030000000
10430.0 0.0027000000
10455.0 0.0025000000
10480.0 0.0023000000
10505.0 0.0021000000
10530.0 0.0019000000
10555.0 0.0018000000
10580.0 0.0017000000
10605.0 0.0016000000
10630.0 0.0015000000
10655.0 0.0014000000
10680.0 0.0013000000
10705.0 0.0012000000
10730.0 0.0011000000
10755.0 0.0010000000
10780.0 0.0009000000
10805.0 0.0008000000
10830.0 0.0008000000
10855.0 0.0007000000
10880.0 0.0006000000
10905.0 0.0006000000
10930.0 0.0006000000
10955.0 0.0005000000
10980.0 0.0005000000
11005.0 0.0004000000
11030.0 0.0004000000
11055.0 0.0003000000
11080.0 0.0003000000
11105.0 0.0002000000
11130.0 0.0002000000
11155.0 0.0001000000
11180.0 0.0001000000
11205.0 0.0000000000
11230.0 0.0000000000
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment