Example #1
0
 def test_check_band_zp_ps1(self):
     bands = ['PS1g', 'PS1z', 'PS1r', "PS1i", "PS1y", "PS1w"]
     star = ps.Star('test', self.sp)
     for n in bands:
         b = ps.band.band_by_name(n)
         mag = star.magAB(b)
         self.assertAlmostEqual(mag, ps.phys.ZP_AB, delta=1.,
                                msg="For uniform flux=1 it should be mag==AB zero point.\n \
                                     Now mag is %f for band %s. ZP is %f" % (mag, b, ps.phys.ZP_AB))
Example #2
0
 def test_k_cor_uniform(self):
     b_r = ps.band.band_by_name('U')
     b_o = ps.band.band_by_name('U')
     z = 0.2
     star = ps.Star('test', self.sp)
     k_cor = star.k_cor(b_r, b_o, z=z)
     self.assertIsNotNone(k_cor, "Return error for k_cor. \
                         Band-rest %s and band-obs %s." % (b_r, b_o))
     self.assertAlmostEqual(k_cor, 0.,
                            msg="For uniform flux=1 it should be k_cor==0. \
                         Now k_kor is %f for band-rest %s and band-obs %s." % (k_cor, b_r, b_o), delta=0.0001)
Example #3
0
 def test_check_band_zp_sdss(self):
     bands = ['UVM2', 'UVW1', 'UVW2']
     star = ps.Star('test', self.sp)
     # star.set_radius_ph(self.distance)
     # star.set_distance(self.distance)
     for n in bands:
         b = ps.band.band_by_name(n)
         mag = star.magAB(b)
         self.assertAlmostEqual(mag, ps.phys.ZP_AB, delta=1.,
                                msg="For uniform flux=1 it should be mag==AB zero point.\n \
                                     Now mag is %f for band %s. ZP is %f" % (mag, b, ps.phys.ZP_AB))
Example #4
0
 def test_k_cor_z(self):
     b_r = ps.band.band_by_name('V')
     b_o = ps.band.band_by_name('V')
     z = 0.1
     star = ps.Star('test1', self.sp)
     star.set_redshift(z)
     k_cor = star.k_cor(b_r, b_o)
     self.assertIsNotNone(k_cor, "Return error for k_cor. \
                         Band-rest %s and band-obs %s." % (b_r, b_o))
     self.assertNotAlmostEqual(k_cor, 0.,
                               msg="For z=%f it should be k_cor != 0. \
                         Now k_kor is %f for band-rest %s and band-obs %s." % (z, k_cor, b_r, b_o))
Example #5
0
    def test_check_band_zp_UBVRI(self):
        star = ps.Star('test', self.sp)
        # see https://www.astro.umd.edu/~ssm/ASTR620/mags.html#conversions
        delta = {'B': 0.163, 'V': 0.044, 'R': -0.055, "I": -0.309}
        bands = delta.keys()
        for n in bands:
            b = ps.band.band_by_name(n)
            # mag = star.flux_to_mag(b) - phys.ZP_AB_lmb

            mag = star.magAB(b) - ps.phys.ZP_AB
            # mag = star.flux_to_magAB(b) - delta[n] - phys.ZP_AB

            self.assertAlmostEqual(mag, 0., delta=0.5,
                                   msg="For uniform flux=1 it should be mag==AB zero point.\n \
                                        Now mag is %f for band %s. ZP is %f" % (mag, b, ps.phys.ZP_AB))
Example #6
0
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 = ps.SpectrumDilutePlanck(freq, temp_color, W=zeta**2)
    # sp.correct_zeta(zeta)

    star = ps.Star("bb", sp)
    star.set_radius_ph(radius)
    star.set_distance(dist)
    star.set_redshift(z)
    mag_bb = {b: star.magAB(ps.band.band_by_name(b)) for b in bands}
    for b in bands:
        e += (mag[b] - mag_bb[b])**2
    return e