def load_spectrum(path, smoothing=181, DF=-8.):
    """Load a Phoenix model atmosphere spectrum.

    path : string
      The file path to load.
    smoothing : integer
      Smoothing to apply. If None, do not smooth. If an integer, smooth with a
      Hamming window. Otherwise, the variable is assumed to be a different
      smoothing window, and the data will be convolved with it.
    DF: float
      Numerical factor used to compute the emergent flux density.

    Returns a Pandas DataFrame containing the columns:

    wlen
      Sample wavelength in Angstrom.
    flam
      Flux density in erg/cm²/s/Å. See `pwkit.synphot` for related tools.

    The values of *flam* returned by this function are computed from the
    second column of the data file as specified in the documentation: ``flam =
    10**(col2 + DF)``. The documentation states that the default value, -8, is
    appropriate for most modern models; but some older models use other
    values.

    Loading takes about 5 seconds on my current laptop. Un-smoothed spectra
    have about 630,000 samples.

    """
    try:
        ang, lflam = np.loadtxt(path, usecols=(0,1)).T
    except ValueError:
        # In some files, the numbers in the first columns fill up the
        # whole 12-character column width, and are given in exponential
        # notation with a 'D' character, so we must be more careful:
        with open(path, 'rb') as f:
            def lines():
                for line in f:
                    yield line.replace(b'D', b'e')
            ang, lflam = np.genfromtxt(lines(), delimiter=(13, 12)).T

    # Data files do not come sorted!
    z = ang.argsort()
    ang = ang[z]
    flam = 10**(lflam[z] + DF)
    del z

    if smoothing is not None:
        if isinstance(smoothing, int):
            smoothing = np.hamming(smoothing)
        else:
            smoothing = np.asarray(smoothing)

        wnorm = np.convolve(np.ones_like(smoothing), smoothing, mode='valid')
        smoothing = smoothing / wnorm # do not alter original array.
        smooth = lambda a: np.convolve(a, smoothing, mode='valid')[::smoothing.size]
        ang = smooth(ang)
        flam = smooth(flam)

    return pd.DataFrame({'wlen': ang, 'flam': flam})
Load a Phoenix model atmosphere spectrum.

    path : string
      The file path to load.
    smoothing : integer
      Smoothing to apply. If None, do not smooth. If an integer, smooth with a
      Hamming window. Otherwise, the variable is assumed to be a different
      smoothing window, and the data will be convolved with it.
    DF: float
      Numerical factor used to compute the emergent flux density.

    Returns a Pandas DataFrame containing the columns:

    wlen
      Sample wavelength in Angstrom.
    flam
      Flux density in erg/cm²/s/Å. See `pwkit.synphot` for related tools.

    The values of *flam* returned by this function are computed from the
    second column of the data file as specified in the documentation: ``flam =
    10**(col2 + DF)``. The documentation states that the default value, -8, is
    appropriate for most modern models; but some older models use other
    values.

    Loading takes about 5 seconds on my current laptop. Un-smoothed spectra
    have about 630,000 samples.