예제 #1
0
def plot_mangled_SED(x, y, key, inst):

    p = pygplot.Plot(device='14/XS',
                     font=1.5,
                     fsize=2,
                     xlabel='Wavelength (Angstroms)',
                     ylabel='Flux')
    band = inst.filter
    self = inst.inst
    id = argmin(power(x - self.data[band].t, 2) + power(y - self.ks[band], 2))
    day = int(self.data[band].t[id])
    wave, flux = kcorr.get_SED(day, version='H3')
    p.line(wave, flux, label='Original SED')

    if band in self.ks_mopts:
        man_flux = mangle_spectrum.apply_mangle(wave, flux,
                                                **self.ks_mopts[band][id])
        p.line(wave, man_flux, label='Mangled SED', color='007700')
    f1 = fset[band]
    f2 = fset[self.restbands[band]]
    p.line(f1.wave, f1.resp / f1.resp.max() * flux.max(), color='red')
    p.line(f2.wave * (1 + self.z),
           f2.resp / f2.resp.max() * flux.max(),
           color='blue')

    p.legend(fsize=1.5)
    p.xrange = [fset[band].wave.min() * 0.9, fset[band].wave.max() * 1.1]
    p.plot()
    p.close()
예제 #2
0
파일: redlaw.py 프로젝트: obscode/snpy
def Rv_to_R(f1, f2, f3, Rv, EBV=0.01, day=0, redlaw='ccm',
      strict_ccm=0, version='H3'):
   '''Convert from R_V and optionally EBV to an observed R through
   filter f1, corrected by f2-f3 color.  You can choose which day
   the SN SED should be (default day 0, max).  You can also specify
   which reddening law to use:  redlaw='ccm' for Cardelli et al., or
   redlaw='fm' for Fitzpatric and Malla (1999), If redlaw='ccm', you 
   can specify whether we should use the strict CCM relation (default no).
   Finally, you an choose which SED sequence to use:  'H', 'H3', or '91bg'
   (default H3).'''

   # get the SNIa SED
   wave,flux = kcorr.get_SED(day, version=version)
   # Redden according to CCM (plus improvements if strict_ccm=0)
   rflux,a,b = deredden.unred(wave, flux, -EBV, Rv, redlaw=redlaw,
         strict_ccm=strict_ccm)
   
   # compute synthetic magnitudes of original and reddened filter
   m1 = fset[f1].synth_mag(wave, flux)
   m1_red = fset[f1].synth_mag(wave, rflux)
   m2 = fset[f2].synth_mag(wave, flux)
   m2_red = fset[f2].synth_mag(wave, rflux)
   m3 = fset[f3].synth_mag(wave, flux)
   m3_red = fset[f3].synth_mag(wave, rflux)

   # Compute extinctions
   A1 = m1 - m1_red;   A2 = m2 - m2_red;  A3 = m3 - m3_red

   # Return reddening law R
   return(A1/(A2 - A3))
예제 #3
0
파일: plot_sne_pg.py 프로젝트: obscode/snpy
def advance_day(x, y, key, p):
   '''A call-back function used by plot_filters() to chnage the eqpoch of the
   SNIa SED plotted in the background.'''

   if key == 'd':
      if p.current_day < 70:
         p.current_day += 1
         p.title = 'Filter responses + %s SED (day %d)' % (p.version,
               p.current_day)
         p.sed_line.x,p.sed_line.y = kcorr.get_SED(p.current_day, p.version)
         p.sed_line.y = p.sed_line.y/maximum.reduce(p.sed_line.y)
         p.sed_line.x = p.sed_line.x*(1+p.z)
   if key == 'D':
      if p.current_day > -19:
         p.current_day -= 1
         p.title = 'Filter responses + %s SED (day %d)' % (p.version,
                    p.current_day)
         p.sed_line.x,p.sed_line.y = kcorr.get_SED(p.current_day, p.version)
         p.sed_line.y = p.sed_line.y/maximum.reduce(p.sed_line.y)
         p.sed_line.x = p.sed_line.x*(1+p.z)
예제 #4
0
def advance_day(x, y, key, p):
    '''A call-back function used by plot_filters() to chnage the eqpoch of the
   SNIa SED plotted in the background.'''

    if key == 'd':
        if p.current_day < 70:
            p.current_day += 1
            p.title = 'Filter responses + %s SED (day %d)' % (p.version,
                                                              p.current_day)
            p.sed_line.x, p.sed_line.y = kcorr.get_SED(p.current_day,
                                                       p.version)
            p.sed_line.y = p.sed_line.y / maximum.reduce(p.sed_line.y)
            p.sed_line.x = p.sed_line.x * (1 + p.z)
    if key == 'D':
        if p.current_day > -19:
            p.current_day -= 1
            p.title = 'Filter responses + %s SED (day %d)' % (p.version,
                                                              p.current_day)
            p.sed_line.x, p.sed_line.y = kcorr.get_SED(p.current_day,
                                                       p.version)
            p.sed_line.y = p.sed_line.y / maximum.reduce(p.sed_line.y)
            p.sed_line.x = p.sed_line.x * (1 + p.z)
예제 #5
0
def plot_mangled_SED(event):

    f = pyplot.figure(num=113)
    f.clear()
    ax = f.add_subplot(111)
    ax.set_xlabel('Wavelength (Angstroms)')
    ax.set_ylabel('Flux')
    band = event.inaxes.filt
    self = event.inaxes.inst

    x = event.xdata
    y = event.ydata
    id = argmin(power(x - self.data[band].t, 2) + power(y - self.ks[band], 2))
    day = int(self.data[band].t[id])
    wave, flux = kcorr.get_SED(day, version='H3')
    ax.plot(wave, flux, label='Original SED', color='black')
    if band in self.ks_mopts:
        if 'state' in self.ks_mopts[band][id]:
            man_flux = mangle_spectrum.apply_mangle(
                wave, flux, **self.ks_mopts[band][id])[0]
        else:
            args = {}
            args['state'] = dict(ave_waves=self.ks_mopts[band][id]['sw'])
            args['pars'] = self.ks_mopts[band][id]['sf']
            man_flux = mangle_spectrum.apply_mangle(wave,
                                                    flux,
                                                    init=False,
                                                    **args)[0]
    else:
        man_flux = flux
    ax.plot(wave, man_flux, label='Mangled SED', color='darkgreen')
    ax.plot(wave, man_flux / flux * ax.get_ylim()[1], color='orange')

    f1 = fset[band]
    f2 = fset[self.restbands[band]]
    ax.plot(f1.wave, f1.resp / f1.resp.max() * ax.get_ylim()[1], color='red')
    ax.plot(f2.wave * (1 + self.z),
            f2.resp / f2.resp.max() * ax.get_ylim()[1],
            color='blue')
    #wmax = max(f1.wave.max(), f2.wave.max()*(1+self.z))
    #wmin = max(f1.wave.min(), f2.wave.min()*(1+self.z))
    #dw = wmax - wmin
    #wmax += dw*0.05
    #wmin -= dw*0.05

    ax.legend()
    #ax.set_xlim(wmin,wmax)

    pyplot.tight_layout()
    f.canvas.draw()
예제 #6
0
def plot_color(self, f1, f2, epoch=True, deredden=True, interp=False, 
      dokcorr=False, outfile=None, clear=True):
   '''Plot the color ([f1]-[f2]) evolution curve for the SN.  If  [epoch]
   is True and Bmax is defined, plot relative to T(Bmax).  If [deredden]
   is True, remove MW reddening.  Specify [outfile] to save to file.'''
   p = pyplot.figure(114)
   if clear: p.clear()
   ax = p.add_subplot(111)
   ax.set_xlabel('JD - JD(Bmax)')
   ax.set_ylabel('%s-%s' % (f1,f2))

   MJD,BV,eBV,flag = self.get_color(f1, f2, interp=interp, use_model=0, 
         dokcorr=dokcorr)
   if epoch:
      if self.Tmax:
         t0 = self.Tmax
      elif 'B' in self.data and getattr(self.data['B'],'Tmax',None) is not None:
         t0 = self.B.Tmax
      else:
         t0 = 0
   else:
      t0 = 0

   if deredden:
      Ia_w,Ia_f = kcorr.get_SED(0, 'H3')
      R1 = fset[f1].R(wave=Ia_w, flux=Ia_f, Rv=3.1)
      R2 = fset[f2].R(wave=Ia_w, flux=Ia_f, Rv=3.1)
      BV = BV - (R1-R2)*self.EBVgal
      eBV = sqrt(power(eBV,2) + (R1-R2)**2*0.1**2*self.EBVgal**2)

   bids = equal(flag, 0)
   rids = equal(flag, 1)
   ax.errorbar(MJD[bids]-t0, BV[bids], yerr=eBV[bids], fmt='o', capsize=0, 
         color='black', label='obs')
   if sometrue(rids):
      ax.errorbar(MJD[rids]-t0, BV[rids], yerr=eBV[rids], fmt='o', capsize=0, 
         color='red', mfc='red', label='inter')
   ax.legend(prop={'size':12})
   pyplot.tight_layout()
   pyplot.draw()
   #p.canvas.draw()
   if outfile is not None:
      p.savefig(outfile)
   return p
예제 #7
0
def plot_color(self, f1, f2, epoch=True, deredden=True, interp=False, 
      dokcorr=False, outfile=None, clear=True):
   '''Plot the color ([f1]-[f2]) evolution curve for the SN.  If  [epoch]
   is True and Bmax is defined, plot relative to T(Bmax).  If [deredden]
   is True, remove MW reddening.  Specify [outfile] to save to file.'''
   p = pyplot.figure(114)
   if clear: p.clear()
   ax = p.add_subplot(111)
   ax.set_xlabel('JD - JD(Bmax)')
   ax.set_ylabel('%s-%s' % (f1,f2))

   MJD,BV,eBV,flag = self.get_color(f1, f2, interp=interp, use_model=0, 
         dokcorr=dokcorr)
   if epoch:
      if self.Tmax:
         t0 = self.Tmax
      elif 'B' in self.data and getattr(self.data['B'],'Tmax',None) is not None:
         t0 = self.B.Tmax
      else:
         t0 = 0
   else:
      t0 = 0

   if deredden:
      Ia_w,Ia_f = kcorr.get_SED(0, 'H3')
      R1 = fset[f1].R(wave=Ia_w, flux=Ia_f, Rv=3.1)
      R2 = fset[f2].R(wave=Ia_w, flux=Ia_f, Rv=3.1)
      BV = BV - (R1-R2)*self.EBVgal
      eBV = sqrt(power(eBV,2) + (R1-R2)**2*0.1**2*self.EBVgal**2)

   bids = equal(flag, 0)
   rids = equal(flag, 1)
   ax.errorbar(MJD[bids]-t0, BV[bids], yerr=eBV[bids], fmt='o', capsize=0, 
         color='black', label='obs')
   if sometrue(rids):
      ax.errorbar(MJD[rids]-t0, BV[rids], yerr=eBV[rids], fmt='o', capsize=0, 
         color='red', mfc='red', label='inter')
   ax.legend(prop={'size':12})
   pyplot.tight_layout()
   pyplot.draw()
   #p.canvas.draw()
   if outfile is not None:
      p.savefig(outfile)
   return p
예제 #8
0
def Rv_to_R(f1,
            f2,
            f3,
            Rv,
            EBV=0.01,
            day=0,
            redlaw='ccm',
            strict_ccm=0,
            version='H3'):
    '''Convert from R_V and optionally EBV to an observed R through
   filter f1, corrected by f2-f3 color.  You can choose which day
   the SN SED should be (default day 0, max).  You can also specify
   which reddening law to use:  redlaw='ccm' for Cardelli et al., or
   redlaw='fm' for Fitzpatric and Malla (1999), If redlaw='ccm', you 
   can specify whether we should use the strict CCM relation (default no).
   Finally, you an choose which SED sequence to use:  'H', 'H3', or '91bg'
   (default H3).'''

    # get the SNIa SED
    wave, flux = kcorr.get_SED(day, version=version)
    # Redden according to CCM (plus improvements if strict_ccm=0)
    rflux, a, b = deredden.unred(wave,
                                 flux,
                                 -EBV,
                                 Rv,
                                 redlaw=redlaw,
                                 strict_ccm=strict_ccm)

    # compute synthetic magnitudes of original and reddened filter
    m1 = fset[f1].synth_mag(wave, flux)
    m1_red = fset[f1].synth_mag(wave, rflux)
    m2 = fset[f2].synth_mag(wave, flux)
    m2_red = fset[f2].synth_mag(wave, rflux)
    m3 = fset[f3].synth_mag(wave, flux)
    m3_red = fset[f3].synth_mag(wave, rflux)

    # Compute extinctions
    A1 = m1 - m1_red
    A2 = m2 - m2_red
    A3 = m3 - m3_red

    # Return reddening law R
    return (A1 / (A2 - A3))
예제 #9
0
def change_SED(event):
   fig = event.inaxes.figure
   ax = event.inaxes
   if event.key == 'd':
      if fig.current_day < 70:  
         fig.current_day += 1
         ax.set_title('Filter responses + %s SED (day %d)' % \
               (fig.version,fig.current_day))
   elif event.key == 'D':
      if fig.current_day > -19:  
         fig.current_day -= 1
         ax.set_title('Filter responses + %s SED (day %d)' % \
               (fig.version,fig.current_day))
   wave,flux = kcorr.get_SED(fig.current_day, version='H3')
   fig.sed_line.set_data(wave*(1+fig.z), flux/flux.max())
   if fig.sed_fill is not None:  
      fig.sed_fill.remove()
      fig.sed_fill = fig.axes[0].fill_between(wave*(1+fig.z), flux/flux.max(),
         facecolor='black', alpha=0.1)
   fig.canvas.draw()
예제 #10
0
def change_SED(event):
   fig = event.inaxes.figure
   ax = event.inaxes
   if event.key == 'd':
      if fig.current_day < 70:  
         fig.current_day += 1
         ax.set_title('Filter responses + %s SED (day %d)' % \
               (fig.version,fig.current_day))
   elif event.key == 'D':
      if fig.current_day > -19:  
         fig.current_day -= 1
         ax.set_title('Filter responses + %s SED (day %d)' % \
               (fig.version,fig.current_day))
   wave,flux = kcorr.get_SED(fig.current_day, version='H3')
   fig.sed_line.set_data(wave*(1+fig.z), flux/flux.max())
   if fig.sed_fill is not None:  
      fig.sed_fill.remove()
      fig.sed_fill = fig.axes[0].fill_between(wave*(1+fig.z), flux/flux.max(),
         facecolor='black', alpha=0.1)
   fig.canvas.draw()
예제 #11
0
def plot_filters(self, bands=None, day=0):
    '''Plot the filter responses, both the observed ones and the restbands
   defined in the sn instance in the rest frame of the SN.  If bands is specified,
   only plot those.  Specify which SED to plot using day.'''
    p = pygplot.Plot(xlabel='Wavelength (\A)',
                     ylabel='relative flux',
                     title='Filter responses + %s SED (day %d)' %
                     (self.k_version, day),
                     device="11/XWIN")

    # first, get the SED:
    sed_wav, sed_flux = kcorr.get_SED(day, self.k_version)
    # normalize:
    sed_flux = sed_flux / maximum.reduce(sed_flux)
    p.sed_line = p.line(sed_wav * (1 + self.z), sed_flux, autorange=0)
    p.current_day = day
    p.version = self.k_version
    p.z = self.z

    # Next, for each filter, plot the response and rest band closest to it:
    if bands is None: bands = list(self.data.keys())
    if type(bands) is bytes:
        bands = [bands]

    for band in bands:
        f1 = fset[band]
        f2 = fset[self.restbands[band]]
        maxresp = maximum.reduce(f1.resp)
        max_wave = f1.wave[argmax(f1.resp)]
        p.line(f1.wave, f1.resp / maxresp, color='blue')
        p.label(max_wave, 1.05, band, color='blue')
        maxresp = maximum.reduce(f2.resp)
        max_wave = f2.wave[argmax(f2.resp)] * (1 + self.z)
        p.line(f2.wave * (1 + self.z), f2.resp / maxresp, color='red')
        p.label(max_wave, 1.05, self.restbands[band], color='red')

    p.plot()
    p.interact(bindings={'D': advance_day, 'd': advance_day})
    pygplot.ppgplot.pgask(0)
    p.close()
예제 #12
0
파일: plot_sne_pg.py 프로젝트: obscode/snpy
def plot_filters(self, bands=None, day=0):
   '''Plot the filter responses, both the observed ones and the restbands
   defined in the sn instance in the rest frame of the SN.  If bands is specified,
   only plot those.  Specify which SED to plot using day.'''
   p = pygplot.Plot(xlabel='Wavelength (\A)', ylabel='relative flux', 
        title='Filter responses + %s SED (day %d)' % (self.k_version,day),
        device="11/XWIN")

   # first, get the SED:
   sed_wav,sed_flux = kcorr.get_SED(day, self.k_version)
   # normalize:
   sed_flux = sed_flux/maximum.reduce(sed_flux)
   p.sed_line = p.line(sed_wav*(1+self.z),sed_flux, autorange=0)
   p.current_day = day
   p.version = self.k_version
   p.z = self.z

   # Next, for each filter, plot the response and rest band closest to it:
   if bands is None:  bands = self.data.keys()
   if type(bands) is types.StringType:
      bands = [bands]

   for band in bands:
      f1 = fset[band]
      f2 = fset[self.restbands[band]]
      maxresp = maximum.reduce(f1.resp)
      max_wave = f1.wave[argmax(f1.resp)]
      p.line(f1.wave, f1.resp/maxresp, color='blue')
      p.label(max_wave,1.05, band, color='blue')
      maxresp = maximum.reduce(f2.resp)
      max_wave = f2.wave[argmax(f2.resp)]*(1+self.z)
      p.line(f2.wave*(1+self.z), f2.resp/maxresp, color='red')
      p.label(max_wave, 1.05, self.restbands[band], color='red')

   p.plot()
   p.interact(bindings={'D':advance_day, 'd':advance_day})
   pygplot.ppgplot.pgask(0)
   p.close()
예제 #13
0
파일: plot_sne_pg.py 프로젝트: obscode/snpy
def plot_mangled_SED(x, y, key, inst):

   p = pygplot.Plot(device='14/XS', font=1.5, fsize=2, xlabel='Wavelength (Angstroms)',
         ylabel='Flux')
   band = inst.filter
   self = inst.inst
   id = argmin(power(x - self.data[band].t,2) + power(y - self.ks[band],2))
   day = int(self.data[band].t[id])
   wave,flux = kcorr.get_SED(day, version='H3')
   p.line(wave,flux, label='Original SED')

   if band in self.ks_mopts:
      man_flux = mangle_spectrum.apply_mangle(wave,flux, **self.ks_mopts[band][id])
      p.line(wave, man_flux, label='Mangled SED', color='007700')
   f1 = fset[band]
   f2 = fset[self.restbands[band]]
   p.line(f1.wave, f1.resp/f1.resp.max()*flux.max(), color='red')
   p.line(f2.wave*(1+self.z), f2.resp/f2.resp.max()*flux.max(), 
         color='blue')

   p.legend(fsize=1.5)
   p.xrange = [fset[band].wave.min()*0.9, fset[band].wave.max()*1.1]
   p.plot()
   p.close()
예제 #14
0
def plot_mangled_SED(event):

   f = pyplot.figure(num=113)
   f.clear()
   ax = f.add_subplot(111)
   ax.set_xlabel('Wavelength (Angstroms)')
   ax.set_ylabel('Flux')
   band = event.inaxes.filt
   self = event.inaxes.inst

   x = event.xdata;  y = event.ydata
   id = argmin(power(x - self.data[band].t,2) + power(y - self.ks[band],2))
   day = int(self.data[band].t[id])
   wave,flux = kcorr.get_SED(day, version='H3')
   ax.plot(wave,flux, label='Original SED', color='black')
   if band in self.ks_mopts:
      man_flux = mangle_spectrum.apply_mangle(wave,flux, **self.ks_mopts[band][id])[0]
   ax.plot(wave, man_flux, label='Mangled SED', color='darkgreen')
   ax.plot(wave, man_flux/flux*ax.get_ylim()[1], color='orange')

   f1 = fset[band]
   f2 = fset[self.restbands[band]]
   ax.plot(f1.wave, f1.resp/f1.resp.max()*ax.get_ylim()[1], color='red')
   ax.plot(f2.wave*(1+self.z), f2.resp/f2.resp.max()*ax.get_ylim()[1], 
         color='blue')
   #wmax = max(f1.wave.max(), f2.wave.max()*(1+self.z))
   #wmin = max(f1.wave.min(), f2.wave.min()*(1+self.z))
   #dw = wmax - wmin
   #wmax += dw*0.05
   #wmin -= dw*0.05

   ax.legend()
   #ax.set_xlim(wmin,wmax)

   pyplot.tight_layout()
   f.canvas.draw()
예제 #15
0
def plot_filters(self, bands=None, day=0, fill=0, outfile=None):
    '''Plot the filt responses, both the observed ones and the restbands
   defined in the sn instance in the rest frame of the SN.  If bands is specified,
   only plot those.  Specify which SED to plot using day.'''
    p = pyplot.figure(112)
    p.clear()
    ax = p.add_subplot(111,
                       title='Filter responses + %s SED (day %d)' %
                       (self.k_version, day),
                       xlabel='Wavelength ($\AA$)',
                       ylabel='Relative Flux',
                       autoscale_on=False,
                       ylim=(0, 1.1))

    p.current_day = day
    p.version = self.k_version
    p.z = self.z

    # Next, for each filt, plot the response and rest band closest to it:
    if bands is None: bands = list(self.data.keys())
    if type(bands) is bytes:
        bands = [bands]

    minw = 1e12
    maxw = -1
    for band in bands:
        f1 = fset[band]
        f2 = fset[self.restbands[band]]
        minw = min(minw, f1.wave[0], f2.wave[0])
        maxw = max(maxw, f1.wave[-1], f2.wave[-1])
        maxresp = f1.resp.max()
        max_wave = f1.wave[argmax(f1.resp)]
        ax.plot(f1.wave, f1.resp / maxresp, '-', color='blue')
        if fill:
            ax.fill_between(f1.wave,
                            f1.resp / maxresp,
                            facecolor='blue',
                            alpha=0.1)
        ax.annotate(band, (max_wave, 1.05),
                    color='blue',
                    horizontalalignment='center',
                    verticalalignment='center')
        maxresp = maximum.reduce(f2.resp)
        max_wave = f2.wave[argmax(f2.resp)] * (1 + self.z)
        ax.plot(f2.wave * (1 + self.z), f2.resp / maxresp, '-', color='red')
        if fill:
            ax.fill_between(f2.wave * (1 + self.z),
                            f2.resp / maxresp,
                            facecolor='red',
                            alpha=0.1)
        ax.annotate(self.restbands[band], (max_wave, 1.05),
                    color='red',
                    horizontalalignment='center',
                    verticalalignment='center')

    # first, get the SED:
    sed_wav, sed_flux = kcorr.get_SED(day, self.k_version)
    # normalize:
    sed_flux = sed_flux / sed_flux.max()
    p.sed_line = ax.plot(sed_wav * (1 + self.z),
                         sed_flux,
                         scalex=False,
                         color='black')[0]
    if fill:
        p.sed_fill = ax.fill_between(sed_wav * (1 + self.z),
                                     sed_flux,
                                     facecolor='black',
                                     alpha=0.1)
    else:
        p.sed_fill = None

    ax.set_xbound((minw, maxw))

    pyplot.tight_layout()
    pyplot.draw()
    p.cb = ButtonClick(p, bindings={'d': change_SED, 'D': change_SED})
    p.cb.connect()
    if outfile is not None:
        p.savefig(outfile)
    return p
예제 #16
0
def plot_filters(self, bands=None, day=0, fill=0, outfile=None):
   '''Plot the filt responses, both the observed ones and the restbands
   defined in the sn instance in the rest frame of the SN.  If bands is specified,
   only plot those.  Specify which SED to plot using day.'''
   p = pyplot.figure(112)
   p.clear()
   ax = p.add_subplot(111, 
         title='Filter responses + %s SED (day %d)' % (self.k_version,day),
         xlabel='Wavelength ($\AA$)', ylabel='Relative Flux',
         autoscale_on=False, ylim=(0,1.1))

   p.current_day = day
   p.version = self.k_version
   p.z = self.z

   # Next, for each filt, plot the response and rest band closest to it:
   if bands is None:  bands = self.data.keys()
   if type(bands) is types.StringType:
      bands = [bands]

   minw = 1e12
   maxw = -1
   for band in bands:
      f1 = fset[band]
      f2 = fset[self.restbands[band]]
      minw = min(minw, f1.wave[0], f2.wave[0])
      maxw = max(maxw, f1.wave[-1], f2.wave[-1])
      maxresp = f1.resp.max()
      max_wave = f1.wave[argmax(f1.resp)]
      ax.plot(f1.wave, f1.resp/maxresp, '-', color='blue')
      if fill:
         ax.fill_between(f1.wave, f1.resp/maxresp, facecolor='blue', alpha=0.1)
      ax.annotate(band, (max_wave,1.05), color='blue', 
            horizontalalignment='center', verticalalignment='center')
      maxresp = maximum.reduce(f2.resp)
      max_wave = f2.wave[argmax(f2.resp)]*(1+self.z)
      ax.plot(f2.wave*(1+self.z), f2.resp/maxresp, '-', color='red')
      if fill:
         ax.fill_between(f2.wave*(1+self.z), f2.resp/maxresp, facecolor='red', alpha=0.1)
      ax.annotate(self.restbands[band], (max_wave, 1.05), color='red',
            horizontalalignment='center', verticalalignment='center')

   # first, get the SED:
   sed_wav,sed_flux = kcorr.get_SED(day, self.k_version)
   # normalize:
   sed_flux = sed_flux/sed_flux.max()
   p.sed_line = ax.plot(sed_wav*(1+self.z),sed_flux, scalex=False, color='black')[0]
   if fill:
      p.sed_fill = ax.fill_between(sed_wav*(1+self.z),sed_flux,
            facecolor='black', alpha=0.1)
   else:
      p.sed_fill = None

   ax.set_xbound((minw, maxw))

   pyplot.tight_layout()
   pyplot.draw()
   p.cb = ButtonClick(p, bindings={'d':change_SED, 'D':change_SED})
   p.cb.connect()
   if outfile is not None:
      p.savefig(outfile)
   return p