Exemplo n.º 1
0
def plot_obsext(ax, obsext):

    obsext_wave = obsext.waves["BAND"].value

    obsext_ext = obsext.exts["BAND"]
    obsext_ext_uncs = obsext.uncs["BAND"]

    gindxs_IRS = np.where(obsext.npts["IRS"] > 0)
    obsext_IRS_wave = obsext.waves["IRS"][gindxs_IRS].value
    obsext_IRS_ext = obsext.exts["IRS"][gindxs_IRS]
    obsext_IRS_uncs = obsext.uncs["IRS"][gindxs_IRS]

    ax.plot(
        obsext_IRS_wave,
        obsext_IRS_ext,
        "b-",  # pcol[i] + psym[i],
        markersize=5,
        markeredgewidth=1.0,
        alpha=1.0,
        label="MWAvg",
    )

    # rebin IRS
    wrange = [5.0, 36.0]
    res = 25
    full_wave, full_wave_min, full_wave_max = _wavegrid(res, wrange)
    n_waves = len(full_wave)
    full_flux = np.zeros((n_waves), dtype=float)
    full_unc = np.zeros((n_waves), dtype=float)
    full_npts = np.zeros((n_waves), dtype=int)

    cwaves = obsext_IRS_wave
    cfluxes = obsext_IRS_ext
    cuncs = obsext_IRS_uncs
    for k in range(n_waves):
        (indxs,) = np.where((cwaves >= full_wave_min[k]) & (cwaves < full_wave_max[k]))
        if len(indxs) > 0:
            # weights = 1.0 / np.square(cuncs[indxs])
            weights = 1.0
            full_flux[k] += np.sum(weights * cfluxes[indxs])
            full_unc[k] += np.sum(1.0 / np.square(cuncs[indxs]))
            full_npts[k] += len(indxs)

    findxs = full_npts > 0
    full_flux[findxs] /= full_npts[findxs]
    full_unc[findxs] = np.sqrt(1.0 / full_unc[findxs])
Exemplo n.º 2
0
            alpha=0.5,
        )

        # IRS
        ax[1].plot(
            obsext_IRS_wave,
            obsext_IRS_ext,
            pcol[i] + pline[i],
            lw=2,
            alpha=0.65,
        )

        # rebin IRS
        wrange = [5.0, 36.0]
        res = 25
        full_wave, full_wave_min, full_wave_max = _wavegrid(res, wrange)
        n_waves = len(full_wave)
        full_flux = np.zeros((n_waves), dtype=float)
        full_unc = np.zeros((n_waves), dtype=float)
        full_npts = np.zeros((n_waves), dtype=int)

        cwaves = obsext_IRS_wave
        cfluxes = obsext_IRS_ext
        cuncs = obsext_IRS_uncs
        for k in range(n_waves):
            (indxs, ) = np.where((cwaves >= full_wave_min[k])
                                 & (cwaves < full_wave_max[k]))
            if len(indxs) > 0:
                # weights = 1.0 / np.square(cuncs[indxs])
                weights = 1.0
                full_flux[k] += np.sum(weights * cfluxes[indxs])