Ejemplo n.º 1
0
def check_m5sigma_depth():
    """
    Compare Philippe Gris' m5 with mine.
    """
    log = snsim.OpSimObsLog(NTuple.fromtxt('Observations_DD_290_LSSTPG.txt'))
    lsstpg = psf.find('LSSTPG')
    sky_flux = lsstpg.mag_to_flux(log.mag_sky, log.band)
    m5 = lsstpg.mag_lim(30., sky_flux, log.seeing, log.band)

    pl.figure()
    pl.plot(log.mjd, log.m5sigmadepth, marker='.', color='gray', ls='')
    pl.plot(log.mjd, m5, marker='.', color='r', ls='')
    pl.xlabel('MJD')

    for b in np.unique(log.band):
        idx = log.band == b
        pl.figure()
        pl.plot(log.mjd[idx],
                m5[idx] - log.m5sigmadepth[idx],
                marker='.',
                color='gray',
                ls='')
        pl.title(b)
    pl.xlabel('MJD')
    pl.xlabel('$\Delta m_{5\sigma} [%s]$' % b)
Ejemplo n.º 2
0
def main_depth_wide(
    instr_name='LSSTPG',
    #                    bands=['g', 'r', 'i', 'z'],
    SNR=dict(zip(['LSSTPG::' + b for b in "griz"], [30., 40., 30., 20.])),
    target={
        'LSSTPG::g': (24.83, 3.),  # 23.86
        'LSSTPG::r': (24.35, 3.),  # 23.82
        'LSSTPG::i': (23.88, 3.),  # 23.51
        'LSSTPG::z': (23.30, 3.),  # 
    }):

    instr = psf.find(instr_name)
    bands = SNR.keys()

    # Wide survey
    logs = [
        snsim.OpSimObsLog(NTuple.fromtxt(fn))
        for fn in glob.glob('OpSimLogs/*_WFD_*.txt')
    ]
    m = np.hstack([log.median_values() for log in logs])
    lims = f5_cadence_lims(zs=[0.1, 0.2, 0.3, 0.4, 0.5], SNR=SNR)
    #                           bands=[instr_name + '::' + b for b in bands])
    for bn in bands:
        f5_cadence_plot(
            instr,
            bn,  # instr_name + '::' + bn, 
            lims,
            mag_range=(21., 24.8),
            dt_range=(0.5, 30.),
            median_log_summary=m,
            target=target)
        pl.gcf().savefig('m5_cadence_limits_wide_%s.png' % bn.split(':')[-1],
                         bbox_inches='tight')
        pl.gcf().savefig('m5_cadence_limits_wide_%s.pdf' % bn.split(':')[-1],
                         bbox_inches='tight')
Ejemplo n.º 3
0
 def __init__(self, pxlobs, z=0.5, rf_phase_range=(-20., 45.), nside=64, etc=None, lc_template=None, model_filename=None):
     """
     Constructor. Takes a file 
     """
     self.pixel_obs = pxlobs
     self.mjd = np.unique(np.floor(pxlobs['mjd'])).astype(int)
     self.mjd = self.mjd[self.mjd>0]
     self.nside, self.npix = nside, hp.nside2npix(nside)
     self.rf_phase_range = np.array(rf_phase_range)
     self.min_rf_phase_range = np.array(rf_phase_range) + np.array([10., -10.])
     self.accept = []
     self.fig_odometer = 0
     self.cache_mjd_min = 0.
     self.cache_mjd_max = 0.
     self.cache = None
     
     # add an etc
     logging.info('loading ETC')
     self.etc = psf.find(instrument_name) if etc is None else etc
     suffix = self.etc.instrument.name + '::'
     self.pixel_obs['bandname'][:] = np.core.defchararray.add(suffix, self.pixel_obs['band'])
     
     # add a LC model
     self.sn = np.rec.fromarrays(([0.] * 7),
                                 names=['z', 'dL', 'DayMax', 'X1', 'Color', 'ra', 'dec'])
     self.sn['X1'], self.sn['Color'] = -2., 0.2
     logging.info('instantiating Cosmo model')
     self.cosmo = cosmo.CosmoLambda()
     logging.info('loading SALT2 from: %s' % model_filename)
     #        self.lcmodel = snsim.init_lc_model(np.unique(self.pixel_obs['bandname']),
     #                                           model_filename)
     logging.info('done.')        
     
     # add something to manage the LC templates
     #        print lc_template
     if lc_template is not None:
         self.lc_template_cache = self._build_lc_template_cache(lc_template)
     else:
         self.lc_template_cache = None
Ejemplo n.º 4
0
def main_depth_ddf(
    instr_name='LSSTPG',
    #                   bands=['r', 'i', 'z', 'y'],
    SNR=dict(zip(['LSSTPG::' + b for b in "grizy"],
                 [25., 25., 60., 35., 20.])),
    target={  # 'LSSTPG::g': (26.91, 3.), # was 25.37
        'LSSTPG::r': (26.43, 3.),  # was 25.37
        'LSSTPG::i': (26.16, 3.),  # was 25.37      # could be 25.3 (400-s)
        'LSSTPG::z': (25.56, 3.),  # was 24.68      # could be 25.1 (1000-s)
        'LSSTPG::y': (24.68, 3.)
    }):  # was 24.72

    bands = SNR.keys()
    instr = psf.find(instr_name)

    # DDF survey
    #    logs = [snsim.OpSimObsLog(NTuple.fromtxt(fn)) for fn in glob.glob('OpSimLogs_LSST/*_DD_*.txt')]
    logs = [
        snsim.OpSimObsLog(NTuple.fromtxt(fn))
        for fn in glob.glob('OpSimLogs/*_DD_*.txt')
    ]
    m = np.hstack([log.median_values() for log in logs])
    lims = f5_cadence_lims(zs=[0.6, 0.7, 0.8, 0.9, 1.0, 1.1], SNR=SNR)
    #                           bands=[instr_name + '::' + b for b in bands])
    for bn in bands:
        f5_cadence_plot(
            instr,
            bn,  # instr_name + '::' + bn, 
            lims,
            target=target,
            mag_range=(23., 26.5),
            median_log_summary=m)
        pl.gcf().savefig('m5_cadence_limits_%s.png' % bn.split(':')[-1],
                         bbox_inches='tight')
        pl.gcf().savefig('m5_cadence_limits_%s.pdf' % bn.split(':')[-1],
                         bbox_inches='tight')
Ejemplo n.º 5
0
    # open the obslog
    with np.load(args.obslog) as f:
        obslog = f['l']

    # global stats
    #    r = cadence_stats(cad, bands='ugrizy', title=args.cadence_filename)

    # numbers of visits
    plot_number_of_visits(obslog,
                          nside=args.nside,
                          max_nv=400,
                          output_dir=args.output_dir)

    # average seeing
    plot_average_seeing(obslog, nside=args.nside, output_dir=args.output_dir)

    # survey depth
    etc = psf.find('LSSTPG')
    plot_survey_depth(obslog,
                      etc,
                      nside=args.nside,
                      maxv=28.,
                      output_dir=args.output_dir)

    # ... aaaaand finally ! (long !)
    if True:
        plot_seasons(obslog, nside=args.nside, output_dir=args.output_dir)
        plot_average_cadence(obslog,
                             nside=args.nside,
                             output_dir=args.output_dir)
Ejemplo n.º 6
0
def plot_figure_3():
    log = snsim.OpSimObsLog(NTuple.fromtxt('Observations_DD_290_LSSTPG.txt'))
    r = log.split()
    log = r[2]

    # Wide
    lsstpg = psf.find('LSSTPG')
    r = plot_sigc_vs_z(lsstpg,
                       delta=4.,
                       exptimes={
                           'LSSTPG::g': 30,
                           'LSSTPG::r': 30,
                           'LSSTPG::i': 30.,
                           'LSSTPG::z': 30.
                       },
                       zmax=0.5,
                       sigc_filename='sigc_lsstpg_wide_30',
                       snr_filename='snr_lsstpg_wide_30')
    r = plot_sigc_vs_z(lsstpg,
                       delta=3.,
                       exptimes={
                           'LSSTPG::g': 30,
                           'LSSTPG::r': 30,
                           'LSSTPG::i': 30.,
                           'LSSTPG::z': 30.
                       },
                       zmax=0.5,
                       sigc_filename='sigc_lsstpg_wide_30_cad3',
                       snr_filename='snr_lsstpg_wide_30_cad3')
    r = plot_sigc_vs_z(lsstpg,
                       delta=4.,
                       exptimes={
                           'LSSTPG::g': 30,
                           'LSSTPG::r': 30,
                           'LSSTPG::i': 30.,
                           'LSSTPG::z': 30.
                       },
                       zmax=0.5,
                       sigc_filename='sigc_lsstpg_wide_30_minion',
                       snr_filename='snr_lsstpg_wide_30_minion',
                       reference_log=log)

    # DDF
    r = plot_sigc_vs_z(lsstpg,
                       delta=4.,
                       exptimes={
                           'LSSTPG::r': 600,
                           'LSSTPG::i': 600.,
                           'LSSTPG::z': 780.,
                           'LSSTPG::y': 600
                       },
                       zmax=1.1,
                       sigc_filename='sigc_lsstpg_ddf_600',
                       snr_filename='snr_lsstpg_ddf_600')
    r = plot_sigc_vs_z(lsstpg,
                       delta=3.,
                       exptimes={
                           'LSSTPG::r': 1200,
                           'LSSTPG::i': 1800.,
                           'LSSTPG::z': 1800.,
                           'LSSTPG::y': 1800
                       },
                       zmax=1.1,
                       sigc_filename='sigc_lsstpg_ddf_1800_cad3',
                       snr_filename='snr_lsstpg_ddf_1800_cad3')

    #    r = plot_sigc_vs_z(lsstpg,  delta=3., exptimes={'LSSTPG::r': 600, 'LSSTPG::i': 600., 'LSSTPG::z': 780., 'LSSTPG::y': 600},
    #                       zmax=1.1, sigc_filename='sigc_lsstpg_ddf_1200_minion', snr_filename='snr_lsstpg_ddf_1200_minion', reference_log=log)
    #    r = plot_sigc_vs_z(lsstpg,  delta=3., exptimes={'LSSTPG::r': 1200, 'LSSTPG::i': 1200., 'LSSTPG::z': 1200., 'LSSTPG::y': 1200},
    #                       zmax=1.1, sigc_filename='sigc_lsstpg_ddf_1200_cad2', snr_filename='snr_lsstpg_ddf_1200_cad2')

    lsst = psf.find('LSST')
    r = plot_sigc_vs_z(lsst,
                       delta=4.,
                       exptimes={
                           'LSST::r': 600.,
                           'LSST::i': 600.,
                           'LSST::z': 780.,
                           'LSST::y4': 600
                       },
                       zmax=1.1,
                       sigc_filename='sigc_lsst_ddf_600',
                       snr_filename='snr_lsst_ddf_600')
    r = plot_sigc_vs_z(lsst,
                       delta=3.,
                       exptimes={
                           'LSST::r': 1200,
                           'LSST::i': 1800.,
                           'LSST::z': 1800.,
                           'LSST::y4': 1800
                       },
                       zmax=1.1,
                       sigc_filename='sigc_lsst_ddf_1800_cad3',
                       snr_filename='snr_lsst_ddf_1800_cad3')
Ejemplo n.º 7
0
def plot_lc_snr(filename='Observations_DD_290_LSSTPG.txt',
                z=1.1,
                X1=0.,
                Color=0.,
                DayMax=0.,
                bands=['LSSTPG::' + b for b in "rizy"],
                rest_frame_margins=(-15., 30.),
                snr_min=20.,
                fig=None):
    """Return a metric from a log and a fiducial supernova. 

    Args:
      z, X1, Color, DayMax: fiducial supernova 
      
    """
    lsstpg = psf.find('LSSTPG')
    colors = band_colors(lsstpg)
    mjd, shapes = get_pulse_shapes(bands, z=z, X1=X1, Color=Color)
    mjd_margins = rest_frame_margins[0] * (1. +
                                           z), rest_frame_margins[1] * (1. + z)

    log = snsim.OpSimObsLog(NTuple.fromtxt(filename))
    r = log.split(delta=100.)

    #    f5 = lsstpg.mag_to_flux(log.m5sigmadepth, log.band)
    flux_sky = lsstpg.mag_to_flux(log.mag_sky, log.band)
    f5 = lsstpg.flux_lim(log.exptime, flux_sky, log.seeing, log.band)
    #    print lsstpg.mag_lim(log.exptime, flux_sky, log.seeing, log.band)
    #    print lsstpg.mag_to_flux(lsstpg.mag_lim(log.exptime, flux_sky, log.seeing, log.band), log.band)

    if fig is None:
        fig = pl.figure(figsize=(12, 12))
    ax = None

    mjd = np.arange(log.mjd.min(), log.mjd.max(), 1.)

    for i, bn in enumerate(bands):
        if ax is None:
            ax = pl.subplot(len(bands), 1, i + 1)
            pl.title('$SN[X1=%5.1f,C=%5.1f]\ at\ z=%4.2f$ [%s]' %
                     (X1, Color, z, filename))
        else:
            ax = pl.subplot(len(bands), 1, i + 1)

        # runs
        for rr in r:
            pl.axvspan(rr.mjd.min(), rr.mjd.max(), color='gray', alpha=0.25)
            pl.axvspan(rr.mjd.min() - rest_frame_margins[0],
                       rr.mjd.max() - rest_frame_margins[1],
                       color='gray',
                       alpha=0.35)

        # plot the cadence metric
        idx = log.band == bn
        c = CadenceMetric(log.mjd[idx], f5[idx], log.band[idx], shapes[bn])
        y = c(mjd)
        pl.plot(mjd, y, color=colors[bn], marker='.', ls=':')
        pl.ylabel('$SNR [%s]$' % bn.split(':')[-1],
                  fontsize=16)  #  color=colors[bn])
        pl.axhline(snr_min, ls='--', color='r')
        pl.ylim((0., max((y.max(), snr_min + 1))))

        # plot the average number of observations averaged over a
        # window of ~ 21 days.
        c_sched = SimpleCadenceMetric(log.mjd[idx], 21.)
        print c_sched.sumw.min(), c_sched.sumw.max()
        y_sched = c_sched(mjd)
        ax = pl.gca().twinx()
        ax.plot(mjd, y_sched, color='gray', ls='-')
        pl.ylim((0., 0.28))
        pl.ylabel("Cadence [day$^{-1}$]", color='black')
        cad = 1. / (4. * (1. + z))
        pl.axhline(cad, ls=':', color='gray')

        if i < len(bands) - 1:
            ax.get_xaxis().set_ticklabels([])
    pl.subplots_adjust(hspace=0.06)
    pl.xlabel('$MJD$ [days]', fontsize=16)

    return c
Ejemplo n.º 8
0
    bands = 'grizy'
    opsim_dir = '/pbs/throng/lsst/users/gris/Read_sqlite_python3/OpSimLogs_' + simu_name + '_' + thetype + '/WFD'
    opsim_dir += '/Season_' + str(season)
    opsim_files = glob.glob(opsim_dir + '/WFD_*.txt')
    MultiProc_Median_log_summary(opsim_files, season, bands, simu_name,
                                 thetype)

if display:

    display_metric = True
    Plots = False

    if display_metric:

        atmos = False
        instr_snsim = psf.find('LSSTPG')
        instr = Telescope(atmos=atmos, aerosol=False, airmass=-1.)
        instrb = Telescope(atmos=True, aerosol=False, airmass=1.2)
        zs = [0.1, 0.2, 0.3, 0.4, 0.5]
        SNR = dict(zip(['LSSTPG::' + b for b in "griz"], [30., 40., 30., 20.]))
        SNR_sncosmo = dict(zip([b for b in "griz"], [30., 40., 30., 20.]))

        bands = SNR.keys()

        target = {
            'g': (24.83, 3.),  # 23.86
            'r': (24.35, 3.),  # 23.82
            'i': (23.88, 3.),  # 23.51
            'z': (23.30, 3.)
        }