Пример #1
0
def pseudocolor_vs_z(simgridIa=None, clobber=0):
    """  Plot medium-broad pseudo-colors from a grid simulation as a function
     of redshift.

    :param simgridIa: SNANA Simulation Table, or None to make/load it anew
    :param clobber:  passed to snanasim.dosimGrid() to re-run the SNANA sims
    :return: new or existing SNANA sim table (a stardust.SimTable object)
    """
    import stardust
    import snanasim
    import mkplots
    from matplotlib import pyplot as pl
    sn = stardust.SuperNova('HST_CANDELS2_colfax.dat')

    if simgridIa is None:
        if clobber:
            simgridIa = snanasim.dosimGrid(sn,
                                           ngridz=20,
                                           clobber=clobber,
                                           x1range=[-2, 2],
                                           crange=[-0.2, 0.5],
                                           trestrange=[-5, 5])
        else:
            simgridIa = stardust.SimTable('sim_colfax_medbandGrid_Ia')
    mkplots.pseudocolor_vs_z(simgridIa, medbands='OPQ', broadbands='JNH')
    pl.suptitle('MED BAND GRID SIM FOR SN COLFAX @ z=2.1+- 0.2', fontsize=20)
    return (simgridIa)
Пример #2
0
def mkcirclefigGrid(simdataGrid=None, clobber=0, snanadatfile=_SNANADATFILE):
    """  Plot the results of a SNANA Grid simulation as a circle diagram.
    """
    import snanasim
    import mkplots
    import stardust
    import numpy as np
    from matplotlib import pyplot as pl

    sn = stardust.SuperNova(snanadatfile)
    if simdataGrid is None:
        if clobber:
            simdataGrid = snanasim.dosimGrid(sn,
                                             ngridz=20,
                                             clobber=clobber,
                                             x1range=[-2, 2],
                                             crange=[-0.2, 0.5],
                                             trestrange=[-5, 5])
        else:
            simdataGrid = stardust.SimTable('sim_colfax_medbandGrid_Ia')

    mjdmedband = sn.MJD[np.where((sn.FLT == '7') | (sn.FLT == '8')
                                 | (sn.FLT == 'P'))]
    if len(mjdmedband) > 0:
        mjdobs = np.median(mjdmedband)
    else:
        mjdobs = sn.pkmjd

    fig = pl.gcf()
    ax1 = fig.add_subplot(2, 2, 1)
    mkplots.gridsim_circleplot(simdataGrid, 'O-J', 'P-N')
    ax2 = fig.add_subplot(2, 2, 2)
    mkplots.gridsim_circleplot(simdataGrid, 'Q-H', 'P-N')
    ax2 = fig.add_subplot(2, 2, 3)
    mkplots.gridsim_circleplot(simdataGrid, 'O-J', 'Q-H')

    pl.draw()
    return simdataGrid
Пример #3
0
def colorCheck(datfile, nrow, irow, ifiglist=[1, 2], clobber=False, verbose=1):

    sn = stardust.SuperNova(datfile)
    sn.getClassSim('HST_colormag',
                   Nsim=2000,
                   dustmodel='mid',
                   simpriors=True,
                   clobber=clobber,
                   verbose=verbose)

    pkbands = np.unique([
        sn.FLT[i] for i in range(len(sn.MJD))
        if abs(sn.MJD[i] - sn.pkmjdobs) <= sn.pkmjdobserr
    ])
    sn.ClassSim.Ia.samplephot(sn.pkmjdobs,
                              tmatch=sn.pkmjdobserr,
                              bandlist=pkbands)
    sn.ClassSim.Ibc.samplephot(sn.pkmjdobs,
                               tmatch=sn.pkmjdobserr,
                               bandlist=pkbands)
    sn.ClassSim.II.samplephot(sn.pkmjdobs,
                              tmatch=sn.pkmjdobserr,
                              bandlist=pkbands)

    ipk = np.where(np.abs(sn.MJD - sn.pkmjdobs) < sn.pkmjdobserr)[0]

    for ifig, redfilt in zip(ifiglist, ['H', 'J']):
        if redfilt not in pkbands: continue

        fig = pl.figure(ifig)
        ax1 = fig.add_subplot(nrow, 4, 1)

        RpkSimIa = sn.ClassSim.Ia.__dict__['%s%i' %
                                           (redfilt, int(sn.pkmjdobs))]
        RpkSimIbc = sn.ClassSim.Ibc.__dict__['%s%i' %
                                             (redfilt, int(sn.pkmjdobs))]
        RpkSimII = sn.ClassSim.II.__dict__['%s%i' %
                                           (redfilt, int(sn.pkmjdobs))]

        ipkR = np.where(sn.FLT[ipk] == redfilt)[0]
        if not len(ipkR): continue
        snR = sn.MAG[ipk][ipkR][0]
        snRerr = sn.MAGERR[ipk][ipkR][0]

        for icol, bluefilt in zip(range(4), ['W', 'V', 'I', 'Z']):
            ax = fig.add_subplot(nrow, 4, irow * 4 + icol + 1, sharex=ax1)
            if icol == 0: ax.set_ylabel(sn.nickname)
            if irow == 0: ax.set_title('%s-%s' % (bluefilt, redfilt))
            if bluefilt not in pkbands: continue

            ipkB = np.where(sn.FLT[ipk] == bluefilt)[0]
            if not len(ipkB): continue
            snB = sn.MAG[ipk][ipkB][0]
            snBerr = sn.MAGERR[ipk][ipkB][0]

            BpkSimIa = sn.ClassSim.Ia.__dict__['%s%i' %
                                               (bluefilt, int(sn.pkmjdobs))]
            BpkSimIbc = sn.ClassSim.Ibc.__dict__['%s%i' %
                                                 (bluefilt, int(sn.pkmjdobs))]
            BpkSimII = sn.ClassSim.II.__dict__['%s%i' %
                                               (bluefilt, int(sn.pkmjdobs))]

            CpkSimIa = BpkSimIa - RpkSimIa
            CpkSimIbc = BpkSimIbc - RpkSimIbc
            CpkSimII = BpkSimII - RpkSimII

            CIa, cbins = np.histogram(CpkSimIa, bins=np.arange(-5, 12, 0.2))
            CIbc, cbins = np.histogram(CpkSimIbc, bins=np.arange(-5, 12, 0.2))
            CII, cbins = np.histogram(CpkSimII, bins=np.arange(-5, 12, 0.2))

            ax.plot(cbins[:-1], CIa, 'r-', drawstyle='steps-mid')
            ax.plot(cbins[:-1], CIbc, 'g-', drawstyle='steps-mid')
            ax.plot(cbins[:-1], CII, 'b-', drawstyle='steps-mid')

            snC = snB - snR
            snCerr = np.sqrt(snBerr**2 + snRerr**2)
            snCmin = snC - snCerr
            snCmax = snC + snCerr
            if snBerr < 0: snCmin = snC
            if snRerr < 0: snCmax = snC

            ymin, ymax = ax.get_ylim()
            snCbar = patches.Rectangle([snCmin, 0.0],
                                       snCmax - snCmin,
                                       ymax,
                                       color='0.5',
                                       alpha=0.5,
                                       zorder=-100)
            ax.add_patch(snCbar)
            ax.set_xlim([-2, 6])
        fig.suptitle('(W,V,I,Z)-%s band color distributions' % redfilt)
Пример #4
0
def doOneSN(datfile,
            useLuminosityPrior=False,
            modelerror=[0.05, 0.07, 0.07],
            clobber=False,
            testrun=False,
            returnsn=False,
            debug=False):

    if debug:
        import pdb
        pdb.set_trace()

    import stardust
    start = time.time()
    try:
        sn = stardust.SuperNova(datfile)
        sn.PEAKMJD = sn.MJD[sn.signoise.argmax()]

        thistypeindex = int(sn.SIM_NON1a.split()[0])
        thistype = modelIndexDict[thistypeindex][0]
        thismodel = sn.SIM_COMMENT.split('=')[-1].split('.')[0].strip()
        if thistype == 'Ia': omittemp = None
        else: omittemp = thismodel

        if testrun:
            pIa, pIbc, pII = 0, 0, 0
            chi2Ia, chi2Ibc, chi2II = 0, 0, 0
            Ndof = 0
            bestIbc = 'None'
            bestII = 'None'
        else:
            sn.doGridClassify(clobber=clobber,
                              useLuminosityPrior=useLuminosityPrior,
                              kcorfile='DES/kcor_DES_grizY.fits',
                              modelerror=modelerror,
                              omitTemplateIbc=omittemp,
                              omitTemplateII=omittemp,
                              nlogz=1,
                              nlumipar=20,
                              ncolorpar=20,
                              ncolorlaw=1,
                              npkmjd=20)
            pIa, pIbc, pII = sn.PIa, sn.PIbc, sn.PII
            chi2Ia, chi2Ibc, chi2II = min(sn.chi2Ia) / sn.Ndof, min(
                sn.chi2Ibc) / sn.Ndof, min(sn.chi2II) / sn.Ndof
            Ndof = sn.Ndof
            bestIbc = stardust.constants.IBCMODELS[
                '%03i' % sn.maxLikeIbcModel.LUMIPAR][1]
            bestII = stardust.constants.IIMODELS['%03i' %
                                                 sn.maxLikeIIModel.LUMIPAR][1]

        end = time.time()

        outstr = '%15s %4s %5.3f %12s  %6.3f %6.3f %6.3f   %7.3f  %7.3f  %7.3f    %3i   %5i  %12s  %12s' % (
            os.path.basename(datfile), thistype, sn.z,
            thismodel, pIa, pIbc, pII, chi2Ia, chi2Ibc, chi2II, Ndof,
            int(end - start), bestIbc, bestII)

    except Exception as exc:
        print('classify error : %s' % exc)
        end = time.time()
        bestIbc, bestII = 'None', 'None'
        outstr = '%15s %4s %5.3f %12s  %6.3f %6.3f %6.3f   %7.3f  %7.3f  %7.3f    %3i   %5i   %12s  %12s  %s' % (
            os.path.basename(datfile), thistype, sn.z, thismodel, -9, -9, -9,
            -9, -9, -9, -9, int(end - start), bestIbc, bestII, exc)

    if returnsn:
        print(outstr)
        return (sn)
    return (outstr)
Пример #5
0
def mkDemoFig(simdata,
              linelevels=[0, 0.82],
              plotstyle='contourf',
              Nbins=80,
              showsn=False):
    """ construct the medium-band demo figure for the FrontierSN proposal:
    filter bandpasses on the left for three redshifts, two color-color plots on the
    right with SN observation points overlaid """
    import stardust
    import snanasim

    w1a, f1a = stardust.snsed.getsed(
        sedfile='/usr/local/SNDATA_ROOT/snsed/Hsiao07.dat', day=0)

    # first the band-pass plots on the left
    z = 1.8
    w1az = w1a * (1 + z)
    f1az = f1a / f1a.max() / 2.
    ax18 = pl.subplot(3, 2, 1)
    ax18.plot(w1az, f1az, ls='-', lw=0.7, color='0.5', label='_nolegend_')
    ax18.plot(w127, f127, ls='-', color='DarkOrchid', label='F127M')
    ax18.plot(w139, f139, ls='-', color='Teal', label='F139M')
    ax18.plot(w153, f153, ls='-', color='Maroon', label='F153M')
    ax18.fill_between(w1az,
                      f1az,
                      where=((w1az > 12400) & (w1az < 13120)),
                      color='DarkOrchid',
                      alpha=0.3)
    ax18.fill_between(w1az,
                      f1az,
                      where=((w1az > 13500) & (w1az < 14150)),
                      color='teal',
                      alpha=0.3)
    ax18.fill_between(w1az,
                      f1az,
                      where=((w1az > 15000) & (w1az < 15700)),
                      color='Maroon',
                      alpha=0.3)
    ax18.text(0.95,
              0.4,
              'SNIa\n@ z=%.1f' % (z),
              color='k',
              ha='right',
              va='bottom',
              fontweight='bold',
              transform=ax18.transAxes,
              fontsize='large')
    pl.setp(ax18.get_xticklabels(), visible=False)
    pl.setp(ax18.get_yticklabels(), visible=False)
    ax18.text(12700,
              0.65,
              'F127M',
              ha='right',
              va='center',
              color='DarkOrchid',
              fontweight='bold')
    ax18.text(13900,
              0.65,
              'F139M',
              ha='center',
              va='center',
              color='Teal',
              fontweight='bold')
    ax18.text(15300,
              0.65,
              'F153M',
              ha='left',
              va='center',
              color='Maroon',
              fontweight='bold')

    z = 2.0
    w1az = w1a * (1 + z)
    f1az = f1a / f1a.max() / 2.
    ax20 = pl.subplot(3, 2, 3, sharex=ax18)
    ax20.plot(w127, f127, ls='-', color='DarkOrchid', label='F127M')
    ax20.plot(w139, f139, ls='-', color='Teal', label='F139M')
    ax20.plot(w153, f153, ls='-', color='Maroon', label='F153M')
    ax20.plot(w1az, f1az, ls='-', lw=0.7, color='0.5', label='_nolegend_')
    ax20.fill_between(w1az,
                      f1az,
                      where=((w1az > 12400) & (w1az < 13120)),
                      color='DarkOrchid',
                      alpha=0.3)
    ax20.fill_between(w1az,
                      f1az,
                      where=((w1az > 13500) & (w1az < 14150)),
                      color='Teal',
                      alpha=0.3)
    ax20.fill_between(w1az,
                      f1az,
                      where=((w1az > 15000) & (w1az < 15700)),
                      color='Maroon',
                      alpha=0.3)
    ax20.text(0.95,
              0.4,
              'z=%.1f' % (z),
              color='k',
              ha='right',
              va='bottom',
              fontweight='bold',
              transform=ax20.transAxes,
              fontsize='large')
    pl.setp(ax20.get_xticklabels(), visible=False)
    pl.setp(ax20.get_yticklabels(), visible=False)

    z = 2.2
    w1az = w1a * (1 + z)
    f1az = f1a / f1a.max() / 2.
    ax22 = pl.subplot(3, 2, 5, sharex=ax18)
    ax22.plot(w127, f127, ls='-', color='DarkOrchid', label='F127M')
    ax22.plot(w139, f139, ls='-', color='Teal', label='F139M')
    ax22.plot(w153, f153, ls='-', color='Maroon', label='F153M')
    ax22.plot(w1az, f1az, ls='-', lw=0.7, color='0.5', label='_nolegend_')
    ax22.fill_between(w1az,
                      f1az,
                      where=((w1az > 12400) & (w1az < 13120)),
                      color='DarkOrchid',
                      alpha=0.3)
    ax22.fill_between(w1az,
                      f1az,
                      where=((w1az > 13500) & (w1az < 14150)),
                      color='Teal',
                      alpha=0.3)
    ax22.fill_between(w1az,
                      f1az,
                      where=((w1az > 15000) & (w1az < 15700)),
                      color='Maroon',
                      alpha=0.3)
    ax22.text(0.95,
              0.4,
              'z=%.1f' % (z),
              color='k',
              ha='right',
              va='bottom',
              fontweight='bold',
              transform=ax22.transAxes,
              fontsize='large')
    pl.setp(ax22.get_yticklabels(), visible=False)
    ax22.set_xlabel('Observed Wavelength [\AA]')

    ax18.set_xlim(9000, 19900)

    # ------------------------------------------------------------
    # Now the color-color plots on the right

    if type(simdata) == str: simdata = snanasim.readSimDataMC(simdata)
    simIa, simIbc, simII = simdata

    if showsn:
        sn = stardust.SuperNova(_medbanddat)
        H, dH = sn.MAG[np.where(sn.FLT == 'H')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'H')[0][0]]
        J, dJ = sn.MAG[np.where(sn.FLT == 'J')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'J')[0][0]]
        N, dN = sn.MAG[np.where(sn.FLT == 'N')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'N')[0][0]]
        Y, dY = sn.MAG[np.where(sn.FLT == 'Y')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'Y')[0][0]]
        L, dL = sn.MAG[np.where(sn.FLT == 'L')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'L')[0][0]]
        O, dO = sn.MAG[np.where(sn.FLT == 'O')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'O')[0][0]]
        P, dP = sn.MAG[np.where(sn.FLT == 'P')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'P')[0][0]]
        Q, dQ = sn.MAG[np.where(sn.FLT == 'Q')[0][0]], sn.MAGERR[np.where(
            sn.FLT == 'Q')[0][0]]

    ax1 = pl.subplot(2, 2, 2)
    stardust.simplot.plotColorColor(simII,
                                    'Q-H',
                                    'O-J',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    stardust.simplot.plotColorColor(simIbc,
                                    'Q-H',
                                    'O-J',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    stardust.simplot.plotColorColor(simIa,
                                    'Q-H',
                                    'O-J',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    if showsn:
        ax1.errorbar(Q - H,
                     O - J,
                     np.sqrt(dO**2 + dJ**2),
                     np.sqrt(dQ**2 + dH**2),
                     color='k',
                     mfc='w',
                     mec='k',
                     mew=2,
                     elinewidth=2,
                     marker='D')

    ax1.xaxis.set_ticks_position('top')
    ax1.xaxis.set_ticks_position('both')
    ax1.xaxis.set_label_position('top')
    ax1.yaxis.set_ticks_position('right')
    ax1.yaxis.set_ticks_position('both')
    ax1.yaxis.set_label_position('right')

    ax2 = pl.subplot(2, 2, 4, sharex=ax1)
    stardust.simplot.plotColorColor(simII,
                                    'Q-H',
                                    'P-N',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    stardust.simplot.plotColorColor(simIbc,
                                    'Q-H',
                                    'P-N',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    stardust.simplot.plotColorColor(simIa,
                                    'Q-H',
                                    'P-N',
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    if showsn:
        ax2.errorbar(Q - H,
                     P - N,
                     np.sqrt(dP**2 + dN**2),
                     np.sqrt(dQ**2 + dH**2),
                     color='k',
                     mfc='w',
                     mec='k',
                     mew=2,
                     elinewidth=2,
                     marker='D')
    ax2.yaxis.set_ticks_position('right')
    ax2.yaxis.set_ticks_position('both')
    ax2.yaxis.set_label_position('right')
    ax2.text(0.2,
             -0.18,
             'Ia',
             ha='left',
             va='top',
             color='DarkRed',
             fontsize='large',
             fontweight='bold')
    ax2.text(-0.2,
             0.25,
             'Ib/c',
             ha='left',
             va='top',
             color='DarkGreen',
             fontsize='large',
             fontweight='bold')
    ax2.text(-0.05,
             0.21,
             'II',
             ha='left',
             va='bottom',
             color='DarkBlue',
             fontsize='large',
             fontweight='bold')
    ax2.set_ylabel(ax2.get_ylabel(), rotation=-90, color='teal')
    ax2.set_xlabel(ax2.get_xlabel(), color='maroon')
    ax1.set_ylabel(ax1.get_ylabel(), rotation=-90, color='DarkOrchid')
    ax1.set_xlabel(ax1.get_xlabel(), color='maroon')

    fig = pl.gcf()
    fig.subplots_adjust(left=0.03,
                        right=0.90,
                        top=0.90,
                        bottom=0.12,
                        hspace=0,
                        wspace=0.08)

    ax1.set_xlim(-0.28, 0.38)
    ax1.set_ylim(-0.54, 0.2)
    ax2.set_ylim(-0.3, 0.32)
    ax1.text(0.25,
             -0.19,
             'z=1.8',
             color='k',
             ha='left',
             va='bottom',
             fontweight='bold',
             fontsize='large')
    ax1.text(-0.15,
             -0.32,
             'z=2.0',
             color='k',
             ha='right',
             va='bottom',
             fontweight='bold',
             fontsize='large')
    ax1.text(0.29,
             -0.51,
             'z=2.2',
             color='k',
             ha='right',
             va='bottom',
             fontweight='bold',
             fontsize='large')
    ax1.plot([0.1, 0.24], [-0.2, -0.175],
             ls='-',
             marker=' ',
             color='k',
             lw=0.8)
    ax1.plot([-0.14, -0.07], [-0.28, -0.185],
             ls='-',
             marker=' ',
             color='k',
             lw=0.8)

    ax2.text(0.2,
             0.21,
             '1.8',
             color='k',
             ha='left',
             va='bottom',
             fontweight='bold',
             fontsize='large')
    ax2.text(-0.18,
             -0.27,
             '2.0',
             color='k',
             ha='right',
             va='bottom',
             fontweight='bold',
             fontsize='large')
    ax2.text(0.3,
             0.01,
             '2.2',
             color='k',
             ha='left',
             va='bottom',
             fontweight='bold',
             fontsize='large')
Пример #6
0
def mkcirclefigMC(simdataMC=None,
                  linelevels=[0, 0.82],
                  plotstyle='contourf',
                  Nbins=80,
                  Nsim=2000,
                  clobber=0,
                  verbose=1,
                  snanadatfile=_SNANADATFILE):
    """  Plot the results of a SNANA monte carlo simulation as a circle diagram.

    :param simdataMC:
    :param linelevels:
    :param plotstyle:
    :param Nbins:
    :param nsim:
    :param clobber:
    :param verbose:
    :param snanadatfile:
    :return:
    """
    import snanasim
    sn = stardust.SuperNova(snanadatfile)

    if simdataMC is None:
        simdataMC = snanasim.dosimMC(sn,
                                     Nsim=Nsim,
                                     bands='XI78YJNHLOPQ',
                                     clobber=clobber,
                                     verbose=verbose)
    simIa, simIbc, simII = simdataMC

    mjdmedband = sn.MJD[np.where((sn.FLT == '7') | (sn.FLT == '8')
                                 | (sn.FLT == 'P'))]
    mjdobs = np.median(mjdmedband)

    print('Binning up MC sim for color-color diagram...')
    pl.clf()
    ax1 = pl.subplot(2, 2, 1)
    stardust.simplot.plotColorColor(simIa,
                                    '7-I',
                                    'P-N',
                                    binrange=[[-0.2, 0.8], [-0.5, 0.5]],
                                    mjdrange=[mjdobs, mjdobs],
                                    tsample=1,
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    #stardust.simplot._plot_colorcolor_singlesim( simIbc, '7-I','P-N', binrange=[[-0.2,0.8],[-0.5,0.5]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )
    #stardust.simplot._plot_colorcolor_singlesim( simII,  '7-I','P-N', binrange=[[-0.2,0.8],[-0.5,0.5]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )
    ax2 = pl.subplot(2, 2, 2)
    stardust.simplot.plotColorColor(simIa,
                                    '8-I',
                                    'P-N',
                                    binrange=[[-0.6, 0.4], [-0.5, 0.5]],
                                    mjdrange=[mjdobs, mjdobs],
                                    tsample=1,
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    #stardust.simplot._plot_colorcolor_singlesim( simIbc,  '8-I','P-N', binrange=[[-0.6,0.4],[-0.5,0.5]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )
    #stardust.simplot._plot_colorcolor_singlesim( simII,   '8-I','P-N', binrange=[[-0.6,0.4],[-0.5,0.5]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )
    ax3 = pl.subplot(2, 2, 3)
    stardust.simplot.plotColorColor(simIa,
                                    '7-I',
                                    '8-I',
                                    binrange=[[-0.2, 0.8], [-0.6, 0.4]],
                                    mjdrange=[mjdobs, mjdobs],
                                    tsample=1,
                                    plotstyle=plotstyle,
                                    linelevels=linelevels,
                                    Nbins=Nbins,
                                    sidehist=False)
    #stardust.simplot._plot_colorcolor_singlesim( simIbc,  '7-I','8-I', binrange=[[-0.2,0.8],[-0.6,0.4]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )
    #stardust.simplot._plot_colorcolor_singlesim( simII,   '7-I','8-I', binrange=[[-0.2,0.8],[-0.6,0.4]], mjdrange=[mjdobs,mjdobs], tsample=1, plotstyle=plotstyle, linelevels=linelevels, Nbins=Nbins, sidehist=False )

    pl.draw()
    return simdataMC
Пример #7
0
def mkfig3d(
    simdata,
    dz=0.05,
    snanadatfile=_SNANADATFILE,
):
    """ Plot the results of a SNANA monte carlo simulation as a 3-D circle
    diagram.

    :param simdata:
    :param dz:
    :param snanadatfile:
    :return:
    """
    from mpl_toolkits.mplot3d.axes3d import Axes3D
    from matplotlib import cm
    import mpltools
    from pytools import plotsetup
    fig = plotsetup.fullpaperfig(1, [10, 10])

    sn = stardust.SuperNova(snanadatfile)
    simIa, simIbc, simII = simdata
    ax1 = fig.add_axes([0.12, 0.12, 0.85, 0.85], projection='3d')

    c7I, c8I, cPN = get_colors(simII)
    ax1.plot3D(c7I,
               c8I,
               cPN,
               marker='o',
               color='k',
               alpha=1,
               ls=' ',
               mew=0,
               label='Type II')

    c7I, c8I, cPN = get_colors(simIbc)
    ax1.plot3D(c7I,
               c8I,
               cPN,
               marker='o',
               color='sienna',
               alpha=1,
               ls=' ',
               mew=0,
               label='Type Ibc')

    zbins, c7I, c8I, cPN = get_colors_binned_by_z(sn, simIa, dz=dz)
    mpltools.color.cycle_cmap(len(zbins), cmap=cm.gist_rainbow_r, ax=ax1)
    for iz in range(len(zbins) - 1):
        z0, z1 = zbins[iz], zbins[iz + 1]
        #if dz>=0.1 : zmid = round(np.mean([z0,z1]),1)
        #elif dz>=0.01 : zmid = round(np.mean([z0,z1]),2)
        ax1.plot3D(c7I[iz],
                   c8I[iz],
                   cPN[iz],
                   marker='o',
                   alpha=1,
                   ls=' ',
                   mew=0,
                   label='%.2f-%.2f' % (z0, z1))

    ax1.set_xlim(-0.1, 0.5)
    ax1.set_ylim(-0.4, 0.2)
    ax1.set_zlim(-0.3, 0.3)

    ax1.legend(loc='upper left',
               ncol=2,
               numpoints=1,
               frameon=False,
               handletextpad=0.3,
               handlelength=0.2)
    ax1.set_xlabel('F763M-F814W')
    ax1.set_ylabel('F845M-F140W')
    ax1.set_zlabel('F139M-F140W')