def test_aliases(self): bo = band.band_by_name("BesU") ba = band.band_by_name("U") self.assertTrue(ba.is_chem_load, "The band should be loaded and with data") self.assertItemsEqual(expected_seq=bo.wl, actual_seq=ba.wl, msg="The alias wl should be the same as original") self.assertItemsEqual(expected_seq=bo.resp_wl, actual_seq=ba.resp_wl, msg="The alias wl should be the same as original")
def test_spec_kcorr_zplot(self): import matplotlib.pyplot as plt nf, start, end = 100, 10., 1e5 wl = np.exp(np.linspace(np.log(end), np.log(start), nf)) freq = rf.val_to_hz(wl, inp="A") Tcolor = 7.e3 sp = spectrum.SpectrumPlanck(freq, Tcolor, 'test') bn_rest = 'B' bn_obs = bn_rest br = band_by_name(bn_rest) bo = band_by_name(bn_obs) z_arr = np.linspace(0, 0.3, 33) kcoors = [] for z in z_arr: k = kcorrection_spec(sp, z, br, bo) kcoors.append(k) fig, ax = plt.subplots(figsize=(4, 16)) ax.plot(z_arr, kcoors, marker='o', ls='', markersize=3) # ax.set_ylim(-0., .3) ax.grid() ax.set_title("{} band, Tcol= {:.0f} K".format(bn_rest, Tcolor)) ax.set_xlabel('Redshift') ax.set_ylabel('k-correction') plt.show() fig.savefig('k-correction.pdf')
def test_spec_kcorr_with_curve(self): nf, start, end = 100, 10., 1e5 wl = np.exp(np.linspace(np.log(end), np.log(start), nf)) freq = rf.val_to_hz(wl, inp="A") Tcolor = 7e3 sp = spectrum.SpectrumPlanck(freq, Tcolor, 'test') z = 0.1 distance = 1e6 # phys.cosmology_D_by_z(z) bn_rest = 'g' # bn_obs = 'V' bn_obs = bn_rest br = band_by_name(bn_rest) bo = band_by_name(bn_obs) M_Q = sp.to_mag(br, z=0., d=phys.pc2cm(10.)) m_r = sp.to_mag(bo, z=z, d=phys.pc2cm(distance)) DM = phys.dist2MD(distance) K_QR = m_r - M_Q - DM kcorr = kcorrection_spec(sp, z, br, bo) print("{}: z= {} K_QR= {:.5f} kcorr= {:.5f}".format(bn_rest, z, K_QR, kcorr)) self.assertAlmostEqual(K_QR, kcorr, 8, "{}: For z={} kcorr should be like K_QR. But kcorr={:.5f} K_QR= {:.5f}.". format(bn_rest, z, kcorr, K_QR))
def test_aliases(self): bo = band.band_by_name("BesU") ba = band.band_by_name("U") self.assertTrue(ba.is_load, "The band should be loaded and with data") self.assertCountEqual( bo.wl, ba.wl, msg="The alias wl should be the same as original") self.assertCountEqual( bo.resp_wl, ba.resp_wl, msg="The alias wl should be the same as original")
def read_curves_kurtenkov(path=sn_path): jd = 2457000 lc_data = np.loadtxt(os.path.join(path, 'lrn_aa26564-15_p5.csv'), skiprows=2, usecols=(0, 1, 2, 3), dtype=[('JD', '<f4'), ('b', 'S1'), ('mag', '<f4'), ('err', '<f4')]) # mshift = 24.43 # Distance Module to M31 curves = SetLightCurve('Red Nova') bnames = np.unique(lc_data['b']) for i, n in enumerate(bnames): b = band.band_by_name(n) d = lc_data[lc_data['b'] == n, ] time = d['JD'] + jd mags = d['mag'] errs = d['err'] # filter bad values # is_good = mags < 30. # t = time[is_good] # mags = mags[is_good] # errs = errs[is_good] # add lc = LightCurve(b, time, mags, errs=errs) # lc.tshift = -tshift # lc.mshift = -mshift curves.add(lc) return curves
def read_curves_kurtenkov(path=sn_path): jd = 2457000 lc_data = np.loadtxt(os.path.join(path, 'lrn_aa26564-15_p5.csv'), skiprows=2, usecols=(0, 1, 2, 3), dtype=[('JD', '<f4'), ('b', '|S1'), ('mag', '<f4'), ('err', '<f4')]) # mshift = 24.43 # Distance Module to M31 curves = SetLightCurve('Red Nova') bnames = np.unique(lc_data['b']) for i, n in enumerate(bnames): b = band.band_by_name(n.decode("utf-8")) d = lc_data[lc_data['b'] == n, ] time = d['JD'] + jd mags = d['mag'] errs = d['err'] # filter bad values # is_good = mags < 30. # t = time[is_good] # mags = mags[is_good] # errs = errs[is_good] # add lc = LightCurve(b, time, mags, errs=errs) # lc.tshift = -tshift # lc.mshift = -mshift curves.add(lc) return curves
def test_wl_eff(self): # wl_eff = {'U': 3650, 'B': 4450, 'V': 5510, 'R': 6580, 'I': 8060} wl_eff = { 'u': 3560, 'g': 4830, 'r': 6260, 'i': 7670, 'z': 8890, 'U': 3600, 'B': 4380, 'V': 5450, 'R': 6410, 'I': 7980, 'J': 12200, 'H': 16300, 'K': 21900 } for bname, wl in wl_eff.items(): b = band.band_by_name(bname) res = b.wl_eff_angs print('{} {:.0f} VS {:.0f}'.format(bname, res, wl)) self.assertAlmostEqual( res, wl, delta=wl * 0.03, msg="The effective wavelength of band %s equals %f. " "Should be %f" % (b.Name, res, wl))
def flux_to_curves(self, bands, z=0., d=phys.pc2cm(10.), magnification=1.): """ :param bands: :param z: :param d: :param magnification: :return: """ from pystella.rf.lc import SetLightCurve from pystella.rf import band curves = SetLightCurve(self.Name) for bname in bands: if isinstance(bname, str): b = band.band_by_name(bname) else: b = bname try: lc = self.flux_to_curve(b, z=z, d=d, magnification=magnification) curves.add(lc) except ValueError as ex: logger.error("Could not compute light curve {} for band {} due to {}.". format(self.Name, bname, ex)) return curves
def mags_bands(self, bands, z=0., d=rf.pc_to_cm(10.), magnification=1.): mags = dict((k, None) for k in bands) for n in bands: b = band.band_by_name(n) mags[n] = self.flux_to_mags(b, z=z, d=d, magnification=magnification) mags['time'] = self.Time * (1. + z) return mags
def test_zero_point(self): zp = 0.748 # See filters.ini b = band.band_by_name('U') self.assertAlmostEqual( b.zp, zp, msg="Zero points of band %s equals %f. Should be %f" % (b.Name, b.zp, zp))
def test_available_bands(self): bands = ['U', 'B', 'V', 'R', "I"] for n in bands: b = band.band_by_name(n) self.assertTrue(b is not None, "Band %s does not exist." % b) bands = ['g', 'i', 'r', 'u', "z"] for n in bands: b = band.band_by_name(n) self.assertTrue(b is not None, "Band %s does not exist." % b) bands4 = dict(UVM2="photonUVM2.dat", UVW1="photonUVW1.dat", UVW2="photonUVW2.dat", SwiftU="photonU_Swift.dat", SwiftB="photonB_Swift.dat", SwiftV="photonV_Swift.dat") bands = ['SwiftU', 'SwiftB', 'SwiftV', 'UVM2', "UVW1", "UVW2"] for n in bands: b = band.band_by_name(n) self.assertTrue(b is not None, "Band %s does not exist." % n)
def test_spec_kcorr_positive(self): nf = 300 start, end = 100., 1e5 wl = np.exp(np.linspace(np.log(end), np.log(start), nf)) freq = rf.val_to_hz(wl, inp="A") Tcolor = 7e3 sp = spectrum.SpectrumPlanck(freq, Tcolor, 'test') z = 0.1 for bn_rest in ['U', 'B', 'V', 'R', 'u', 'g', 'r']: bn_obs = bn_rest br = band_by_name(bn_rest) bo = band_by_name(bn_obs) kcorr = kcorrection_spec(sp, z, br, bo) print('{}: z= {} kcorr= {}'.format(bn_rest, z, kcorr)) self.assertGreater(kcorr, 0., "{}: For z={} kcorr should be > 0. But kcorr={:.5f}.". format(bn_rest, z, kcorr))
def test_band_zp_vs_Jy(self): bands = band.band_load_names() for bname in bands: b = band.band_by_name(bname) if b.is_zp and b.is_Jy: m_ab = Flux2MagAB(b.Jy * phys.jy_to_erg) self.assertAlmostEqual(m_ab, b.zp, msg="Band [%s] zp and Jy should be coincide each other. " "zp=%f, m_zp(Jy) = %f, Jy = %f" % (b.name, b.zp, m_ab, b.Jy), delta=0.01)
def test_spec_kcorr_z0(self): nf, start, end = 100, 10., 1e5 wl = np.exp(np.linspace(np.log(end), np.log(start), nf)) freq = rf.val_to_hz(wl, inp="A") Tcolor = 7e3 sp = spectrum.SpectrumPlanck(freq, Tcolor, 'test') z = 0. bn_rest = 'V' # bn_obs = 'V' for bn_rest in ['U', 'B', 'V', 'R', 'g']: bn_obs = bn_rest br = band_by_name(bn_rest) bo = band_by_name(bn_obs) kcorr = kcorrection_spec(sp, z, br, bo) self.assertAlmostEqual(kcorr, 0., 8, "{}: For z={} kcorr should be 0. But kcorr={:.5f}.". format(bn_rest, z, kcorr))
def plot_UBVRI(): plt.title("UBVRI filter response") bands = dict(U="b", B="c", V="g", R="r", I="p") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_JHK(): plt.title("JHK filter response") bands = dict(J="b", H="c", K="r") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_Misc(): plt.title('The filter responses of the different sources') bands = dict(AtlasC="cyan", AtlasO="orange") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_SWIFT(): plt.title("SWIFT filter response") bands = dict(UVM2="m", UVW1="r", UVW2="b", SwiftU="k", SwiftB="c", SwiftV="g") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def read_curves_tt(self): block = self.read() header = 'Mbol MU MB MV MI MR'.split() curves = SetLightCurve(self.name) time = block['time'] for col in header: b = band.band_by_name(col.replace('M', '')) mag = block[col] lc = LightCurve(b, time, mag) curves.add(lc) return curves
def mags_bands(self, bands, z=0., d=phys.pc2cm(10.), magnification=1.): from pystella.rf import band mags = dict((k, None) for k in bands) for bn in bands: b = band.band_by_name(bn) times, m = self.to_mags(b, z=z, d=d, magnification=magnification) mags[bn] = m mags['time'] = self.Time * (1. + z) return mags
def read_curves(self): block = self.load() header = 'Mbol MU MB MV MI MR'.split() curves = SetLightCurve(self.name) time = block['time'] for col in header: b = band.band_by_name(col.replace('M', '')) mag = block[col] lc = LightCurve(b, time, mag) curves.add(lc) return curves
def plot_JHK(): plt.title('JHK filter response') bands = dict(J='b', H='c', K='r') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_UBVRI(): plt.title('UBVRI filter response') bands = dict(U='b', B='c', V='g', R='r', I='p') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_Kepler(): plt.title("The Kepler Space Telescope filter responses") bands = dict(Kepler="magenta") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_HSC(): plt.title('The Hyper Suprime-Cam(HSC) Photometric filter responses') bands = dict(HSCg='m', HSCr='b', HSCi='r', HSCz='y', HSCY='g') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_PS1(): plt.title('The Pan-STARRS1 Photometric filter responses') bands = dict(PS1g='m', PS1i='r', PS1r='b', PS1z='y', PS1y='g', PS1w='p') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_HSC(): plt.title("The Hyper Suprime-Cam(HSC) Photometric filter responses") bands = dict(HSCg="m", HSCr="b", HSCi="r", HSCz="y", HSCY="g") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_griuz(): plt.title('griuz filter response') bands = dict(g='g', i='r+', r='r', u='o', z='*') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_HST(): plt.title("The Hubble Space Telescope filter responses") bands = dict(F105W="blue", F125W="g", F435W="skyblue", F140W="orange", F160W="r", F606W="cyan", F814W="magenta") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_Kepler(): plt.title('The Kepler Space Telescope filter responses') bands = dict(Kepler="magenta") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_PS1(): plt.title("The Pan-STARRS1 Photometric filter responses") bands = dict(PS1g="m", PS1i="r", PS1r="b", PS1z="y", PS1y="g", PS1w="p") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def plot_griuz(): plt.title("griuz filter response") bands = dict(g="g", i="r+", r="r", u="o", z="*") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel("Amplitude Response") plt.xlabel("Wave [A]") plt.grid() plt.show()
def __init__(self, b, time, mags, errs=None, tshift=0., mshift=0.): """Creates a Light Curve instance. Required parameters: b (band), time, mags.""" if isinstance(b, str): # convert band-name to band instance if band.is_exist(b): self._b = band.band_by_name(b) else: raise ValueError("No such band: {}".format(b)) else: self._b = b super().__init__(self._b.Name, time, mags, errs, tshift=tshift) self._mshift = mshift self._attrs = {}
def test_band_zp_vs_Jy(self): bands = band.band_load_names() for bname in bands: b = band.band_by_name(bname) if b.is_zp and b.is_Jy: m_ab = Flux2MagAB(b.Jy * phys.jy_to_erg) self.assertAlmostEqual( m_ab, b.zp, msg="Band [%s] zp and Jy should be coincide each other. " "zp=%f, m_zp(Jy) = %f, Jy = %f" % (b.Name, b.zp, m_ab, b.Jy), delta=0.01)
def table2curves(name, tbl, bands=None): time = tbl['time'] curves = SetLightCurve(name) if bands is None: bands = [n for n in tbl.dtype.names if band.band_is_exist(n)] for bname in bands: b = band.band_by_name(bname) mag = tbl[bname] lc = LightCurve(b, time, mag) curves.add(lc) return curves
def test_band_ubvri(self): import pylab as plt b = band.band_by_name(band.Band.NameUBVRI) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, band.colors(b.Name), label=b.Name, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def read_curves(path=sn_path): fs = {'U': 'pav_U.csv', 'B': 'pav_B.csv', 'V': 'pav_V.csv', 'R': 'pav_R.csv', 'I': 'pav_I.csv'} fs = dict((k, os.path.join(path, v)) for k, v in fs.items()) curves = SetLightCurve('Sn87A') for n, fname in fs.items(): data = np.loadtxt(fname, comments='#', skiprows=1, delimiter="\t", usecols=(0, 1)) b = band.band_by_name(n) t = data[:, 0] mags = data[:, 1] lc = LightCurve(b, t, mags) curves.add(lc) return curves
def read_curves_gri(self): block = self.read(ext='gri', line_header=1) # header = 'L_bol Mu MB Mg Mr Mi'.split() # header = 'MB MV'.split() header = 'L_bol Mu MB MV Mg Mr Mi J H K '.split() # header = 'MB MV '.split() # header = 'L_bol L_ubvgri Mu MB MV Mg Mr Mi'.split() curves = SetLightCurve(self.name) time = block['time'] for col in header: b = band.band_by_name(col.replace('M', '').replace('L_', '')) mag = block[col] lc = LightCurve(b, time, mag) curves.add(lc) return curves
def read_curves_gri(self): block = self.load(ext='gri', line_header=1) # header = 'L_bol Mu MB Mg Mr Mi'.split() # header = 'MB MV'.split() header = 'L_bol Mu MB MV Mg Mr Mi J H K '.split() # header = 'MB MV '.split() # header = 'L_bol L_ubvgri Mu MB MV Mg Mr Mi'.split() curves = SetLightCurve(self.name) time = block['time'] for col in header: b = band.band_by_name(col.replace('M', '').replace('L_', '')) mag = block[col] lc = LightCurve(b, time, mag) curves.add(lc) return curves
def read_curves_master(path=sn_path): header = 'V I R' bnames = map(str.strip, header.split()) curves = SetLightCurve('Red Nova') for i, n in enumerate(bnames): b = band.band_by_name(n) d = np.loadtxt(os.path.join(path, n + '.txt'), dtype=[('JD', '<f4'), ('mag', '<f4'), ('err', '<f4')]) time = d['JD'] mags = d['mag'] errs = d['err'] lc = LightCurve(b, time, mags, errs=errs) curves.add(lc) return curves
def plot_bands(bands, color_dic=None): if color_dic is None: color_dic = band.colors() for bname in bands: b = band.band_by_name(bname) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, color_dic[bname], label=bname, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def plot_SWIFT(): plt.title('SWIFT filter response') bands = dict(UVM2='m', UVW1='r', UVW2='b', SwiftU='k', SwiftB='c', SwiftV='g') for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k) plt.legend() plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def flux_to_curves(self, bands, z=0., d=rf.pc_to_cm(10.), magnification=1.): """ :param bands: :param z: :param d: :param magnification: :return: """ curves = SetLightCurve(self.name) for n in bands: b = band.band_by_name(n) lc = self.flux_to_curve(b, z=z, d=d, magnification=magnification) curves.add(lc) return curves
def plot_HST(): plt.title('The Hubble Space Telescope filter responses') bands = dict(F105W="blue", F125W="g", F435W="skyblue", F140W="orange", F160W="r", F606W="cyan", F814W="magenta") for k, v in bands.items(): b = band.band_by_name(k) plt.plot(b.wl * phys.cm_to_angs, b.resp_wl, v, label=k, linewidth=2) plt.legend(loc=4) plt.ylabel('Amplitude Response') plt.xlabel('Wave [A]') plt.grid(linestyle=':') plt.show()
def epsilon(theta, freq, mag, bands, radius, dist, z): temp_color, zeta = theta e = 0 if temp_color < 0 or zeta < 0: for b in bands: e += mag[b] ** 2 return e # sp = spectrum.SpectrumDilutePlanck(freq, temp_color, W=zeta**2) sp = spectrum.SpectrumDilutePlanck(freq, temp_color, W=zeta ** 2) # sp.correct_zeta(zeta) star = Star("bb", sp) star.set_radius_ph(radius) star.set_distance(dist) star.set_redshift(z) mag_bb = {b: star.magAB(band.band_by_name(b)) for b in bands} for b in bands: e += (mag[b] - mag_bb[b]) ** 2 return e
def table2curves(name, tbl, bands=None, colt=('time', 'JD', 'MJD'), is_filter_zero=True): # time = None for nm in colt: if nm in tbl.dtype.names: time = tbl[nm] break else: raise ValueError( "THe table should contain a column with name in [{0}]".format( ', '.join(colt))) curves = SetLightCurve(name) if bands is None: bands = [n for n in tbl.dtype.names if band.is_exist(n)] for bname in bands: b = band.band_by_name(bname) mag = tbl[bname] mask = ~np.isnan(mag) # filter if is_filter_zero: mask = np.logical_and(mask, mag != 0) # filter out values not equal 0 mask = np.logical_and(mask, mag < 99) t = time[mask] m = mag[mask] for err_name in (prefix + bname for prefix in err_prefix): if err_name in tbl.dtype.names: err = tbl[err_name] e = err[mask] lc = LightCurve(b, t, m, e) break else: lc = LightCurve(b, t, m) curves.add(lc) return curves
def read_curves(path=sn_path): header = 'U B V R I' cols = map(str.strip, header.split()) lc_data = np.loadtxt(os.path.join(path, '1999emubvir.dat'), skiprows=1, usecols=range(1, 12)) time = lc_data[:, 0] curves = SetLightCurve('Sn99em') for i, n in enumerate(cols): b = band.band_by_name(n) mags = lc_data[:, 2*i+1] errs = lc_data[:, 2*i+2] # filter bad values is_good = mags < 30. t = time[is_good] mags = mags[is_good] errs = errs[is_good] # add lc = LightCurve(b, t, mags, errs=errs) curves.add(lc) return curves
def read_curves(path=sn_path): header = 'U B V I R' cols = map(str.strip, header.split()) lc_data = np.loadtxt(os.path.join(path, '1999emubvir.dat'), skiprows=1, usecols=range(1, 12)) time = lc_data[:, 0] curves = SetLightCurve('Sn99em') for i, n in enumerate(cols): b = band.band_by_name(n) mags = lc_data[:, 2*i+1] errs = lc_data[:, 2*i+2] # filter bad values is_good = mags < 30. t = time[is_good] mags = mags[is_good] errs = errs[is_good] # add lc = LightCurve(b, t, mags, errs=errs) curves.add(lc) return curves
def read_curves_master_abs_mag(path=sn_path): jd = 2457036 header = 'V I R' bnames = map(str.strip, header.split()) curves = SetLightCurve('Red Nova') for i, n in enumerate(bnames): b = band.band_by_name(n) time = np.loadtxt(os.path.join(path, n + '_jd.txt')) + jd mags = np.loadtxt(os.path.join(path, n + '_mag.txt')) errs = np.loadtxt(os.path.join(path, n + '_err.txt')) # filter bad values # is_good = mags < 30. # t = time[is_good] # mags = mags[is_good] # errs = errs[is_good] # add lc = LightCurve(b, time, mags, errs=errs) curves.add(lc) return curves
def test_band_by_name(self): b = band.band_by_name("BesU") self.assertTrue(b.is_chem_load, "The band should be loaded and with data")
def test_zero_point(self): zp = 0.748 # See filters.ini b = band.band_by_name('U') self.assertAlmostEqual(b.zp, zp, msg="Zero points of band %s equals %f. Should be %f" % (b.name, b.zp, zp))