def to_mags_old(self, b, z=0., d=None, magnification=1.): from pystella.rf.star import Star from pystella.rf import band # from pystella.rf.lc import LightCurve, SetLightCurve if b is None: raise ValueError("Band must be defined.") if not self.is_time: return ValueError("No spectral time points.") # mags = np.zeros(len(self.Time)) times = [] mags = [] for k, t in enumerate(self.Time): try: star = Star(k, self.get_spec(k), is_flux_eq_luminosity=True) star.set_distance(d) star.set_redshift(z) star.set_magnification(magnification) # mag = star.flux_to_mag(b) if b.Name == band.Band.NameBol: mag = star.magBol(b) else: mag = star.magAB(b) times.append(t) mags.append(mag) except ValueError as ex: logger.error("Could not compute mag {} for band {} at {} due to {}.". format(self.Name, b.Name, t, ex)) return times, mags
def to_mag(self, b, z=0., d=phys.pc2cm(10.), magnification=1.): """ Compute the magnitude for the band :param b: photometric band :param z: redshift, default: 0 :param d: distance [cm], default: 10 pc :param magnification: , default: 1 :return: """ if b is None: raise ValueError("Band must be defined.") from pystella.rf.star import Star from pystella.rf import band star = Star('', self, is_flux_eq_luminosity=True) star.set_distance(d) star.set_redshift(z) star.set_magnification(magnification) # mag = star.flux_to_mag(b) if b.Name in [band.Band.NameBol, band.Band.NameBolQuasi, band.Band.NameUBVRI]: mag = star.magBol(b) else: mag = star.magAB(b) return mag
def flux_to_mags(self, b, z=0., d=0., magnification=1.): from pystella.rf.star import Star if b is None: raise ValueError("Band must be defined.") if not self.is_time: return ValueError("No spectral time points.") mags = np.zeros(len(self.Time)) for k, t in enumerate(self.Time): star = Star(k, self.get_spec(k)) star.set_distance(d) star.set_redshift(z) star.set_magnification(magnification) # mag = star.flux_to_mag(b) mag = star.magAB(b) mags[k] = mag # if self.times[k] > 50: # spec.plot_spec(title="t=%f, mag=%f" % (self.times[k], mag)) return mags