Commit 251af67c authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent cf7c5c51
Pipeline #7616 failed with stage
in 0 seconds
...@@ -1405,7 +1405,7 @@ class MCIsimulator(): ...@@ -1405,7 +1405,7 @@ class MCIsimulator():
self.log.error( self.log.error(
'Error,no ra data in the star_cat catlog file ') 'Error,no ra data in the star_cat catlog file ')
raise ValueError( raise ValueError(
'Error,no ra data in the star_cat catlog file ') 'Error,no ra data in the star_cat catlog file ')
# #
try: try:
df2['dec_gaia'][10] df2['dec_gaia'][10]
...@@ -1413,13 +1413,13 @@ class MCIsimulator(): ...@@ -1413,13 +1413,13 @@ class MCIsimulator():
self.log.error( self.log.error(
'Error,no dec data in the star_cat catlog file ') 'Error,no dec data in the star_cat catlog file ')
raise ValueError( raise ValueError(
'Error,no dec data in the star_cat catlog file ') 'Error,no dec data in the star_cat catlog file ')
# #
if df2['ra_gaia'].max() > 360 or df2['ra_gaia'].min() < 0 or df2['dec_gaia'].max() > 90 or df2['dec_gaia'].min() < -90: if df2['ra_gaia'].max() > 360 or df2['ra_gaia'].min() < 0 or df2['dec_gaia'].max() > 90 or df2['dec_gaia'].min() < -90:
self.log.error( self.log.error(
'ra or dec data beyond definition,please check!') 'ra or dec data beyond definition,please check!')
raise ValueError( raise ValueError(
'ra or dec data beyond definition,please check!') 'ra or dec data beyond definition,please check!')
# #
df3 = df2[(abs(df2['ra_gaia']-df2['ra_gaia'].mean()) < 400/3600.0) df3 = df2[(abs(df2['ra_gaia']-df2['ra_gaia'].mean()) < 400/3600.0)
& (abs(df2['dec_gaia']-df2['dec_gaia'].mean()) < 400/3600.0)] & (abs(df2['dec_gaia']-df2['dec_gaia'].mean()) < 400/3600.0)]
...@@ -1447,27 +1447,25 @@ class MCIsimulator(): ...@@ -1447,27 +1447,25 @@ class MCIsimulator():
self.star = df0[1].data self.star = df0[1].data
### ###
try: if 'ra' not in self.star.names:
self.star['ra'][10] print('no ra')
except NameError:
self.log.error( self.log.error(
'Error,no ra data in the star_cat catlog file ') 'Error,no ra data in the star_cat catlog file ')
raise ValueError( raise ValueError(
'Error,no ra data in the star_cat catlog file ') 'Error,no ra data in the star_cat catlog file ')
# #
try: if 'dec' not in self.star.names:
self.star['dec'][10] print('no ra')
except NameError:
self.log.error( self.log.error(
'Error,no dec data in the star_cat catlog file ') 'Error,no dec data in the star_cat catlog file ')
raise ValueError( raise ValueError(
'Error,no dec data in the star_cat catlog file ') 'Error,no dec data in the star_cat catlog file ')
if self.star['ra'].max() > 360 or self.star['ra'].min() < 0 or self.star['dec'].max() > 90 or self.star['dec'].min() < -90: if self.star['ra'].max() > 360 or self.star['ra'].min() < 0 or self.star['dec'].max() > 90 or self.star['dec'].min() < -90:
self.log.error( self.log.error(
'ra or dec data beyond definition,please check!') 'ra or dec data beyond definition,please check!')
raise ValueError( raise ValueError(
'ra or dec data beyond definition,please check!') 'ra or dec data beyond definition,please check!')
self.information['ra_obj'] = self.star['ra'].mean() self.information['ra_obj'] = self.star['ra'].mean()
self.information['dec_obj'] = self.star['dec'].mean() self.information['dec_obj'] = self.star['dec'].mean()
...@@ -1853,10 +1851,10 @@ class MCIsimulator(): ...@@ -1853,10 +1851,10 @@ class MCIsimulator():
imag = self.star['imag'][j] imag = self.star['imag'][j]
zmag = self.star['zmag'][j] zmag = self.star['zmag'][j]
flag = (umag > 0 and gmag > 0 and rmag > # if j==426:
0 and imag > 0 and zmag > 0) # print('debug error')
if flag is False: if np.isnan(umag) or np.isnan(gmag) or np.isnan(rmag) or np.isnan(imag) or np.isnan(zmag):
continue continue
wave = np.linspace(2500, 11000, 8501) wave = np.linspace(2500, 11000, 8501)
...@@ -1864,7 +1862,7 @@ class MCIsimulator(): ...@@ -1864,7 +1862,7 @@ class MCIsimulator():
redshift = 0 redshift = 0
# Loading galaxy SED template # Loading galaxy SED template
t = sed.Gal_Temp(self.information['dir_path']) t = sed.Gal_Temp(self.log, self.information['dir_path'])
# Calculating the magnitude (u, g, r, i, z) of each template # Calculating the magnitude (u, g, r, i, z) of each template
t.toMag(redshift=redshift) t.toMag(redshift=redshift)
# Calculating flux # Calculating flux
...@@ -2376,6 +2374,13 @@ class MCIsimulator(): ...@@ -2376,6 +2374,13 @@ class MCIsimulator():
srcs_sed = fits.open(filename) srcs_sed = fits.open(filename)
self.log.info('galaxy_Input SED path is: %s' % (filename)) self.log.info('galaxy_Input SED path is: %s' % (filename))
#
if len(srcs_cat) != len(srcs_sed):
#
self.log.error(
'Error,image data do not mach sed data in the input galaxy data file ')
raise ValueError(
'Error,image data do not mach sed data in the input galaxy data file ')
# ##### do Tiance Effect ### # ##### do Tiance Effect ###
ra_list = [] ra_list = []
...@@ -2390,7 +2395,7 @@ class MCIsimulator(): ...@@ -2390,7 +2395,7 @@ class MCIsimulator():
self.log.error( self.log.error(
'Error,no ra data in the input galaxy data file ') 'Error,no ra data in the input galaxy data file ')
raise ValueError( raise ValueError(
'Error,no ra data in the input galaxy data file ') 'Error,no ra data in the input galaxy data file ')
# #
try: try:
srcs_cat[kkk].header['new_dec'] srcs_cat[kkk].header['new_dec']
...@@ -2398,13 +2403,13 @@ class MCIsimulator(): ...@@ -2398,13 +2403,13 @@ class MCIsimulator():
self.log.error( self.log.error(
'Error,no dec data in the input galaxy data file ') 'Error,no dec data in the input galaxy data file ')
raise ValueError( raise ValueError(
'Error,no dec data in the input galaxy data file ') 'Error,no dec data in the input galaxy data file ')
if srcs_cat[kkk].header['new_ra'] > 360 or srcs_cat[kkk].header['new_ra'] < 0 or srcs_cat[kkk].header['new_dec'] > 90 or srcs_cat[kkk].header['new_dec'] < -90: if srcs_cat[kkk].header['new_ra'] > 360 or srcs_cat[kkk].header['new_ra'] < 0 or srcs_cat[kkk].header['new_dec'] > 90 or srcs_cat[kkk].header['new_dec'] < -90:
self.log.error( self.log.error(
'Gal ra or dec data beyond definition, please check!') 'Gal ra or dec data beyond definition, please check!')
raise ValueError( raise ValueError(
'Gal ra or dec data beyond definition, please check!') 'Gal ra or dec data beyond definition, please check!')
# #
t1 = srcs_cat[kkk].header['new_ra'] - \ t1 = srcs_cat[kkk].header['new_ra'] - \
self.information['gal_ra'] + self.information['star_ra'] self.information['gal_ra'] + self.information['star_ra']
...@@ -2460,13 +2465,13 @@ class MCIsimulator(): ...@@ -2460,13 +2465,13 @@ class MCIsimulator():
self.log.error( self.log.error(
'Galaxy SED data error, please check!') 'Galaxy SED data error, please check!')
raise ValueError( raise ValueError(
'Galaxy SED data error, please check!') 'Galaxy SED data error, please check!')
# #
if srcs_cat[k1+1].data.min() < 0 or srcs_cat[k1+1].data.max == 0 or srcs_cat[k1+1].data.ndim != 2: if srcs_cat[k1+1].data.min() < 0 or srcs_cat[k1+1].data.max == 0 or srcs_cat[k1+1].data.ndim != 2:
self.log.error( self.log.error(
'Galaxy image data error, please check!') 'Galaxy image data error, please check!')
raise ValueError( raise ValueError(
'Galaxy image data error, please check!') 'Galaxy image data error, please check!')
# #
################################ ################################
# ## rotate the lensed_images_g ### # ## rotate the lensed_images_g ###
...@@ -3887,7 +3892,8 @@ class MCIsimulator(): ...@@ -3887,7 +3892,8 @@ class MCIsimulator():
hdu_g.header['RADECSYS'] = ( hdu_g.header['RADECSYS'] = (
'ICRS', 'coordinate system of the object') 'ICRS', 'coordinate system of the object')
hdu_g.header['EQUINOX'] = (float(2000.1), '') hdu_g.header['EQUINOX'] = (float(2000.1), '')
hdu_g.header['FITSSWV'] = ('csst_mci_sim_3.0.0', 'FITS creating software version') hdu_g.header['FITSSWV'] = (
'csst_mci_sim_3.0.0', 'FITS creating software version')
######################################## ########################################
...@@ -4438,7 +4444,8 @@ class MCIsimulator(): ...@@ -4438,7 +4444,8 @@ class MCIsimulator():
hdu_r.header['RADECSYS'] = ( hdu_r.header['RADECSYS'] = (
'ICRS', 'coordinate system of the object') 'ICRS', 'coordinate system of the object')
hdu_r.header['EQUINOX'] = (float(2000.1), '') hdu_r.header['EQUINOX'] = (float(2000.1), '')
hdu_r.header['FITSSWV'] = ('csst_mci_sim_3.0.0', 'FITS creating software version') hdu_r.header['FITSSWV'] = (
'csst_mci_sim_3.0.0', 'FITS creating software version')
######################################## ########################################
...@@ -4989,7 +4996,8 @@ class MCIsimulator(): ...@@ -4989,7 +4996,8 @@ class MCIsimulator():
hdu_i.header['RADECSYS'] = ( hdu_i.header['RADECSYS'] = (
'ICRS', 'coordinate system of the object') 'ICRS', 'coordinate system of the object')
hdu_i.header['EQUINOX'] = (float(2000.1), '') hdu_i.header['EQUINOX'] = (float(2000.1), '')
hdu_i.header['FITSSWV'] = ('csst_mci_sim_3.0.0', 'FITS creating software version') hdu_i.header['FITSSWV'] = (
'csst_mci_sim_3.0.0', 'FITS creating software version')
######################################## ########################################
...@@ -5762,7 +5770,7 @@ class MCIsimulator(): ...@@ -5762,7 +5770,7 @@ class MCIsimulator():
if self.cosmicRays: if self.cosmicRays:
self.addCosmicRays() self.addCosmicRays()
print('addCosmicRays finisth') print('addCosmicRays finished')
################################################## ##################################################
if self.skyback: if self.skyback:
...@@ -5773,7 +5781,7 @@ class MCIsimulator(): ...@@ -5773,7 +5781,7 @@ class MCIsimulator():
if self.darknoise: if self.darknoise:
self.applyDarkCurrent() self.applyDarkCurrent()
print('applyDarkCurrent finisth') print('applyDarkCurrent finished')
################################################# #################################################
...@@ -5788,7 +5796,7 @@ class MCIsimulator(): ...@@ -5788,7 +5796,7 @@ class MCIsimulator():
self.image_g = self.applyBleeding(self.image_g.copy()) self.image_g = self.applyBleeding(self.image_g.copy())
self.image_r = self.applyBleeding(self.image_r.copy()) self.image_r = self.applyBleeding(self.image_r.copy())
self.image_i = self.applyBleeding(self.image_i.copy()) self.image_i = self.applyBleeding(self.image_i.copy())
print('apply bleeding effect finisth') print('apply bleeding effect finished')
################################################ ################################################
...@@ -5828,13 +5836,13 @@ class MCIsimulator(): ...@@ -5828,13 +5836,13 @@ class MCIsimulator():
self.image_g = self.image_g/1.0 self.image_g = self.image_g/1.0
self.image_r = self.image_r/1.0 self.image_r = self.image_r/1.0
self.image_i = self.image_i/1.0 self.image_i = self.image_i/1.0
print('apply gain finish') print('apply gain finished')
###################################################################### ######################################################################
# size of the output image array, xsize is column, ysize is row, xsize = 9216,ysize = 9232 # size of the output image array, xsize is column, ysize is row, xsize = 9216,ysize = 9232
if self.information['xsize'] == 9216 and self.information['ysize'] == 9232 and self.overscans: if self.information['xsize'] == 9216 and self.information['ysize'] == 9232 and self.overscans:
self.applyBias() self.applyBias()
print('apply bias finish') print('apply bias finished')
else: else:
self.image_g = self.image_g+500.0 self.image_g = self.image_g+500.0
self.image_r = self.image_r+500.0 self.image_r = self.image_r+500.0
......
...@@ -126,7 +126,7 @@ class Gal_Temp(): ...@@ -126,7 +126,7 @@ class Gal_Temp():
Template of Galaxy SED Template of Galaxy SED
""" """
def __init__(self, path): def __init__(self, log, path):
# #
...@@ -134,6 +134,13 @@ class Gal_Temp(): ...@@ -134,6 +134,13 @@ class Gal_Temp():
self.path = path self.path = path
hdulist = fits.open( hdulist = fits.open(
self.path+'MCI_inputData/SED_Code/seddata/galaxy_temp.fits') self.path+'MCI_inputData/SED_Code/seddata/galaxy_temp.fits')
if len(hdulist) < 4:
log.error(
'Data error in galaxy_temp.fits file, please check!!!')
raise ValueError(
'Data error in galaxy_temp.fits file, please check!!!')
self.wave = hdulist[1].data['wave'] self.wave = hdulist[1].data['wave']
self.flux = hdulist[2].data self.flux = hdulist[2].data
self.age_grid = hdulist[3].data['logAge'] self.age_grid = hdulist[3].data['logAge']
...@@ -141,7 +148,6 @@ class Gal_Temp(): ...@@ -141,7 +148,6 @@ class Gal_Temp():
def toMag(self, redshift=0): def toMag(self, redshift=0):
"""Calculating magnitude """Calculating magnitude
Args: Args:
redshift (float, optional): redshift of spectra. Defaults to 0. redshift (float, optional): redshift of spectra. Defaults to 0.
""" """
...@@ -165,13 +171,14 @@ class Star_Temp(): ...@@ -165,13 +171,14 @@ class Star_Temp():
# parent = os.path.dirname(os.path.realpath(__file__)) # parent = os.path.dirname(os.path.realpath(__file__))
# print("获取其父目录——" + parent) # 从当前文件路径中获取目录 # print("获取其父目录——" + parent) # 从当前文件路径中获取目录
hdulist = fits.open( hdulist = fits.open(
os.path.join(path, 'MCI_inputData/SED_Code/seddata/stellar_temp.fits')) os.path.join(path, 'MCI_inputData/SED_Code/seddata/stellar_temp_wrong.fits'))
if hdulist[1].data['wave'] == [] or hdulist[2].data == [] or hdulist[3].data['Teff'] == [] or hdulist[3].data['FeH'] == []: if len(hdulist) < 4:
self.log.error( self.log.error(
'Data error in tellar_temp.fits file, please check!!!') 'Data error in galaxy_temp.fits file, please check!!!')
raise ValueError( raise ValueError(
'Data error in tellar_temp.fits file, please check!!!') 'Data error in galaxy_temp.fits file, please check!!!')
self.wave = hdulist[1].data['wave'] self.wave = hdulist[1].data['wave']
self.flux = hdulist[2].data self.flux = hdulist[2].data
......
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