Exemplo n.º 1
0
def main(args):
    logger.info('Loading data from %s', args.filename)
    with fits.open(args.filename) as infile:
        flux = infile['flux'].data
        detflux = infile['casudet'].data

    logger.debug('Computing statistics')

    # Remember detflux is in magnitudes
    med_mags = np.median(detflux, axis=1)
    med_flux = np.median(flux, axis=1)

    undetrended_frms = flux.std(axis=1) / med_flux
    detrended_frms = detflux.std(axis=1)

    logger.info('Plotting to %s', args.output)
    with subplots(xlabels=['Magnitude'], ylabels=['Fractional rms']) as (fig, axes):
        axes[0].semilogy(med_mags, undetrended_frms, '.', alpha=0.3, label='Raw')
        axes[0].semilogy(med_mags, detrended_frms, '.', alpha=0.3, label='CASU')
        axes[0].set_xlim(10, 18)
        axes[0].set_ylim(1E-3, 1E-1)
        axes[0].legend(loc='best')
        axes[0].grid(True, which='both')

    fig.savefig(args.output, bbox_inches='tight')
Exemplo n.º 2
0
def main(args):
    if args.verbose:
        logger.setLevel('DEBUG')
    logger.debug(args)

    with fits.open(args.filename) as infile:
        imagelist = infile['imagelist'].data
        imag = -2.5 * np.log10(infile['flux'].data)
        detflux = infile['casudet'].data

    mjd = imagelist['tmid']
    mjd0 = int(mjd.min())
    mjd -= mjd0
    normalised_flux = detflux - np.median(detflux, axis=1)[:, np.newaxis]
    normalised_raw = imag - np.median(imag, axis=1)[:, np.newaxis]

    with subplots() as (fig, axes):

        l, med, u = compute_stats(normalised_flux)
        err = (u - l) / np.sqrt(normalised_flux.shape[0])
        errorbar(axes[0], mjd, med, err, zorder=10)
        axes[0].plot(mjd, med, '.r', zorder=11)
        ylims = axes[0].get_ylim()

        med_detrended = np.median(med)
        axes[0].axhline(med_detrended, color='k', ls='--', zorder=50)
        axes[0].axhline(med_detrended + 1E-3, color='k', ls=':', zorder=50)
        axes[0].axhline(med_detrended - 1E-3, color='k', ls=':', zorder=50)

        l, med, u = compute_stats(normalised_raw)
        err = (u - l) / np.sqrt(normalised_raw.shape[0])
        errorbar(axes[0], mjd, med, err, zorder=5)
        axes[0].plot(mjd, med, '.k', zorder=6)
        axes[0].set_ylim(*ylims)

        for ax in axes:
            ax.invert_yaxis()

        axes[0].set_ylabel(r'Raw')
        axes[0].set_ylabel(r'Post-CASU')
        axes[-1].set_xlabel(r'MJD - {}'.format(mjd0))

    fig.savefig(args.output)
Exemplo n.º 3
0
def main(args):
    if args.verbose:
        logger.setLevel('DEBUG')
    logger.debug(args)

    logger.info('Reading autoguider stats from %s', args.filename)
    imagelist = fits.getdata(args.filename)

    colours = ['#d95f02', '#1b9e77']
    mjd = imagelist['tmid']
    mjd0 = int(mjd.min())
    mjd -= mjd0
    keys = ['ag_err', 'ag_corr', 'ag_delt']
    axes_labels = ['x', 'y']
    full_keys = (a + b for (a, b) in product(keys, axes_labels))
    with subplots(6, 1, sharex=True, figsize=(11, 11)) as (fig, axes):
        for (key, ax, colour) in zip(full_keys, axes, cycle(colours)):
            logger.debug('Plotting %s', key)
            ax.plot(mjd, imagelist[key], '.', color=colour)
            ax.set_ylabel(key)
        axes[-1].set_xlabel(r'MJD - {}'.format(mjd0))

    logger.info('Rendering to %s', args.output)
    fig.savefig(args.output, bbox_inches='tight')