예제 #1
0
파일: sed.py 프로젝트: nhmc/H2
    def __init__(self, filename=None, wa=[], fl=[], z=0., label=None):

        # filename overrides wave and flux keywords
        if filename is not None:
            if not filename.startswith(PATH_TEMPLATE):
                filepath = PATH_TEMPLATE + filename
            if filepath.endswith('.fits'):
                rec = readtabfits(filepath)
                wa, fl = rec.wa, rec.fl
            else:
                wa, fl = np.loadtxt(filepath, usecols=(0,1), unpack=1)  
            if label is None:
                label = filename
        # We keep a copy of the wavelength, flux at z = 0 as it's
        # more robust to copy that to self.wa, flux and
        # redshift it, rather than repeatedly redshifting
        self.z0wa = np.array(wa)
        self.z0fl = np.array(fl)
        self.wa = np.array(wa)
        self.fl = np.array(fl)
        self.z = z
        self.label = label    

        # Store the intrinsic (i.e. unextincted) flux in case we
        # change extinction
        self.EBmV = 0.
        self.z0fl_no_extinct = np.array(fl)

        if abs(z) > 1e-6:
            self.redshift_to(z)
예제 #2
0
파일: spec.py 프로젝트: nhmc/H2
def qso_template(wa, z):
    """ Return a composite QSO spectrum at redshift z.

    The SDSS composite spectrum as a function of F_lambda is returned
    at each wavelength of wa. wa must be in angstroms.
    """
    r = readtabfits(DATAPATH + "/templates/qso/dr1QSOspec.fits")
    return np.interp(wa, r.wa * (1 + z), r.fl)