Commit ce56e48c authored by Feng Shuai's avatar Feng Shuai 💬
Browse files

Update tests/test_spec1d.py

parent bf8acf21
Loading
Loading
Loading
Loading
Loading
+38 −38
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ class test_spec1d(unittest.TestCase):

        print("------------------------Test Magnitude---------------------------")
        print("1. mr=15")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(231)
@@ -44,9 +44,9 @@ class test_spec1d(unittest.TestCase):
        
        print("---------------------------Test  Age-----------------------------")
        print("1. Age=0.1Gyr")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(232)
@@ -57,9 +57,9 @@ class test_spec1d(unittest.TestCase):

        print("-----------------------Test  Metallicity-------------------------")
        print("1. [Fe/H]=0.5")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(233)
@@ -70,9 +70,9 @@ class test_spec1d(unittest.TestCase):
        
        print("------------------------Test  Velocity---------------------------")
        print("1. v=3000km/s")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(234)
@@ -83,9 +83,9 @@ class test_spec1d(unittest.TestCase):
        
        print("-------------------Test Velocity Dispersion----------------------")
        print("1. sigma=180km/s")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(235)
@@ -96,9 +96,9 @@ class test_spec1d(unittest.TestCase):

        print("----------------------Test Dust Extinction-----------------------")
        print("1. E(B-V)=0.1")
        sed1 = s.StellarContinuum(temp, inst, 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")
        sed2 = s.StellarContinuum(temp, inst, 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):
            print("No Problem!")
            plt.subplot(236)
@@ -126,9 +126,9 @@ class test_spec1d(unittest.TestCase):

        print("------------------------Test Magnitude---------------------------")
        print("1. mr=15")
        sed1 = s.SingleStar(temp, inst, 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")
        sed2 = s.SingleStar(temp, inst, 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):
            print("No Problem!")
            plt.subplot(221)
@@ -139,9 +139,9 @@ class test_spec1d(unittest.TestCase):

        print("------------------------Test Tempreture--------------------------")
        print("1. Teff=6000K")
        sed1 = s.SingleStar(temp, inst, 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")
        sed2 = s.SingleStar(temp, inst, 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):
            print("No Problem!")
            plt.subplot(222)
@@ -152,9 +152,9 @@ class test_spec1d(unittest.TestCase):

        print("-----------------------Test Metallicity--------------------------")
        print("1. [Fe/H]=-0.5")
        sed1 = s.SingleStar(temp, inst, 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")
        sed2 = s.SingleStar(temp, inst, 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):
            print("No Problem!")
            plt.subplot(223)
@@ -165,9 +165,9 @@ class test_spec1d(unittest.TestCase):

        print("------------------------Test  Velocity---------------------------")
        print("1. v=-200km/s")
        sed1 = s.SingleStar(temp, inst, 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")
        sed2 = s.SingleStar(temp, inst, 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):
            print("No Problem!")
            plt.subplot(224)
@@ -199,9 +199,9 @@ class test_spec1d(unittest.TestCase):
        print("---------------------Test Total Halpha Flux----------------------")

        print("1. F_Halpha = 10 * 1e-17 erg/s/cm^2")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = -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")
        sed2 = s.HII_Region(inst, temp, halpha = 50, zh = -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):
            print("No Problem!")
            plt.subplot(231)
@@ -213,9 +213,9 @@ class test_spec1d(unittest.TestCase):
        print("-------------------Test Gas-Phase Metallicity--------------------")

        print("1. [Z/H] = 0")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = 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")
        sed2 = s.HII_Region(inst, temp, halpha = 10, zh = -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):
            print("No Problem!")
            plt.subplot(232)
@@ -227,9 +227,9 @@ class test_spec1d(unittest.TestCase):
        print("-------------------------Test  Velocity--------------------------")

        print("1. v=3000km/s")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = -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")
        sed2 = s.HII_Region(inst, temp, halpha = 10, zh = -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):
            print("No Problem!")
            plt.subplot(233)
@@ -241,9 +241,9 @@ class test_spec1d(unittest.TestCase):
        print("--------------------Test Velocity Dispersion---------------------")

        print("1. sigma=500km/s")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = -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")
        sed2 = s.HII_Region(inst, temp, halpha = 10, zh = -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):
            print("No Problem!")
            plt.subplot(234)
@@ -255,9 +255,9 @@ class test_spec1d(unittest.TestCase):
        print("----------------------Test Dust Extinction-----------------------")

        print("1. E(B-V)=0.1")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = -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")
        sed1 = s.HII_Region(inst, temp, halpha = 10, zh = -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):
            print("No Problem!")
            plt.subplot(235)
@@ -291,11 +291,11 @@ class test_spec1d(unittest.TestCase):
        print("1. z=0.2")
        sed1 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        print("2. z=0.4")
        sed2 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 40000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 40000, logz = 0, ebv = 0.1, dist = 20)
        if np.sum(sed1.flux) != np.sum(sed2.flux):
            print("No Problem!")
            plt.subplot(221)
@@ -309,11 +309,11 @@ class test_spec1d(unittest.TestCase):
        print("1. Mbh=1e6")
        sed1 = s.AGN(inst, temp, bhmass = 1e6, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        print("2. Mbh=5e6")
        sed2 = s.AGN(inst, temp, bhmass = 5e6, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        if np.sum(sed1.flux) != np.sum(sed2.flux):
            print("No Problem!")
            plt.subplot(222)
@@ -327,11 +327,11 @@ class test_spec1d(unittest.TestCase):
        print("1. 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,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        print("2. 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,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        if np.sum(sed1.flux) != np.sum(sed2.flux):
            print("No Problem!")
            plt.subplot(223)
@@ -345,11 +345,11 @@ class test_spec1d(unittest.TestCase):
        print("1. E(B-V)=0.1")
        sed1 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 20000, zh = 0, ebv = 0.1, dist = 20)
                     vel = 20000, logz = 0, ebv = 0.1, dist = 20)
        print("2. E(B-V)=0.3")
        sed2 = s.AGN(inst, temp, bhmass = 1e5, edd_ratio = 0.05,
                     halpha_broad = 100, halpha_narrow = 100, vdisp_broad = 2000, vdisp_narrow = 500,
                     vel = 20000, zh = 0, ebv = 0.3, dist = 20)  
                     vel = 20000, logz = 0, ebv = 0.3, dist = 20)  
        if np.sum(sed1.flux) != np.sum(sed2.flux):
            print("No Problem!")
            plt.subplot(224)