예제 #1
0
def test():
    """ Test to understando how the best fit is produced with extinction. """
    w1 = 4500
    w2 = 7000
    targetSN = 70
    logdir = "logs_sn{0}_w{1}_{2}".format(targetSN, w1, w2)
    for field in fields[:1]:
        os.chdir(os.path.join(data_dir, "combined_{0}".format(field), logdir))
        bins = [1,2,3]
        for bin in bins:
            pp = ppload("{0}_bin{1}".format(field, bin))
            pp = pPXF(pp, velscale)
            plt.plot(pp.lam, pp.galaxy, "-k")
            plt.plot(pp.lam, pp.bestfit, "-r")
            extinction = reddening_curve(pp.lam, pp.reddening)
            plt.plot(pp.lam, (pp.gas + pp.ssps) / extinction, "-b")
            # plt.plot(pp.lam, extinction, "-g")
            # print pp.reddening
            # print reddening_curve(pp.lam, pp.reddening)
            # plt.plot(pp.lam, pp.mpoly, "-b")
            plt.show()
예제 #2
0
 def calc_arrays(self):
     """ Calculate the different useful arrays."""
     # Slice matrix into components
     self.m_poly = self.matrix[:,:self.degree + 1]
     self.matrix = self.matrix[:,self.degree + 1:]
     self.m_ssps = self.matrix[:,:self.ntemplates]
     self.matrix = self.matrix[:,self.ntemplates:]
     self.m_gas = self.matrix[:,:self.ngas]
     self.matrix = self.matrix[:,self.ngas:]
     self.m_sky = self.matrix
     # Slice weights
     if hasattr(self, "polyweights"):
         self.w_poly = self.polyweights
         self.poly = self.m_poly.dot(self.w_poly)
     else:
         self.poly = np.zeros_like(self.galaxy)
     if hasattr(self, "mpolyweights"):
         x = np.linspace(-1, 1, len(self.galaxy))
         self.mpoly = np.polynomial.legendre.legval(x, np.append(1,
                                                    self.mpolyweights))
     else:
         self.mpoly = np.ones_like(self.galaxy)
     if self.reddening is not None:
         self.extinction = reddening_curve(self.lam, self.reddening)
     else:
         self.extinction = np.ones_like(self.galaxy)
     self.w_ssps = self.weights[:self.ntemplates]
     self.weights = self.weights[self.ntemplates:]
     self.w_gas = self.weights[:self.ngas]
     self.weights = self.weights[self.ngas:]
     self.w_sky = self.weights
     # Calculating components
     self.ssps = self.m_ssps.dot(self.w_ssps)
     self.gas = self.m_gas.dot(self.w_gas)
     self.bestsky = self.m_sky.dot(self.w_sky)
     return
예제 #3
0
 def calc_arrays(self):
     """ Calculate the different useful arrays."""
     # Slice matrix into components
     self.m_poly = self.matrix[:, :self.degree + 1]
     self.matrix = self.matrix[:, self.degree + 1:]
     self.m_ssps = self.matrix[:, :self.ntemplates]
     self.matrix = self.matrix[:, self.ntemplates:]
     self.m_gas = self.matrix[:, :self.ngas]
     self.matrix = self.matrix[:, self.ngas:]
     self.m_sky = self.matrix
     # Slice weights
     if hasattr(self, "polyweights"):
         self.w_poly = self.polyweights
         self.poly = self.m_poly.dot(self.w_poly)
     else:
         self.poly = np.zeros_like(self.galaxy)
     if hasattr(self, "mpolyweights"):
         x = np.linspace(-1, 1, len(self.galaxy))
         self.mpoly = np.polynomial.legendre.legval(
             x, np.append(1, self.mpolyweights))
     else:
         self.mpoly = np.ones_like(self.galaxy)
     if self.reddening is not None:
         self.extinction = reddening_curve(self.lam, self.reddening)
     else:
         self.extinction = np.ones_like(self.galaxy)
     self.w_ssps = self.weights[:self.ntemplates]
     self.weights = self.weights[self.ntemplates:]
     self.w_gas = self.weights[:self.ngas]
     self.weights = self.weights[self.ngas:]
     self.w_sky = self.weights
     # Calculating components
     self.ssps = self.m_ssps.dot(self.w_ssps)
     self.gas = self.m_gas.dot(self.w_gas)
     self.bestsky = self.m_sky.dot(self.w_sky)
     return