Commit 2497d9d1 authored by Shuai Feng's avatar Shuai Feng
Browse files

add PEP8 bugs

parent 7c2ce85a
Pipeline #7133 passed with stage
in 0 seconds
import sys import sys
sys.path.insert(0, '..')
import unittest import unittest
from csst_ifs_gehong import spec1d as s from csst_ifs_gehong import spec1d as s
from csst_ifs_gehong import map2d as m from csst_ifs_gehong import map2d as m
from csst_ifs_gehong import cube3d as b from csst_ifs_gehong import cube3d as b
from csst_ifs_gehong import config as c from csst_ifs_gehong import config as c
import numpy as np import numpy as np
import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
# import warnings
sys.path.insert(0, '..')
import warnings
class test_cube3d(unittest.TestCase): class test_cube3d(unittest.TestCase):
...@@ -25,7 +27,7 @@ class test_cube3d(unittest.TestCase): ...@@ -25,7 +27,7 @@ class test_cube3d(unittest.TestCase):
print(" ") print(" ")
inst = c.config() inst = c.config()
gas_tem = s.EmissionLineTemplate(inst, model = 'hii') gas_tem = s.EmissionLineTemplate(inst, model='hii')
stellar_tem = s.StellarContinuumTemplate(inst) stellar_tem = s.StellarContinuumTemplate(inst)
sbmap = m.Map2d(inst) sbmap = m.Map2d(inst)
...@@ -35,14 +37,14 @@ class test_cube3d(unittest.TestCase): ...@@ -35,14 +37,14 @@ class test_cube3d(unittest.TestCase):
vdispmap = m.Map2d(inst) vdispmap = m.Map2d(inst)
vdispmap.gred_map() vdispmap.gred_map()
agemap = m.Map2d(inst) agemap = m.Map2d(inst)
agemap.gred_map(a0 = 9.5, gred = -1.2) agemap.gred_map(a0=9.5, gred=-1.2)
fehmap = m.Map2d(inst) fehmap = m.Map2d(inst)
fehmap.gred_map(a0 = -0.2, gred = -0.1) fehmap.gred_map(a0=-0.2, gred=-0.1)
ebvmap = m.Map2d(inst) ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1) ebvmap.gred_map(a0=0.2, gred=-0.1)
stellarcontinuum = m.StellarPopulationMap(inst, sbright = sbmap, logage = agemap, stellarcontinuum = m.StellarPopulationMap(inst, sbright=sbmap, logage=agemap,
feh = fehmap, vel = velmap, feh=fehmap, vel=velmap,
vdisp = vdispmap, ebv = ebvmap) vdisp=vdispmap, ebv=ebvmap)
sbmap = m.Map2d(inst) sbmap = m.Map2d(inst)
sbmap.sersic_map() sbmap.sersic_map()
...@@ -51,32 +53,33 @@ class test_cube3d(unittest.TestCase): ...@@ -51,32 +53,33 @@ class test_cube3d(unittest.TestCase):
vdispmap = m.Map2d(inst) vdispmap = m.Map2d(inst)
vdispmap.gred_map() vdispmap.gred_map()
agemap = m.Map2d(inst) agemap = m.Map2d(inst)
agemap.gred_map(a0 = 9.5, gred = -1.2) agemap.gred_map(a0=9.5, gred=-1.2)
fehmap = m.Map2d(inst) fehmap = m.Map2d(inst)
fehmap.gred_map(a0 = -0.2, gred = -0.1) fehmap.gred_map(a0=-0.2, gred=-0.1)
ebvmap = m.Map2d(inst) ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1) ebvmap.gred_map(a0=0.2, gred=-0.1)
ionizedgas = m.IonizedGasMap(inst, halpha = agemap, zh = fehmap, ionizedgas = m.IonizedGasMap(inst, halpha=agemap, zh=fehmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap) vel=velmap, vdisp=vdispmap, ebv=ebvmap)
u = b.Cube3D(inst, stellar_map = stellarcontinuum, gas_map = ionizedgas) u = b.Cube3D(inst, stellar_map=stellarcontinuum, gas_map=ionizedgas)
u.make_cube(stellar_tem = stellar_tem, hii_tem = gas_tem) u.make_cube(stellar_tem=stellar_tem, hii_tem=gas_tem)
u.savefits('result.fits') u.savefits('result.fits')
if np.sum(u.flux[15,15,:]) != np.sum(u.flux[5,25,:]): if np.sum(u.flux[15, 15, :]) != np.sum(u.flux[5, 25, :]):
print("No Problem!") print("No Problem!")
#plt.figure(figsize=(16,4)) # plt.figure(figsize=(16,4))
#plt.plot(u.wave,np.log10(u.flux[50,50,:]),color='blue',label=r'$v=%4.2f$'%(velmap.map[50,50])) # plt.plot(u.wave,np.log10(u.flux[50,50,:]),color='blue',label=r'$v=%4.2f$'%(velmap.map[50,50]))
#plt.plot(u.wave,np.log10(u.flux[5,95,:]),color='red',label=r'$v=%4.2f$'%(velmap.map[5,95])) # plt.plot(u.wave,np.log10(u.flux[5,95,:]),color='red',label=r'$v=%4.2f$'%(velmap.map[5,95]))
#plt.xlim(3500,9500) # plt.xlim(3500,9500)
#plt.legend(frameon=False) # plt.legend(frameon=False)
#plt.savefig('./image/test_cube3d_spec.png') # plt.savefig('./image/test_cube3d_spec.png')
print("-----------------------------------------------------------------") print("-----------------------------------------------------------------")
print(">>> Unit test for **Spec Cube** Modelling has been passed!") print(">>> Unit test for **Spec Cube** Modelling has been passed!")
if __name__=='__main__':
if __name__ == '__main__':
unittest.main() unittest.main()
import sys import sys
sys.path.insert(0, '..')
import unittest import unittest
from csst_ifs_gehong import map2d as m from csst_ifs_gehong import map2d as m
from csst_ifs_gehong import config as c from csst_ifs_gehong import config as c
import numpy as np import numpy as np
import matplotlib.pyplot as plt # import matplotlib.pyplot as plt
# import warnings
sys.path.insert(0, '..')
import warnings
class test_map2d(unittest.TestCase): class test_map2d(unittest.TestCase):
...@@ -22,44 +23,44 @@ class test_map2d(unittest.TestCase): ...@@ -22,44 +23,44 @@ class test_map2d(unittest.TestCase):
print(" ") print(" ")
print("Pars: Total Magnitude") print("Pars: Total Magnitude")
sbmap0 = m.Map2d(inst) sbmap0 = m.Map2d(inst)
sbmap0.sersic_map(mag = 12, r_eff = 2, n = 2.5, ellip = 0.5, theta = -50) sbmap0.sersic_map(mag=12, r_eff=2, n=2.5, ellip=0.5, theta=-50)
sbmap1 = m.Map2d(inst) sbmap1 = m.Map2d(inst)
sbmap1.sersic_map(mag = 14, r_eff = 2, n = 2.5, ellip = 0.5, theta = -50) sbmap1.sersic_map(mag=14, r_eff=2, n=2.5, ellip=0.5, theta=-50)
if np.sum(sbmap1.map) != np.sum(sbmap0.map): if np.sum(sbmap1.map) != np.sum(sbmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Effective Radius") print("Pars: Effective Radius")
sbmap1 = m.Map2d(inst) sbmap1 = m.Map2d(inst)
sbmap1.sersic_map(mag = 12, r_eff = 4, n = 2.5, ellip = 0.5, theta = -50) sbmap1.sersic_map(mag=12, r_eff=4, n=2.5, ellip=0.5, theta=-50)
if np.sum(sbmap1.map) != np.sum(sbmap0.map): if np.sum(sbmap1.map) != np.sum(sbmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Sersic Index") print("Pars: Sersic Index")
sbmap1 = m.Map2d(inst) sbmap1 = m.Map2d(inst)
sbmap1.sersic_map(mag = 12, r_eff = 2, n = 5, ellip = 0.5, theta = -50) sbmap1.sersic_map(mag=12, r_eff=2, n=5, ellip=0.5, theta=-50)
if np.sum(sbmap1.map) != np.sum(sbmap0.map): if np.sum(sbmap1.map) != np.sum(sbmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Ellipse") print("Pars: Ellipse")
sbmap1 = m.Map2d(inst) sbmap1 = m.Map2d(inst)
sbmap1.sersic_map(mag = 12, r_eff = 2, n = 2.5, ellip = 0.2, theta = -50) sbmap1.sersic_map(mag=12, r_eff=2, n=2.5, ellip=0.2, theta=-50)
if np.sum(sbmap1.map) != np.sum(sbmap0.map): if np.sum(sbmap1.map) != np.sum(sbmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Position Angle") print("Pars: Position Angle")
sbmap1 = m.Map2d(inst) sbmap1 = m.Map2d(inst)
sbmap1.sersic_map(mag = 12, r_eff = 2, n = 2.5, ellip = 0.5, theta = 0) sbmap1.sersic_map(mag=12, r_eff=2, n=2.5, ellip=0.5, theta=0)
if np.sum(sbmap1.map) != np.sum(sbmap0.map): if np.sum(sbmap1.map) != np.sum(sbmap0.map):
print("No Problem!") print("No Problem!")
#plt.figure(figsize=(6,5)) # plt.figure(figsize=(6,5))
#plt.imshow(sbmap0.map, origin='lower', cmap='gray_r') # plt.imshow(sbmap0.map, origin='lower', cmap='gray_r')
#plt.xticks([]) # plt.xticks([])
#plt.yticks([]) # plt.yticks([])
#plt.title('Surface Brightness Modelling') # plt.title('Surface Brightness Modelling')
#plt.colorbar(label='mag') # plt.colorbar(label='mag')
#plt.tight_layout() # plt.tight_layout()
#plt.savefig('./image/test_map2d_SBmap.png') # plt.savefig('./image/test_map2d_SBmap.png')
def test_velmap(self): def test_velmap(self):
...@@ -69,38 +70,38 @@ class test_map2d(unittest.TestCase): ...@@ -69,38 +70,38 @@ class test_map2d(unittest.TestCase):
print(" ") print(" ")
print("Pars: Rotation Velocity") print("Pars: Rotation Velocity")
velmap0 = m.Map2d(inst) velmap0 = m.Map2d(inst)
velmap0.tanh_map(vmax = 200, rt = 2, ellip = 0.5, theta = -50) velmap0.tanh_map(vmax=200, rt=2, ellip=0.5, theta=-50)
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.tanh_map(vmax = 100, rt = 2, ellip = 0.5, theta = -50) velmap1.tanh_map(vmax=100, rt=2, ellip=0.5, theta=-50)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Turnover Radius") print("Pars: Turnover Radius")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.tanh_map(vmax = 200, rt = 3, ellip = 0.5, theta = -50) velmap1.tanh_map(vmax=200, rt=3, ellip=0.5, theta=-50)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Inclination Angle") print("Pars: Inclination Angle")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.tanh_map(vmax = 200, rt = 2, ellip = 0.3, theta = -50) velmap1.tanh_map(vmax=200, rt=2, ellip=0.3, theta=-50)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Position Angle") print("Pars: Position Angle")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.tanh_map(vmax = 200, rt = 2, ellip = 0.5, theta = 100) velmap1.tanh_map(vmax=200, rt=2, ellip=0.5, theta=100)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
#plt.figure(figsize=(6,5)) # plt.figure(figsize=(6,5))
#plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r') # plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
#plt.xticks([]) # plt.xticks([])
#plt.yticks([]) # plt.yticks([])
#plt.title('Velocity Map Modelling') # plt.title('Velocity Map Modelling')
#plt.colorbar(label='km/s') # plt.colorbar(label='km/s')
#plt.tight_layout() # plt.tight_layout()
#plt.savefig('./image/test_map2d_velmap.png') # plt.savefig('./image/test_map2d_velmap.png')
def test_gremap(self): def test_gremap(self):
...@@ -110,44 +111,44 @@ class test_map2d(unittest.TestCase): ...@@ -110,44 +111,44 @@ class test_map2d(unittest.TestCase):
print(" ") print(" ")
print("Pars: Central Intensity") print("Pars: Central Intensity")
velmap0 = m.Map2d(inst) velmap0 = m.Map2d(inst)
velmap0.gred_map(a0 = 10, r_eff = 1, gred = -1, ellip = 0.5, theta = 0) velmap0.gred_map(a0=10, r_eff=1, gred=-1, ellip=0.5, theta=0)
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.gred_map(a0 = 20, r_eff = 1, gred = -1, ellip = 0.5, theta = 0) velmap1.gred_map(a0=20, r_eff=1, gred=-1, ellip=0.5, theta=0)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Effective Radius") print("Pars: Effective Radius")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.gred_map(a0 = 10, r_eff = 2, gred = -1, ellip = 0.5, theta = 0) velmap1.gred_map(a0=10, r_eff=2, gred=-1, ellip=0.5, theta=0)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Grediant") print("Pars: Grediant")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.gred_map(a0 = 10, r_eff = 1, gred = -2, ellip = 0.5, theta = 0) velmap1.gred_map(a0=10, r_eff=1, gred=-2, ellip=0.5, theta=0)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Inclination Angle") print("Pars: Inclination Angle")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.gred_map(a0 = 10, r_eff = 1, gred = -1, ellip = 0.3, theta = 0) velmap1.gred_map(a0=10, r_eff=1, gred=-1, ellip=0.3, theta=0)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
print("Pars: Position Angle") print("Pars: Position Angle")
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.gred_map(a0 = 10, r_eff = 1, gred = -1, ellip = 0.5, theta = 100) velmap1.gred_map(a0=10, r_eff=1, gred=-1, ellip=0.5, theta=100)
if np.sum(velmap1.map) != np.sum(velmap0.map): if np.sum(velmap1.map) != np.sum(velmap0.map):
print("No Problem!") print("No Problem!")
#plt.figure(figsize=(6,5)) # plt.figure(figsize=(6,5))
#plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r') # plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
#plt.xticks([]) # plt.xticks([])
#plt.yticks([]) # plt.yticks([])
#plt.title('Gredient Map Modelling') # plt.title('Gredient Map Modelling')
#plt.colorbar(label='') # plt.colorbar(label='')
#plt.tight_layout() # plt.tight_layout()
#plt.savefig('./image/test_map2d_gredmap.png') # plt.savefig('./image/test_map2d_gredmap.png')
def test_input_image(self): def test_input_image(self):
...@@ -156,7 +157,7 @@ class test_map2d(unittest.TestCase): ...@@ -156,7 +157,7 @@ class test_map2d(unittest.TestCase):
print("------------------------ Feed Image------------------------") print("------------------------ Feed Image------------------------")
print(" ") print(" ")
velmap0 = m.Map2d(inst) velmap0 = m.Map2d(inst)
velmap0.gred_map(a0 = 10, r_eff = 1, gred = -1, ellip = 0.5, theta = 0) velmap0.gred_map(a0=10, r_eff=1, gred=-1, ellip=0.5, theta=0)
velmap1 = m.Map2d(inst) velmap1 = m.Map2d(inst)
velmap1.load_map(velmap0.map) velmap1.load_map(velmap0.map)
if np.sum(velmap1.map) == np.sum(velmap0.map): if np.sum(velmap1.map) == np.sum(velmap0.map):
...@@ -176,16 +177,16 @@ class test_map2d(unittest.TestCase): ...@@ -176,16 +177,16 @@ class test_map2d(unittest.TestCase):
vdispmap.gred_map() vdispmap.gred_map()
agemap = m.Map2d(inst) agemap = m.Map2d(inst)
agemap.gred_map(a0 = 9.5, gred = -1.2) agemap.gred_map(a0=9.5, gred=-1.2)
fehmap = m.Map2d(inst) fehmap = m.Map2d(inst)
fehmap.gred_map(a0 = -0.2, gred = -0.1) fehmap.gred_map(a0=-0.2, gred=-0.1)
ebvmap = m.Map2d(inst) ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1) ebvmap.gred_map(a0=0.2, gred=-0.1)
stellarcontinuum = m.StellarPopulationMap(inst, sbright = sbmap, logage = agemap, feh = fehmap, stellarcontinuum = m.StellarPopulationMap(inst, sbright=sbmap, logage=agemap, feh=fehmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap) vel=velmap, vdisp=vdispmap, ebv=ebvmap)
if np.sum(stellarcontinuum.sbright) == np.sum(sbmap.map): if np.sum(stellarcontinuum.sbright) == np.sum(sbmap.map):
print("SBmap No Problem!") print("SBmap No Problem!")
...@@ -214,13 +215,13 @@ class test_map2d(unittest.TestCase): ...@@ -214,13 +215,13 @@ class test_map2d(unittest.TestCase):
vdispmap.gred_map() vdispmap.gred_map()
logohmap = m.Map2d(inst) logohmap = m.Map2d(inst)
logohmap.gred_map(a0 = 9.5, gred = -1.2) logohmap.gred_map(a0=9.5, gred=-1.2)
ebvmap = m.Map2d(inst) ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1) ebvmap.gred_map(a0=0.2, gred=-0.1)
gas = m.IonizedGasMap(inst, halpha = halphamap, zh = logohmap, gas = m.IonizedGasMap(inst, halpha=halphamap, zh=logohmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap) vel=velmap, vdisp=vdispmap, ebv=ebvmap)
if np.sum(gas.halpha) == np.sum(halphamap.map): if np.sum(gas.halpha) == np.sum(halphamap.map):
print("Halphamap No Problem!") print("Halphamap No Problem!")
...@@ -233,5 +234,6 @@ class test_map2d(unittest.TestCase): ...@@ -233,5 +234,6 @@ class test_map2d(unittest.TestCase):
if np.sum(gas.ebv) == np.sum(ebvmap.map): if np.sum(gas.ebv) == np.sum(ebvmap.map):
print("SBmap No Problem!") print("SBmap No Problem!")
if __name__=='__main__':
if __name__ == '__main__':
unittest.main() unittest.main()
import sys import sys
sys.path.insert(0, '..')
import unittest import unittest
from csst_ifs_gehong import spec1d as s from csst_ifs_gehong import spec1d as s
from csst_ifs_gehong import config as c from csst_ifs_gehong import config as c
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import warnings import warnings
warnings.simplefilter("ignore", ResourceWarning) warnings.simplefilter("ignore", ResourceWarning)
sys.path.insert(0, '..')
class test_spec1d(unittest.TestCase): class test_spec1d(unittest.TestCase):
...@@ -27,88 +27,88 @@ class test_spec1d(unittest.TestCase): ...@@ -27,88 +27,88 @@ class test_spec1d(unittest.TestCase):
temp = s.StellarContinuumTemplate(inst) temp = s.StellarContinuumTemplate(inst)
plt.figure(figsize=(15,12)) plt.figure(figsize=(15, 12))
print("------------------------Test Magnitude---------------------------") print("------------------------Test Magnitude---------------------------")
print("1. mr=15") print("1. mr=15")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0, vel = 100, vdisp = 100, ebv = 0) sed1 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0, vel=100, vdisp=100, ebv=0)
print("2. mr=13") print("2. mr=13")
sed2 = s.StellarContinuum(inst, temp, mag = 13, age = 1, feh = 0, vel = 100, vdisp = 100, ebv = 0) sed2 = s.StellarContinuum(inst, temp, mag=13, age=1, feh=0, vel=100, vdisp=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(231) plt.subplot(231)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'mr = 15') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='mr = 15')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'mr = 13') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='mr = 13')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("---------------------------Test Age-----------------------------") print("---------------------------Test Age-----------------------------")
print("1. Age=0.1Gyr") print("1. Age=0.1Gyr")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 0.1, feh = 0, vel = 100, vdisp = 100, ebv = 0) sed1 = s.StellarContinuum(inst, temp, mag=15, age=0.1, feh=0, vel=100, vdisp=100, ebv=0)
print("2. Age=1Gyr") print("2. Age=1Gyr")
sed2 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0, vel = 100, vdisp = 100, ebv = 0) sed2 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0, vel=100, vdisp=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(232) plt.subplot(232)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'Age = 0.1Gyr') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='Age = 0.1Gyr')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'Age = 1Gyr') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='Age = 1Gyr')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("-----------------------Test Metallicity-------------------------") print("-----------------------Test Metallicity-------------------------")
print("1. [Fe/H]=0.5") print("1. [Fe/H]=0.5")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0.5, vel = 100, vdisp = 100, ebv = 0) sed1 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0.5, vel=100, vdisp=100, ebv=0)
print("2. [Fe/H]=-0.5") print("2. [Fe/H]=-0.5")
sed2 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = -0.5, vel = 100, vdisp = 100, ebv = 0) sed2 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=-0.5, vel=100, vdisp=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(233) plt.subplot(233)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = '[Fe/H] = 0.5') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='[Fe/H] = 0.5')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = '[Fe/H] = -0.5') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='[Fe/H] = -0.5')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("------------------------Test Velocity---------------------------") print("------------------------Test Velocity---------------------------")
print("1. v=3000km/s") print("1. v=3000km/s")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0, vel = 3000, vdisp = 100, ebv = 0) sed1 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0, vel=3000, vdisp=100, ebv=0)
print("2. v=6000km/s") print("2. v=6000km/s")
sed2 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0, vel = 6000, vdisp = 100, ebv = 0) sed2 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0, vel=6000, vdisp=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(234) plt.subplot(234)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'v = 3000km/s') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='v = 3000km/s')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'v = 6000km/s') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='v = 6000km/s')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("-------------------Test Velocity Dispersion----------------------") print("-------------------Test Velocity Dispersion----------------------")
print("1. sigma=180km/s") print("1. sigma=180km/s")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0.5, vel = 100, vdisp = 180, ebv = 0) sed1 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0.5, vel=100, vdisp=180, ebv=0)
print("2. sigma=350km/s") print("2. sigma=350km/s")
sed2 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0.5, vel = 100, vdisp = 350, ebv = 0) sed2 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0.5, vel=100, vdisp=350, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(235) plt.subplot(235)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'sigma = 180km/s') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='sigma = 180km/s')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'sigma = 350km/s') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='sigma = 350km/s')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("----------------------Test Dust Extinction-----------------------") print("----------------------Test Dust Extinction-----------------------")
print("1. E(B-V)=0.1") print("1. E(B-V)=0.1")
sed1 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0.5, vel = 100, vdisp = 100, ebv = 0.1) sed1 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0.5, vel=100, vdisp=100, ebv=0.1)
print("2. E(B-V)=0.3") print("2. E(B-V)=0.3")
sed2 = s.StellarContinuum(inst, temp, mag = 15, age = 1, feh = 0.5, vel = 100, vdisp = 100, ebv = 0.3) sed2 = s.StellarContinuum(inst, temp, mag=15, age=1, feh=0.5, vel=100, vdisp=100, ebv=0.3)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(236) plt.subplot(236)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'E(B-V) = 0.1') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='E(B-V) = 0.1')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'E(B-V) = 0.3') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='E(B-V) = 0.3')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
plt.tight_layout() plt.tight_layout()
#plt.savefig('./image/test_spec1d_stellarpopulation.png') # plt.savefig('./image/test_spec1d_stellarpopulation.png')
def test_Star(self): def test_Star(self):
...@@ -122,62 +122,62 @@ class test_spec1d(unittest.TestCase): ...@@ -122,62 +122,62 @@ class test_spec1d(unittest.TestCase):
temp = s.SingleStarTemplate(inst) temp = s.SingleStarTemplate(inst)
plt.figure(figsize=(15,12)) plt.figure(figsize=(15, 12))
print("------------------------Test Magnitude---------------------------") print("------------------------Test Magnitude---------------------------")
print("1. mr=15") print("1. mr=15")
sed1 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = 0, vel = 100, ebv = 0) sed1 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=0, vel=100, ebv=0)
print("2. mr=13") print("2. mr=13")
sed2 = s.SingleStar(inst, temp, mag = 13, teff = 10000, feh = 0, vel = 100, ebv = 0) sed2 = s.SingleStar(inst, temp, mag=13, teff=10000, feh=0, vel=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(221) plt.subplot(221)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'mr = 15') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='mr = 15')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'mr = 13') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='mr = 13')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("------------------------Test Tempreture--------------------------") print("------------------------Test Tempreture--------------------------")
print("1. Teff=6000K") print("1. Teff=6000K")
sed1 = s.SingleStar(inst, temp, mag = 15, teff = 6000, feh = 0, vel = 100, ebv = 0) sed1 = s.SingleStar(inst, temp, mag=15, teff=6000, feh=0, vel=100, ebv=0)
print("1. Teff=10000K") print("1. Teff=10000K")
sed2 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = 0, vel = 100, ebv = 0) sed2 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=0, vel=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(222) plt.subplot(222)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'Teff = 6000K') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='Teff = 6000K')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'Teff = 10000K') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='Teff = 10000K')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("-----------------------Test Metallicity--------------------------") print("-----------------------Test Metallicity--------------------------")
print("1. [Fe/H]=-0.5") print("1. [Fe/H]=-0.5")
sed1 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = -0.5, vel = 100, ebv = 0) sed1 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=-0.5, vel=100, ebv=0)
print("2. [Fe/H]=0.5") print("2. [Fe/H]=0.5")
sed2 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = 0.5, vel = 100, ebv = 0) sed2 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=0.5, vel=100, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(223) plt.subplot(223)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = '[Fe/H] = -0.5') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='[Fe/H] = -0.5')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = '[Fe/H] = 0.5') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='[Fe/H] = 0.5')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("------------------------Test Velocity---------------------------") print("------------------------Test Velocity---------------------------")
print("1. v=-200km/s") print("1. v=-200km/s")
sed1 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = 0, vel = -200, ebv = 0) sed1 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=0, vel=-200, ebv=0)
print("2. v=200km/s") print("2. v=200km/s")
sed2 = s.SingleStar(inst, temp, mag = 15, teff = 10000, feh = 0, vel = 200, ebv = 0) sed2 = s.SingleStar(inst, temp, mag=15, teff=10000, feh=0, vel=200, ebv=0)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(224) plt.subplot(224)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'v = -200km/s') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='v = -200km/s')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'v = 200km/s') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='v = 200km/s')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
plt.tight_layout() plt.tight_layout()
#plt.savefig('./image/test_spec1d_singlestar.png') # plt.savefig('./image/test_spec1d_singlestar.png')
print("-----------------------------------------------------------------") print("-----------------------------------------------------------------")
print(">>> Unit test for **Single Stellar** Modelling has been passed!") print(">>> Unit test for **Single Stellar** Modelling has been passed!")
...@@ -192,82 +192,82 @@ class test_spec1d(unittest.TestCase): ...@@ -192,82 +192,82 @@ class test_spec1d(unittest.TestCase):
print(">>> Start Test") print(">>> Start Test")
print(" ") print(" ")
temp = s.EmissionLineTemplate(inst, model = 'hii') temp = s.EmissionLineTemplate(inst, model='hii')
plt.figure(figsize=(15,12)) plt.figure(figsize=(15, 12))
print("---------------------Test Total Halpha Flux----------------------") print("---------------------Test Total Halpha Flux----------------------")
print("1. F_Halpha = 10 * 1e-17 erg/s/cm^2") print("1. F_Halpha = 10 * 1e-17 erg/s/cm^2")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 100, vdisp = 120, ebv = 0.1) sed1 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=100, vdisp=120, ebv=0.1)
print("2. F_Halpha = 50 * 1e-17 erg/s/cm^2") print("2. F_Halpha = 50 * 1e-17 erg/s/cm^2")
sed2 = s.HII_Region(inst, temp, halpha = 50, logz = -1, vel = 100, vdisp = 120, ebv = 0.1) sed2 = s.HII_Region(inst, temp, halpha=50, logz=-1, vel=100, vdisp=120, ebv=0.1)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(231) plt.subplot(231)
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'Flux = 50') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='Flux = 50')
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'Flux = 10') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='Flux = 10')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("-------------------Test Gas-Phase Metallicity--------------------") print("-------------------Test Gas-Phase Metallicity--------------------")
print("1. [Z/H] = 0") print("1. [Z/H] = 0")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = 0, vel = 100, vdisp = 120, ebv = 0.1) sed1 = s.HII_Region(inst, temp, halpha=10, logz=0, vel=100, vdisp=120, ebv=0.1)
print("2. [Z/H] = -0.5") print("2. [Z/H] = -0.5")
sed2 = s.HII_Region(inst, temp, halpha = 10, logz = -0.5, vel = 100, vdisp = 120, ebv = 0.1) sed2 = s.HII_Region(inst, temp, halpha=10, logz=-0.5, vel=100, vdisp=120, ebv=0.1)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(232) plt.subplot(232)
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = '[Z/H] = -0.5') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='[Z/H] = -0.5')
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = '[Z/H] = 0') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='[Z/H] = 0')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("-------------------------Test Velocity--------------------------") print("-------------------------Test Velocity--------------------------")
print("1. v=3000km/s") print("1. v=3000km/s")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 3000, vdisp = 120, ebv = 0.1) sed1 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=3000, vdisp=120, ebv=0.1)
print("2. v=6000km/s") print("2. v=6000km/s")
sed2 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 6000, vdisp = 120, ebv = 0.1) sed2 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=6000, vdisp=120, ebv=0.1)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(233) plt.subplot(233)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'v = 3000km/s') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='v = 3000km/s')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'v = 6000km/s') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='v = 6000km/s')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("--------------------Test Velocity Dispersion---------------------") print("--------------------Test Velocity Dispersion---------------------")
print("1. sigma=500km/s") print("1. sigma=500km/s")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 100, vdisp = 500, ebv = 0.1) sed1 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=100, vdisp=500, ebv=0.1)
print("2. sigma=100km/s") print("2. sigma=100km/s")
sed2 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 100, vdisp = 100, ebv = 0.1) sed2 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=100, vdisp=100, ebv=0.1)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(234) plt.subplot(234)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'sigma = 500km/s') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='sigma = 500km/s')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'sigma = 100km/s') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='sigma = 100km/s')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("----------------------Test Dust Extinction-----------------------") print("----------------------Test Dust Extinction-----------------------")
print("1. E(B-V)=0.1") print("1. E(B-V)=0.1")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 100, vdisp = 120, ebv = 0.1) sed1 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=100, vdisp=120, ebv=0.1)
print("2. E(B-V)=0.3") print("2. E(B-V)=0.3")
sed1 = s.HII_Region(inst, temp, halpha = 10, logz = -1, vel = 100, vdisp = 120, ebv = 0.3) sed1 = s.HII_Region(inst, temp, halpha=10, logz=-1, vel=100, vdisp=120, ebv=0.3)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(235) plt.subplot(235)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'E(B-V) = 0.1') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='E(B-V) = 0.1')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'E(B-V) = 0.3') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='E(B-V) = 0.3')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
plt.tight_layout() plt.tight_layout()
#plt.savefig('./image/test_spec1d_ionizedgas.png') # plt.savefig('./image/test_spec1d_ionizedgas.png')
print("-----------------------------------------------------------------") print("-----------------------------------------------------------------")
print(">>> Unit test for **Ionized Gas** Modelling has been passed!") print(">>> Unit test for **Ionized Gas** Modelling has been passed!")
...@@ -282,87 +282,88 @@ class test_spec1d(unittest.TestCase): ...@@ -282,87 +282,88 @@ class test_spec1d(unittest.TestCase):
print(">>> Start Test") print(">>> Start Test")
print(" ") print(" ")
temp = s.EmissionLineTemplate(inst, model = 'nlr') temp = s.EmissionLineTemplate(inst, model='nlr')
plt.figure(figsize=(15,12)) plt.figure(figsize=(15, 12))
print("-------------------------Test Redshift--------------------------") print("-------------------------Test Redshift--------------------------")
print("1. z=0.2") print("1. z=0.2")
sed1 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05, sed1 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
print("2. z=0.4") print("2. z=0.4")
sed2 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05, sed2 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 40000, logz = 0, ebv = 0.1, dist = 20) vel=40000, logz=0, ebv=0.1, dist=20)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(221) plt.subplot(221)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'z = 0.2') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='z = 0.2')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'z = 0.4') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='z = 0.4')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("----------------------Test Black Hole Mass-----------------------") print("----------------------Test Black Hole Mass-----------------------")
print("1. Mbh=1e6") print("1. Mbh=1e6")
sed1 = s.AGN(inst, temp, bhmass = 1e6, edd_ratio = 0.05, sed1 = s.AGN(inst, temp, bhmass=1e6, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
print("2. Mbh=5e6") print("2. Mbh=5e6")
sed2 = s.AGN(inst, temp, bhmass = 5e6, edd_ratio = 0.05, sed2 = s.AGN(inst, temp, bhmass=5e6, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(222) plt.subplot(222)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'Mbh = 1e6') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='Mbh = 1e6')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'Mbh = 5e6') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='Mbh = 5e6')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("------------------------Eddington Ratio-------------------------") print("------------------------Eddington Ratio-------------------------")
print("1. Edd Ratio = 1.0") print("1. Edd Ratio = 1.0")
sed1 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 1.0, sed1 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=1.0,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
print("2. Edd Ratio = 0.1") print("2. Edd Ratio = 0.1")
sed2 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.1, sed2 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=0.1,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(223) plt.subplot(223)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'EddRatio = 1.0') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='EddRatio = 1.0')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'EddRatio = 0.1') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='EddRatio = 0.1')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
print("----------------------Test Dust Extinction-----------------------") print("----------------------Test Dust Extinction-----------------------")
print("1. E(B-V)=0.1") print("1. E(B-V)=0.1")
sed1 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05, sed1 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.1, dist = 20) vel=20000, logz=0, ebv=0.1, dist=20)
print("2. E(B-V)=0.3") print("2. E(B-V)=0.3")
sed2 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05, sed2 = s.AGN(inst, temp, bhmass=1e5, edd_ratio=0.05,
halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500, halpha_broad=100, halpha_narrow=100, vdisp_broad=2000, vdisp_narrow=500,
vel = 20000, logz = 0, ebv = 0.3, dist = 20) vel=20000, logz=0, ebv=0.3, dist=20)
if np.sum(sed1.flux) != np.sum(sed2.flux): if np.sum(sed1.flux) != np.sum(sed2.flux):
print("No Problem!") print("No Problem!")
plt.subplot(224) plt.subplot(224)
plt.plot(sed1.wave, sed1.flux, color = 'blue', lw = 2, label = 'E(B-V) = 0.1') plt.plot(sed1.wave, sed1.flux, color='blue', lw=2, label='E(B-V) = 0.1')
plt.plot(sed2.wave, sed2.flux, color = 'red', lw = 2, label = 'E(B-V) = 0.3') plt.plot(sed2.wave, sed2.flux, color='red', lw=2, label='E(B-V) = 0.3')
plt.legend(frameon=False) plt.legend(frameon=False)
plt.xlim(3900, 6200) plt.xlim(3900, 6200)
plt.tight_layout() plt.tight_layout()
#plt.savefig('./image/test_spec1d_agn.png') # plt.savefig('./image/test_spec1d_agn.png')
print("-----------------------------------------------------------------") print("-----------------------------------------------------------------")
print(">>> Unit test for **AGN** Modelling has been passed!") print(">>> Unit test for **AGN** Modelling has been passed!")
if __name__=='__main__':
if __name__ == '__main__':
unittest.main() unittest.main()
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