diff --git a/csst_ifs_gehong/map2d.py b/csst_ifs_gehong/map2d.py index 379bd0ef9670f173627caead6e23ed0f8d146979..24c328bfce3c26ed9643635482ba46b7791ee8d7 100644 --- a/csst_ifs_gehong/map2d.py +++ b/csst_ifs_gehong/map2d.py @@ -268,13 +268,14 @@ class Map2d(object): # Check Input Parameters if (vmax <= 0): - print("Notice: Your input maximum rotational velocity (vmax) is <= 0 km/s!") + #print("Notice: Your input maximum rotational velocity (vmax) is <= 0 km/s!") + raise Exception("Maximum rotational velocity (vmax) should be >0 km/s!") if (rt <= 0): #raise Exception("Turn-over radius (rt) should be > 0 arcsec!") - print("Turn-over radius (rt) should be > 0 arcsec!") - if (ellip >= 1) or (ellip < 0): - #raise Exception("Ellipcity (ellip) should be >= 0 and < 1!") - print("Ellipcity (ellip) should be >= 0 and < 1!") + raise Exception("Turn-over radius (rt) should be > 0 arcsec!") + if (ellip > 1) or (ellip < 0): + raise Exception("Ellipcity (ellip) should be >= 0 and < 1!") + #print("Ellipcity (ellip) should be >= 0 and < 1!") if (theta > 180) or (theta < -180): print("Notice: Your input position angle (theta) is > 180 degree or < -180 degree.") @@ -304,8 +305,8 @@ class Map2d(object): """ # Check Input Parameters if (r_eff <= 0): - #raise Exception("Effective radius (r_eff) should be > 0 arcsec!") - print("Effective radius (r_eff) should be > 0 arcsec!") + raise Exception("Effective radius (r_eff) should be > 0 arcsec!") + #print("Effective radius (r_eff) should be > 0 arcsec!") if (ellip > 1) or (ellip < 0): #raise Exception("Ellipcity (ellip) should be >= 0 and < 1!") print("Notice: Ellipcity (ellip) should be >= 0 and < 1!") @@ -331,6 +332,8 @@ class Map2d(object): """ if np.ndim(image) == 2: self.map = resize(image, (self.nx, self.ny)) + else: + print("Input array should be a 2d-array!") class StellarPopulationMap(): """ @@ -364,26 +367,45 @@ class StellarPopulationMap(): self.fov_x = config.fov_x self.fov_y = config.fov_y - self.sbright = sbright.map - self.logage = logage.map - self.feh = feh.map - self.vel = vel.map - self.vdisp = vdisp.map - self.ebv = ebv.map + if (sbright == None): + print('Input SurfaceBrightness Map is empty!') + else: + self.sbright = sbright.map + self.mag = self.sbright - 2.5 * np.log10(self.dpix * self.dpix) - self.mag = self.sbright - 2.5 * np.log10(self.dpix * self.dpix) - self.age = 10 ** self.logage / 1e9 + if (logage == None): + print('Input Age Map is empty!') + else: + self.logage = logage.map + self.age = 10 ** self.logage / 1e9 - # Check Input Maps - ind_overrange = (self.vdisp < 10) - if len(self.vdisp[ind_overrange]) > 0: - print("Notice: Spaxel with <10km/s in the input vdisp map will be automatically adjusted to 10km/s.") - self.vdisp[ind_overrange] = 10 - - ind_overrange = (self.ebv < 0) - if len(self.ebv[ind_overrange]) > 0: - print("Notice: Spaxel with < 0 mag in the input ebv map will be automatically adjusted to 0 mag.") - self.ebv[ind_overrange] = 0 + if (feh == None): + print('Input Metallicity Map is empty!') + else: + self.feh = feh.map + + if (vel == None): + print('Input Velocity Map is empty!') + else: + self.vel = vel.map + + if (vdisp == None): + print('Input VelocityDispersion Map is empty!') + else: + self.vdisp = vdisp.map + ind_overrange = (self.vdisp < 10) + if len(self.vdisp[ind_overrange]) > 0: + print("Notice: Spaxel with <10km/s in the input vdisp map will be automatically adjusted to 10km/s.") + self.vdisp[ind_overrange] = 10 + + if (ebv == None): + print('Input EBV Map is empty!') + else: + self.ebv = ebv.map + ind_overrange = (self.ebv < 0) + if len(self.ebv[ind_overrange]) > 0: + print("Notice: Spaxel with < 0 mag in the input ebv map will be automatically adjusted to 0 mag.") + self.ebv[ind_overrange] = 0 class IonizedGasMap(): """ @@ -407,29 +429,42 @@ class IonizedGasMap(): Class of the map of dust extinction, by default None """ def __init__(self, config, halpha = None, zh = None, vel = None, vdisp = None, ebv = None): - + self.nx = config.nx self.ny = config.ny self.dpix = config.dpix self.fov_x = config.fov_x self.fov_y = config.fov_y - self.halpha = halpha.map - self.zh = zh.map - self.vel = vel.map - self.vdisp = vdisp.map - self.ebv = ebv.map - - #self.vdisp[self.vdisp < 10] = 10 - #self.ebv[self.ebv < 0] = 0 - - # Check Input Maps - ind_overrange = (self.vdisp < 10) - if len(self.vdisp[ind_overrange]) > 0: - print("Notice: Spaxel with <10km/s in the input vdisp map will be automatically adjusted to 10km/s.") - self.vdisp[ind_overrange] = 10 - - ind_overrange = (self.ebv < 0) - if len(self.ebv[ind_overrange]) > 0: - print("Notice: Spaxel with < 0 mag in the input ebv map will be automatically adjusted to 0 mag.") - self.ebv[ind_overrange] = 0 \ No newline at end of file + if (halpha == None): + print('Input Halpha Map is empty!') + else: + self.halpha = halpha.map + + if (zh == None): + print('Input ZH Map is empty!') + else: + self.zh = zh.map + + if (vel == None): + print('Input Vel Map is empty!') + else: + self.vel = vel.map + + if (vdisp == None): + print('Input Vdisp Map is empty!') + ind_overrange = (self.vdisp < 10) + if len(self.vdisp[ind_overrange]) > 0: + print("Notice: Spaxel with <10km/s in the input vdisp map will be automatically adjusted to 10km/s.") + self.vdisp[ind_overrange] = 10 + else: + self.vdisp = vdisp.map + + if (ebv == None): + print('Input EBV Map is empty!') + else: + self.ebv = ebv.map + ind_overrange = (self.ebv < 0) + if len(self.ebv[ind_overrange]) > 0: + print("Notice: Spaxel with < 0 mag in the input ebv map will be automatically adjusted to 0 mag.") + self.ebv[ind_overrange] = 0 \ No newline at end of file diff --git a/csst_ifs_gehong/spec1d.py b/csst_ifs_gehong/spec1d.py index 677e561efada5647d24ba2a93eed21f27d977d9c..83f42985c5dcecb518a8af35b53575e1d7411fc7 100644 --- a/csst_ifs_gehong/spec1d.py +++ b/csst_ifs_gehong/spec1d.py @@ -386,7 +386,7 @@ class HII_Region(): # Check Input Parameters #if (halpha < 0): # print("Notice: Your input Halpha flux (halpha) is < 0 erg/s/A/cm^2. ") - if (logz > -2) & (logz < 0.5): + if (logz >= -2) & (logz <= 0.5): indz = np.argmin(np.abs(logz - temp.logz_grid)) flux_ratio = temp.flux_ratio[indz, :] else: @@ -1003,7 +1003,8 @@ class StellarContinuum(): else: if sigma_gal < 0: print('Notice: Your input velocity dispersion (vdisp) is < 0 km/s, which will be automatically adjusted to 0 km/s. ') - + flux0 = Stellar + # Dust Reddening if np.isscalar(ebv): flux0 = reddening(wave, flux0, ebv = ebv) @@ -1119,10 +1120,10 @@ class SingleStar(): print("Notice: Your input magnitude (mag) is > 26 mag or < 8 mag.") if (teff < 2820) or (teff > 20129): print("Notice: Your input effective tempreture (teff) is beyond the range of stellar template [2820, 20129], which will be automatically adjusted to the upper/lower limit.") - if (feh > 0.81): + if (feh > 0.81) or (feh < -2.69): print("Notice: Your input metallicity (feh) is beyond the range of stellar template [-2.69, 0.81], which will be automatically adjusted to the upper limit.") - if (feh < -2.69): - raise Exception('Your input metallicity (feh) is beyond the range of stellar template [-2.69, 0.81]') + #if (feh < -2.69): + # raise Exception('Your input metallicity (feh) is beyond the range of stellar template [-2.69, 0.81]') StarTemp = template.templates