Beispiel #1
0
def integrand(w, alpha=0):
    M = get_mirror()
    Q = get_detector()
    S = get_solar()
    return w * M(w) * Q(w) * ref_rock(w, alpha) * S(w)
Beispiel #2
0
 def integrand(self, w, n=4, alpha=0):
     return w * self.M(w)**n * self.Q(w) * ref_rock(w, alpha) * self.S(w)
Beispiel #3
0
def integrand(w, alpha=0, ice=False):
    if ice:
        return w * M(w) * Q(w) * ref_ice(w, alpha).T * S(w)
    else:
        return w * M(w) * Q(w) * ref_rock(w, alpha).T * S(w)
Beispiel #4
0
        def func(t_exp):
            i = quad(integrand, c2 - w2 / 2, c2 + w2 / 2, args=(N, alpha))[0]
            signal = CoCa.A_Omega / CoCa.G * t_exp * i / (const.h * const.c *
                                                          CoCa.r_h**2) * 1e-9
            return signal - 2**14

        sol = fsolve(func, 0.001)
        print(alpha, sol)
        t.append(sol[0])

    wavelengths = np.linspace(300, 1100, 100)
    fig, axes = plt.subplots(nrows=2)

    axes[0].plot(phase_angle, t, color=BLACK, ls="--")
    axes[0].set_xlabel("phase angle [°]")
    axes[0].set_ylabel("exposure time [s]")

    # phase_angle = 51

    axes[1].plot(wavelengths,
                 ref_rock(wavelengths, phase_angle).T,
                 color=BLACK,
                 ls="--")
    axes[1].set_xlabel("wavelength [nm]")
    axes[1].set_ylabel("I/F")

    plt.savefig("plots/exposure.png")

    plt.show()
Beispiel #5
0
 def integrand(w, N=4, alpha=0):
     return w * M(w)**N * Q(w) * ref_rock(w, alpha).T * S(w)
Beispiel #6
0
 def integrand_low(w, N=4, alpha=0):
     return w * M(w)**N * Q(w) * ref_rock(w, alpha)[0] * S(w)
Beispiel #7
0
def plot_signals():
    M = get_mirror()
    Q = get_detector()
    S = get_solar()
    F = get_filter_from_data()
    F, F2, F3, F4 = init_filters(400, [200, 200, 200, 200])
    F, F2, F3, F4 = init_filters_thomas()
    ref_low, ref_up = get_reflectance()

    def integrand_low(w, N=4, alpha=0):
        return w * M(w)**N * Q(w) * ref_rock(w, alpha)[0] * S(w)

    def integrand_up(w, N=4, alpha=0):
        return w * M(w)**N * Q(w) * ref_ice(w, alpha)[0] * S(w)

    phase_angle = np.arange(0, 100, 5)
    signals_low = np.zeros(phase_angle.shape)
    signals_up = np.zeros(phase_angle.shape)
    signals_std = np.zeros(phase_angle.shape)
    N = 4
    for i, alpha in enumerate(phase_angle):
        print(i, alpha)
        integral_low, int_err = quad(integrand_low, 300, 1100, args=(N, alpha))
        integral_up, int_err = quad(integrand_up, 300, 1100, args=(N, alpha))

        widths_up = []
        widths_low = []
        centers = range(450, 1000, 50)
        for filter_center in centers:

            def func(width):
                G = 2.5  # electron per DN
                A = (7e-6)**2
                Omega = 0.64e-10
                r_h = 1  # A.U.
                t_exp = 0.00005  # seconds
                i = quad(integrand_up,
                         filter_center - width / 2,
                         filter_center + width / 2,
                         args=(N, alpha))[0]
                signal = G * A * Omega * t_exp * i / (const.h *
                                                      const.c) / r_h**2
                return signal - 2**14

            sol = fsolve(func, 100)
            print(filter_center, sol)
            widths_up.append(sol[0])

            def func(width):
                G = 2.5  # electron per DN
                A = (7e-6)**2
                Omega = 0.64e-10
                r_h = 1  # A.U.
                t_exp = 0.001  # seconds
                i = quad(integrand_low,
                         filter_center - width / 2,
                         filter_center + width / 2,
                         args=(N, alpha))[0]
                signal = G * A * Omega * t_exp * i / (const.h *
                                                      const.c) / r_h**2
                return signal - 2**14

            sol = fsolve(func, 100)
            print(filter_center, sol)
            widths_low.append(sol[0])
        widths_up = np.array(widths_up)
        widths_low = np.array(widths_low)
        plt.plot(centers,
                 widths_low + (widths_up - widths_low) / 2,
                 color="#e6002e",
                 alpha=0.5)
        plt.fill_between(centers,
                         widths_low,
                         widths_up,
                         color="#e6002e",
                         alpha=0.5)
        w1 = 150
        w2 = 100
        w3 = 100
        w4 = 150
        c1 = 460
        c2 = 650
        c3 = 750
        c4 = 900
        plt.scatter(c1, w1, label="BLUE", color="#4767af")
        plt.scatter(c2, w2, label="GREEN", color="#466553")
        plt.scatter(c3, w3, label="RED", color="#e6002e")
        plt.scatter(c4, w4, label="NIR", color="black")
        plt.xlabel("filter center [nm]")
        plt.ylabel("filter width [nm]")
        plt.savefig("filter_widths.png")
        plt.show()

        wavelengths = np.linspace(300, 1100, 1000)
        plt.plot(wavelengths,
                 integrand_low(wavelengths) +
                 (integrand_up(wavelengths) - integrand_low(wavelengths)) / 2,
                 color="#e6002e",
                 alpha=0.5)
        plt.fill_between(wavelengths,
                         integrand_low(wavelengths),
                         integrand_up(wavelengths),
                         color="#e6002e",
                         alpha=0.5)
        plt.show()
        exit()

        G = 2.5  # electron per DN
        A = 0.135**2 * 4 * np.pi
        A = (7e-6)**2
        Omega = 0.64e-10
        r_h = 1  # A.U.
        t_exp = 0.00005  # seconds
        signal_low = G * A * Omega * t_exp * integral_low / (const.h *
                                                             const.c) / r_h**2
        signal_up = G * A * Omega * t_exp * integral_up / (const.h *
                                                           const.c) / r_h**2
        # TODO: calculate with uncertainties of other parameters
        signals_low[i] = signal_low
        signals_up[i] = signal_up

    fig, axes = plt.subplots(nrows=6, sharex=True)

    wavelengths = np.linspace(300, 1100, 1000)
    phase_angle = 58

    axes[0].plot(wavelengths, 100 * Q(wavelengths), color="black")
    axes[0].set_ylabel(r"$Q$ [%]")

    axes[1].plot(wavelengths, 100 * M(wavelengths), color="black")
    axes[1].set_ylabel(r"$M$ [%]")

    axes[2].plot(wavelengths, 100 * F(wavelengths), color="#4767af")  # blue
    axes[2].plot(wavelengths, 100 * F2(wavelengths), color="#466553")  # green
    axes[2].plot(wavelengths, 100 * F3(wavelengths), color="#e6002e")  # red
    axes[2].plot(wavelengths, 100 * F4(wavelengths), color="black")
    axes[2].set_ylabel(r"$T$ [%]")

    axes[3].plot(wavelengths,
                 100 * (ref_rock(wavelengths, phase_angle) +
                        (ref_ice(wavelengths, phase_angle) -
                         ref_rock(wavelengths, phase_angle)) / 2),
                 color="#e6002e")
    axes[3].fill_between(wavelengths,
                         100 * ref_rock(wavelengths, phase_angle),
                         100 * ref_ice(wavelengths, phase_angle),
                         color="#e6002e",
                         alpha=0.5)
    axes[3].set_ylabel(r"$R$ [%]")
    axes[3].legend()

    axes[4].plot(wavelengths,
                 S(wavelengths),
                 color="black",
                 label=r"$F_\odot$")
    axes[4].set_ylabel(r"$F_\odot$ [Wm$^{-2}$nm$^{-1}$]")

    axes[5].plot(wavelengths,
                 M(wavelengths)**4 * ref_rock(wavelengths, phase_angle) *
                 S(wavelengths),
                 color="#e6002e",
                 label=r"$F_\odot(\omega)M(\omega)^NR(\omega)$")
    axes[5].set_ylabel(r"$F_\odot'$ [Wm$^{-2}$nm$^{-1}$]")
    axes[5].set_xlabel(r"$\lambda$ [nm]")

    plt.savefig("filters.png")
    plt.show()

    plt.plot(phase_angle,
             signals_low + (signals_up - signal_low) / 2,
             color="#e6002e")
    plt.fill_between(phase_angle,
                     signals_low,
                     signals_up,
                     color="#e6002e",
                     alpha=0.5)
    plt.fill_between(phase_angle, 0, 8 * 2.5, color="black", alpha=0.5)
    plt.axhline(2**14, color="#e6002e", ls="--")
    plt.xlabel(r"$\alpha$ [°]")
    plt.ylabel(r"$S$ [DN]")
    plt.title(fr"$t$ = {t_exp} s")
    plt.savefig("signal.png")
    plt.show()
Beispiel #8
0
def integrand(w, alpha=0):
    return w * M(w) * Q(w) * ref_rock(w, alpha) * S(w)
def main():
    fig, ax = plt.subplots(ncols=2, nrows=2, sharey=True, figsize=(10, 6))
    phase_angles = np.linspace(0.01, 92, 100)
    i = phase_angles
    e = np.zeros(phase_angles.shape)

    phase11_rock = phase_clement(11, "rock")
    phase11_ice = phase_clement(11, "ice")
    phase51_rock = phase_clement(51, "rock")
    phase51_ice = phase_clement(51, "ice")

    s = 15

    ax[0][0].scatter([11] * len(phase11_rock),
                     phase11_rock,
                     marker="x",
                     s=s,
                     color=BLACK,
                     label=r"rock $\alpha=11$°")
    ax[0][0].scatter([51] * len(phase51_rock),
                     phase51_rock,
                     marker="x",
                     s=s,
                     color=BLACK,
                     label=r"rock $\alpha=51$°")
    ax[0][0].scatter([11] * len(phase11_ice),
                     phase11_ice,
                     marker="x",
                     s=s,
                     color=RED,
                     label=r"ice $\alpha=11$°")
    ax[0][0].scatter([51] * len(phase51_ice),
                     phase51_ice,
                     marker="x",
                     s=s,
                     color=RED,
                     label=r"ice $\alpha=51$°")
    r = ref_rock(649, phase_angles)
    r_ice = ref_ice(649, phase_angles)

    ax[0][0].plot(phase_angles, r, color=BLACK, ls="--", label="hapke rock")
    ax[1][0].plot(phase_angles, r, color=BLACK, ls="--", label="hapke rock")

    ax[0][0].plot(phase_angles, r_ice, color=RED, ls="--", label="hapke ice")
    ax[1][0].plot(phase_angles, r_ice, color=RED, ls="--", label="hapke ice")

    for material in ["ice", "rock"]:
        for phase_angle in [51, 58, 89, 92, "92b"]:
            filename = f"data/deshapriya/67p_{material}_alpha_{phase_angle}.csv"
            df = pd.read_csv(filename, names=["wavelength", "r"])
            print(df.wavelength)
            df = df[(df.wavelength < 650) & (df.wavelength > 648)]
            if phase_angle == "92b": phase_angle = 92
            if material == "ice":
                c = RED
                ax[0][0].scatter([phase_angle] * len(df.r),
                                 df.r,
                                 marker="o",
                                 s=s,
                                 color=c)

            else:
                c = BLACK
                ax[0][0].scatter([phase_angle] * len(df.r),
                                 df.r,
                                 marker="o",
                                 s=s,
                                 color=c)

    for material in ["ice", "rock"]:
        for phase_angle in [51, 58, 89, 92, "92b"]:
            filename = f"data/deshapriya/67p_{material}_alpha_{phase_angle}.csv"
            df = pd.read_csv(filename, names=["wavelength", "r"])
            print(df.wavelength)
            df = df[(df.wavelength < 950) & (df.wavelength > 930)]
            if phase_angle == "92b": phase_angle = 92
            if material == "ice":
                c = RED
                ax[1][0].scatter([phase_angle] * len(df.r),
                                 df.r,
                                 marker="o",
                                 s=s,
                                 color=c)

            else:
                c = BLACK
                ax[1][0].scatter([phase_angle] * len(df.r),
                                 df.r,
                                 marker="o",
                                 s=s,
                                 color=c)
    phase11_rock = phase_clement(11, "rock", 932)
    phase11_ice = phase_clement(11, "ice", 932)
    phase51_rock = phase_clement(51, "rock", 932)
    phase51_ice = phase_clement(51, "ice", 932)

    ax[1][0].scatter([11] * len(phase11_rock),
                     phase11_rock,
                     marker="x",
                     s=s,
                     color=BLACK,
                     label=r"rock $\alpha=11$°")
    ax[1][0].scatter([51] * len(phase51_rock),
                     phase51_rock,
                     marker="x",
                     s=s,
                     color=BLACK,
                     label=r"rock $\alpha=51$°")
    ax[1][0].scatter([11] * len(phase11_ice),
                     phase11_ice,
                     marker="x",
                     s=s,
                     color=RED,
                     label=r"ice $\alpha=11$°")
    ax[1][0].scatter([51] * len(phase51_ice),
                     phase51_ice,
                     marker="x",
                     s=s,
                     color=RED,
                     label=r"ice $\alpha=51$°")

    a = mlines.Line2D([], [],
                      color=BLACK,
                      marker='o',
                      ls='',
                      label='deshapryia rock')
    b = mlines.Line2D([], [],
                      color=RED,
                      marker='o',
                      ls='',
                      label='deshapryia ice')
    c = mlines.Line2D([], [],
                      color=BLACK,
                      marker='x',
                      ls='',
                      label='fornasier rock')
    d = mlines.Line2D([], [],
                      color=RED,
                      marker='x',
                      ls='',
                      label='fornasier ice')
    e = mlines.Line2D([], [], color=BLACK, ls='--', label='rock')
    f = mlines.Line2D([], [], color=RED, ls='--', label='ice')
    ax[0][0].legend(handles=[a, b, c, d, e, f])
    ax[0][0].set_xlabel("phase angle [°]")
    ax[1][0].set_xlabel("phase angle [°]")
    ax[0][0].set_ylabel("I/F")
    ax[1][0].set_ylabel("I/F")
    ax[0][0].set_title(r"$\lambda$ = 649 nm")
    ax[1][0].set_title(r"$\lambda$ = 932 nm")

    wave_clement(11, ax[0][1])
    wave_clement(51, ax[1][1])

    wavelengths = np.linspace(200, 1100)
    phase_angles = np.array([11])
    rock = ref_rock(wavelengths, phase_angles).T
    ice = ref_ice(wavelengths, phase_angles).T

    ax[0][1].plot(wavelengths, rock, ls="--", color=BLACK, label="hapke")
    ax[0][1].plot(wavelengths, ice, ls="--", color=RED, label="hapke ice")

    phase_angles = np.array([51])
    rock = ref_rock(wavelengths, phase_angles).T
    ice = ref_ice(wavelengths, phase_angles).T
    ax[1][1].plot(wavelengths, rock, ls="--", color=BLACK, label="hapke")
    ax[1][1].plot(wavelengths, ice, ls="--", color=RED, label="hapke ice")

    for material in ["ice", "rock"]:
        for phase_angle in [51]:
            filename = f"data/deshapriya/67p_{material}_alpha_{phase_angle}.csv"
            df = pd.read_csv(filename, names=["wavelength", "r"])
            if phase_angle == "92b": phase_angle = 92
            if material == "ice":
                c = RED
                ax[1][1].scatter(df.wavelength, df.r, marker="o", s=s, color=c)
            else:
                c = BLACK
                ax[1][1].scatter(df.wavelength, df.r, marker="o", s=s, color=c)
    ax[0][1].set_xlabel("wavelength [nm]")
    ax[0][1].set_ylabel("I/F")
    ax[0][1].set_title(r"$\alpha$ = 11°")
    ax[1][1].set_xlabel("wavelength [nm]")
    ax[1][1].set_ylabel("I/F")
    ax[1][1].set_title(r"$\alpha$ = 51°")

    plt.tight_layout()
    plt.savefig("plots/ref.pdf")
    plt.show()

    plt.plot(wavelengths, ref_rock(wavelengths, 1.3).T)
    plt.show()
Beispiel #10
0
def main(mode, v=30, alpha=11):
    fig, axes = plt.subplots(nrows=2, sharex=True)

    if mode != "C":
        wavelengths = np.linspace(300, 1100, 1000)
    else:
        wavelengths = np.linspace(200, 1100, 1000)

    df = pd.read_csv(f"data/widths_snr.csv")
    widths100_avg = df.widths_100
    widths80_avg = df.widths_80
    widths60_avg = df.widths_60
    centers = df.c
    width100 = interp1d(centers,
                        widths100_avg,
                        kind="quadratic",
                        fill_value="extrapolate")
    width80 = interp1d(centers,
                       widths80_avg,
                       kind="quadratic",
                       fill_value="extrapolate")
    width60 = interp1d(centers,
                       widths60_avg,
                       kind="quadratic",
                       fill_value="extrapolate")
    axes[0].plot(np.linspace(380, 1000, 100),
                 width100(np.linspace(380, 1000, 100)),
                 color=BLACK,
                 zorder=-1,
                 label="SNR 100")
    axes[0].plot(np.linspace(380, 1000, 100),
                 width80(np.linspace(380, 1000, 100)),
                 ls="-.",
                 color=BLACK,
                 zorder=-1,
                 label="SNR 80")
    axes[0].plot(np.linspace(380, 1000, 100),
                 width60(np.linspace(380, 1000, 100)),
                 ls="--",
                 color=BLACK,
                 zorder=-1,
                 label="SNR 60")
    axes[0].legend()
    if mode != "C":
        axes[0].set_ylim(0.8 * min(df.widths_60), max(df.widths_80))
    else:
        axes[0].set_xticks(np.arange(200, 1101, 100))
        axes[0].set_xticklabels(np.arange(200, 1101, 100))
    axes[0].set_ylabel("width [nm]")
    axes[0].set_xlabel("center [nm]")
    axes[1].set_xlabel("wavelength [nm]")
    axes[1].set_ylabel("transmission [%]")
    c1 = 460
    c2 = 650
    c3 = 764
    c4 = 900

    df = pd.read_csv(f"data/filters_{mode}.csv")
    c1, c2, c3, c4 = df.centers
    w1, w2, w3, w4 = df.widths

    F0 = make_filter(c1, w1)
    F1 = make_filter(c2, w2)
    F2 = make_filter(c3, w3)
    F3 = make_filter(c4, w4)
    if mode == "C":
        f0, = axes[1].plot(wavelengths, 100 * F0(wavelengths), color=BLUE)
        f1, = axes[1].plot(wavelengths, 100 * F1(wavelengths), color=GREEN)
        f2, = axes[1].plot(wavelengths, 100 * F2(wavelengths), color=ORANGE)
        f3, = axes[1].plot(wavelengths, 100 * F3(wavelengths), color=RED)
    else:
        f0, = axes[1].plot(wavelengths, 100 * F0(wavelengths), color=BLUE)
        f1, = axes[1].plot(wavelengths, 100 * F1(wavelengths), color=ORANGE)
        f2, = axes[1].plot(wavelengths, 100 * F2(wavelengths), color=RED)
        f3, = axes[1].plot(wavelengths, 100 * F3(wavelengths), color=BLACK)
    axes[1].plot(wavelengths, np.zeros(wavelengths.shape), color=BLACK)
    M = get_mirror()
    Q = get_detector()
    S = get_solar()
    signal = M(wavelengths) * Q(wavelengths) * ref_rock(wavelengths,
                                                        alpha) * S(wavelengths)
    signal = signal / np.max(signal) * 100
    # axes[1].plot(wavelengths, signal.T, color=BLACK)

    df = pd.read_csv("data/texp.csv")
    t = interp1d(df.alpha, df["texp10"], fill_value="extrapolate")
    t_exp = t(alpha) / (v / 10) / 1000

    # axes[0].set_title(f"phase angle = {alpha}°")
    if mode == "C":
        scatter = axes[0].scatter([c1, c2, c3, c4], [w1, w2, w3, w4],
                                  color=[BLUE, GREEN, ORANGE, RED],
                                  edgecolor=BLACK)
    else:
        scatter = axes[0].scatter([c1, c2, c3, c4], [w1, w2, w3, w4],
                                  color=[BLUE, ORANGE, RED, BLACK],
                                  edgecolor=BLACK)
    DraggableScatter(scatter, [f0, f1, f2, f3], fig, v, mode)