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
sys.path.insert(0, '..')
import unittest
from csst_ifs_gehong import spec1d as s
from csst_ifs_gehong import map2d as m
from csst_ifs_gehong import cube3d as b
from csst_ifs_gehong import config as c
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):
......@@ -25,7 +27,7 @@ class test_cube3d(unittest.TestCase):
print(" ")
inst = c.config()
gas_tem = s.EmissionLineTemplate(inst, model = 'hii')
gas_tem = s.EmissionLineTemplate(inst, model='hii')
stellar_tem = s.StellarContinuumTemplate(inst)
sbmap = m.Map2d(inst)
......@@ -35,14 +37,14 @@ class test_cube3d(unittest.TestCase):
vdispmap = m.Map2d(inst)
vdispmap.gred_map()
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.gred_map(a0 = -0.2, gred = -0.1)
fehmap.gred_map(a0=-0.2, gred=-0.1)
ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1)
stellarcontinuum = m.StellarPopulationMap(inst, sbright = sbmap, logage = agemap,
feh = fehmap, vel = velmap,
vdisp = vdispmap, ebv = ebvmap)
ebvmap.gred_map(a0=0.2, gred=-0.1)
stellarcontinuum = m.StellarPopulationMap(inst, sbright=sbmap, logage=agemap,
feh=fehmap, vel=velmap,
vdisp=vdispmap, ebv=ebvmap)
sbmap = m.Map2d(inst)
sbmap.sersic_map()
......@@ -51,32 +53,33 @@ class test_cube3d(unittest.TestCase):
vdispmap = m.Map2d(inst)
vdispmap.gred_map()
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.gred_map(a0 = -0.2, gred = -0.1)
fehmap.gred_map(a0=-0.2, gred=-0.1)
ebvmap = m.Map2d(inst)
ebvmap.gred_map(a0 = 0.2, gred = -0.1)
ionizedgas = m.IonizedGasMap(inst, halpha = agemap, zh = fehmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap)
ebvmap.gred_map(a0=0.2, gred=-0.1)
ionizedgas = m.IonizedGasMap(inst, halpha=agemap, zh=fehmap,
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')
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!")
#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[5,95,:]),color='red',label=r'$v=%4.2f$'%(velmap.map[5,95]))
#plt.xlim(3500,9500)
#plt.legend(frameon=False)
#plt.savefig('./image/test_cube3d_spec.png')
# 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[5,95,:]),color='red',label=r'$v=%4.2f$'%(velmap.map[5,95]))
# plt.xlim(3500,9500)
# plt.legend(frameon=False)
# plt.savefig('./image/test_cube3d_spec.png')
print("-----------------------------------------------------------------")
print(">>> Unit test for **Spec Cube** Modelling has been passed!")
if __name__=='__main__':
if __name__ == '__main__':
unittest.main()
import sys
sys.path.insert(0, '..')
import unittest
from csst_ifs_gehong import map2d as m
from csst_ifs_gehong import config as c
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):
......@@ -22,44 +23,44 @@ class test_map2d(unittest.TestCase):
print(" ")
print("Pars: Total Magnitude")
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.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):
print("No Problem!")
print("Pars: Effective Radius")
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):
print("No Problem!")
print("Pars: Sersic Index")
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):
print("No Problem!")
print("Pars: Ellipse")
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):
print("No Problem!")
print("Pars: Position Angle")
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):
print("No Problem!")
#plt.figure(figsize=(6,5))
#plt.imshow(sbmap0.map, origin='lower', cmap='gray_r')
#plt.xticks([])
#plt.yticks([])
#plt.title('Surface Brightness Modelling')
#plt.colorbar(label='mag')
#plt.tight_layout()
#plt.savefig('./image/test_map2d_SBmap.png')
# plt.figure(figsize=(6,5))
# plt.imshow(sbmap0.map, origin='lower', cmap='gray_r')
# plt.xticks([])
# plt.yticks([])
# plt.title('Surface Brightness Modelling')
# plt.colorbar(label='mag')
# plt.tight_layout()
# plt.savefig('./image/test_map2d_SBmap.png')
def test_velmap(self):
......@@ -69,38 +70,38 @@ class test_map2d(unittest.TestCase):
print(" ")
print("Pars: Rotation Velocity")
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.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):
print("No Problem!")
print("Pars: Turnover Radius")
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):
print("No Problem!")
print("Pars: Inclination Angle")
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):
print("No Problem!")
print("Pars: Position Angle")
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):
print("No Problem!")
#plt.figure(figsize=(6,5))
#plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
#plt.xticks([])
#plt.yticks([])
#plt.title('Velocity Map Modelling')
#plt.colorbar(label='km/s')
#plt.tight_layout()
#plt.savefig('./image/test_map2d_velmap.png')
# plt.figure(figsize=(6,5))
# plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
# plt.xticks([])
# plt.yticks([])
# plt.title('Velocity Map Modelling')
# plt.colorbar(label='km/s')
# plt.tight_layout()
# plt.savefig('./image/test_map2d_velmap.png')
def test_gremap(self):
......@@ -110,44 +111,44 @@ class test_map2d(unittest.TestCase):
print(" ")
print("Pars: Central Intensity")
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.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):
print("No Problem!")
print("Pars: Effective Radius")
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):
print("No Problem!")
print("Pars: Grediant")
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):
print("No Problem!")
print("Pars: Inclination Angle")
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):
print("No Problem!")
print("Pars: Position Angle")
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):
print("No Problem!")
#plt.figure(figsize=(6,5))
#plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
#plt.xticks([])
#plt.yticks([])
#plt.title('Gredient Map Modelling')
#plt.colorbar(label='')
#plt.tight_layout()
#plt.savefig('./image/test_map2d_gredmap.png')
# plt.figure(figsize=(6,5))
# plt.imshow(velmap0.map, origin='lower', cmap='RdBu_r')
# plt.xticks([])
# plt.yticks([])
# plt.title('Gredient Map Modelling')
# plt.colorbar(label='')
# plt.tight_layout()
# plt.savefig('./image/test_map2d_gredmap.png')
def test_input_image(self):
......@@ -156,7 +157,7 @@ class test_map2d(unittest.TestCase):
print("------------------------ Feed Image------------------------")
print(" ")
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.load_map(velmap0.map)
if np.sum(velmap1.map) == np.sum(velmap0.map):
......@@ -176,17 +177,17 @@ class test_map2d(unittest.TestCase):
vdispmap.gred_map()
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.gred_map(a0 = -0.2, gred = -0.1)
fehmap.gred_map(a0=-0.2, gred=-0.1)
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,
vel=velmap, vdisp=vdispmap, ebv=ebvmap)
stellarcontinuum = m.StellarPopulationMap(inst, sbright = sbmap, logage = agemap, feh = fehmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap)
if np.sum(stellarcontinuum.sbright) == np.sum(sbmap.map):
print("SBmap No Problem!")
if np.sum(stellarcontinuum.age) == np.sum(agemap.map):
......@@ -214,14 +215,14 @@ class test_map2d(unittest.TestCase):
vdispmap.gred_map()
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.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,
vel=velmap, vdisp=vdispmap, ebv=ebvmap)
gas = m.IonizedGasMap(inst, halpha = halphamap, zh = logohmap,
vel = velmap, vdisp = vdispmap, ebv = ebvmap)
if np.sum(gas.halpha) == np.sum(halphamap.map):
print("Halphamap No Problem!")
if np.sum(gas.zh) == np.sum(logohmap.map):
......@@ -233,5 +234,6 @@ class test_map2d(unittest.TestCase):
if np.sum(gas.ebv) == np.sum(ebvmap.map):
print("SBmap No Problem!")
if __name__=='__main__':
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
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