Esempio n. 1
0
def test_one(plate, mjd, all_fibers, args):
    exps = []

    if args.exposure is None:
        if args.cc:
            exps.append(('coadd',
                        load_coadded_spectra(plate, mjd, all_fibers[all_fibers <= 500], not args.no_sky),
                        load_coadded_spectra(plate, mjd, all_fibers[all_fibers > 500], not args.no_sky) ))
        else:
            exps.append(('coadd', load_coadded_spectra(plate, mjd, all_fibers, not args.no_sky)))
    else:
        exp_ids = [0]
        if args.exposure == -1:
            remote_path = finder.get_spec_path(plate, mjd, all_fibers[0], lite=False)
            local_path = mirror.get(remote_path)
            specfile = SpecFile(local_path)

            exp_ids = range(specfile.num_exposures/2)
        else:
            exp_ids = [int(args.exposure)]

        for exp_id in exp_ids:
            exps.append((exp_id, load_exposure_spectra(plate, mjd, all_fibers, exp_id, args.camera, not args.no_sky)))

    if(args.plot):
        for exp_wrap in exps:
            exp = exp_wrap[1]
            wlen_cat_wavg, flux_cat_wavg, dflux_cat_wavg, flux_cnt = get_averages(exp[0], exp[1], exp[2])
            averages = {"wlen": wlen_cat_wavg, "flux" : flux_cat_wavg, "dflux": dflux_cat_wavg, "count": flux_cnt}

            wlen_cat_wvar, flux_cat_wvar, dflux_cat_wvar = get_var(exp[0], exp[1], exp[2], args)
            variances = {"wlen": wlen_cat_wvar, "flux" : flux_cat_wvar, "dflux": dflux_cat_wvar}

            wlen_cat_wstd, flux_cat_wstd, dflux_cat_wstd = get_std(exp[0], exp[1], exp[2], args)
            stds = {"wlen": wlen_cat_wstd, "flux" : flux_cat_wstd, "dflux": dflux_cat_wstd}

            # l_cor, r_cor, d_cor = get_diff_cc(exp[0], None)
            r_wlen_cat_wavg, r_flux_cat_wavg, r_dflux_cat_wavg, r_flux_cnt = get_averages(exp_wrap[2][0], exp_wrap[2][1], exp_wrap[2][2])
            conv = get_diff_convolve(flux_cat_wavg, r_flux_cat_wavg)
            print(conv.shape)
            plot_it(averages, variances, stds, conv, args)

    return exps
Esempio n. 2
0
exp_ids = range(specfile.num_exposures/2)

def save_data(wlen, flux, dflux, flux_cnt, flux_std, title):
    filename = "LRDiff-{}.csv".format(title)

    wlen_min, wlen_max = -1e6, +1e6
    #if args.camera == 'blue' and args.exposure is None:
    wlen_max = min(wlen_max, 6200)
    #elif args.camera == 'nored' and args.exposure is None:
    #    wlen_max = min(wlen_max, 5800)
    #elif args.camera == 'red' and args.exposure is None:
    #    wlen_min = max(wlen_min, 5800)

    mask = (wlen.data < wlen_max) & (wlen.data > wlen_min) & (wlen.data != 0) & (wlen.data != 0)

    #I'm making enough revs and have enough files laying about, this is worthwhile
    new_table = Table()
    new_table['WLEN_WAVG'] = Column(wlen[mask], description = "Weighted Average Wavelength for 'Left' side")
    new_table['FLUX_WAVG'] = Column(flux[mask], description = "Weighted Average Flux for 'Left' side")
    new_table['DFLUX'] = Column(dflux[mask], description = "Sigma for the flux (sum in quadr. / count)")
    new_table['FLUX_COUNT'] = Column(flux_cnt[mask], description = "Number of flux measur. contributed")
    new_table['FLUX_STD'] = Column(flux_std[mask], description = "STD of left flux")

    new_table.write(filename, format='ascii.csv')

for fiber in fibers:
    wlen_cat, flux_cat, dflux_cat = compare_l_r_plates.load_exposure_spectra(plate, mjd, fibers, exp_ids, camera='blue', include_sky=True)
    wlen_cat_wavg, flux_cat_wavg, dflux_cat_wavg, flux_cnt, flux_std = compare_l_r_plates.get_averages(wlen_cat, flux_cat, dflux_cat)
    save_data(wlen_cat_wavg, flux_cat_wavg, dflux_cat_wavg, flux_cnt, flux_std,  "fiber_{}".format(fiber))