plt.xlabel(r"Frequency [rad$^{-1}$]", fontsize=18) plt.ylabel(r"Power", fontsize=18) # Now we remove the dc offset, as well as high frequency noise local_fringe_frequencies = fringe_freq(B, wl, moon["dec"], 2.*np.pi*moon["ha"]/24.) bandpass = FourierFilter(min_freq=0.001, max_freq=max(local_fringe_frequencies)) # moon["volts"] = np.real(bandpass(moon["t"], moon["volts"])[1]) moon.flatten_invalid_points() # moon["volts"] = moon.real_boxcar(200) moon["volts"] = np.load("moonshine.npz")["volts"] plt.figure() plt.plot(moon["ha"], moon["volts"]) plt.xlabel(r"Hour angle [h]", fontsize=18) plt.ylabel(r"Power", fontsize=18) plt.plot(moon["ha"], moon.envelope(50)) ''' mooncopy = moon.copyslice(3600, 7100) mooncopy["ha"] = mooncopy["ha"] positive_values = mooncopy["volts"] >= 0.0 enveloper = FourierFilter(max_freq=0.01) _, envelope = enveloper(mooncopy["t"], mooncopy["volts"] * positive_values) phi_to_try = np.arange(0.0, np.pi, np.pi/300.) s2s = [] Y_s = [] a_s = []
Y_ = Y_s[np.argmin(s2s)] print C1, C2, C3 ha1 = (-C2 + np.sqrt(C2**2. - 4*C1*C3)) / (2.*C3) ha2 = (-C2 - np.sqrt(C2**2. - 4*C1*C3)) / (2.*C3) print ha1 print ha2 ''' minima_spots = [(500, 4000), (4500, 7500), (21000, 23000), (24500, 25550)] obs_zeros = [] plottypairs = [] for start, end in minima_spots: # Cut out a small window around the guessed envelope # fit a quadratic to find minima (C1, C2, C3), Y_, s2, cov = fit_components(sun["ha"][start: end], sun.envelope(50)[start:end], lambda ha: ha ** 2, lambda ha: ha, lambda ha: 1, ) plottypairs.append((sun["ha"][start:end], Y_)) vertex = -C2 / (2. * C1) obs_zeros.append(vertex) ''' _, aa = zip(*sorted(zip(b, a))) min_ha = aa[0] obs_zeros.append(min_ha) print "found", min_ha plottypairs.append((a, b))