Example #1
0
 def test_Fbol_calculation(self):
     expected = 10**(
         -0.4 * (bc(self.color_value, self.color_err, self.color_type)[0] +
                 self.v_magnitude + constants.mbol_zeropoint))
     result = luminosity.calc_Fbol(self.color_value, self.color_err,
                                   self.color_type, self.v_magnitude,
                                   self.v_magnitude_err)[0]
     self.assertEqual(expected, result)
Example #2
0
 def test_Fbol_calculation(self):
     expected = 10**(-0.4 * (bc(self.color_value, self.color_err,
                           self.color_type)[0]
                       + self.v_magnitude + constants.mbol_zeropoint))
     result = luminosity.calc_Fbol(self.color_value, self.color_err,
                                       self.color_type,
                                       self.v_magnitude,
                                       self.v_magnitude_err)[0]
     self.assertEqual(expected, result)
Example #3
0
 def test_Fbol_uncertainty(self):
     Fbol = luminosity.calc_Fbol(self.color_value, self.color_err,
                                 self.color_type, self.v_magnitude,
                                 self.v_magnitude_err)[0]
     bolometric_correction, bc_err = bc(self.color_value, self.color_err,
                                        self.color_type)
     expected = (math.sqrt(2) * 0.4 * math.log(10) * Fbol *
                 math.sqrt(bc_err**2 + self.v_magnitude_err**2))
     result = luminosity.calc_Fbol(self.color_value, self.color_err,
                                   self.color_type, self.v_magnitude,
                                   self.v_magnitude_err)[1]
     self.assertAlmostEqual(expected, result)
Example #4
0
 def test_Fbol_uncertainty(self):
     Fbol = luminosity.calc_Fbol(self.color_value, self.color_err,
                                       self.color_type,
                                       self.v_magnitude,
                                       self.v_magnitude_err)[0]
     bolometric_correction, bc_err = bc(self.color_value, self.color_err, 
                                        self.color_type)
     expected = (math.sqrt(2) * 0.4 * math.log(10) * Fbol * 
                         math.sqrt(bc_err**2 + self.v_magnitude_err**2))
     result = luminosity.calc_Fbol(self.color_value, self.color_err,
                                       self.color_type,
                                       self.v_magnitude,
                                       self.v_magnitude_err)[1]
     self.assertAlmostEqual(expected, result)
Example #5
0
def calc_Fbol(color_value, color_err, color_type, v_magnitude,
              v_magnitude_err):
    """Calculates the bolometric flux of a Type II-P supernova.

    Args:
        color_value (float): B-V, V-I, or B-I color of the supernova in
            magnitudes (corrected for reddening and extinction from
            the host and MWG.)
        color_err (float): Uncertainty in the photometric color.
        color_type (str): String signifying which color color_value
            represents. Valid values are "BminusV" for B-V, "VminusI"
            for V-I, and "BminusI" for B-I.
        v_magnitude (float): Photometric magnitude in the V band, corrected for
            host + MWG extinction.
        v_magnitude_err (float): Uncertainty in the V band magnitude after
            correction for host + MWG extinction.

    Returns:
        tuple: A tuple containing the bolometric flux used when calculating the
        bolometric luminosity, and the uncertainty in that number.

        (Fbol, uncertainty)

        (-999, -999) if the bolometric correction calculated from the
        color_value and color_type is -999 (which means the observed
        color is outside the range of validity of the polynomial fit.)
    """
    bolometric_correction, bc_err = bc(color_value, color_err, color_type)

    if bolometric_correction == -999:
        Fbol = -999
        Fbol_uncertainty = -999
    else:
        Fbol = 10**(-0.4 *
                    (bolometric_correction + v_magnitude + mbol_zeropoint))
        Fbol_uncertainty = (0.4 * math.log(10) * Fbol *
                            math.sqrt(bc_err**2 + v_magnitude_err**2))

    return Fbol, Fbol_uncertainty