def ampmean(amp): imap = k_indexmap(amp.shape[0], amp.shape[1], angle=0, sector=180, kstep=1.0) for i in range(KIMAX): mask = imap == i yield amp[mask].mean()
def fit(x, y, label="data"): imap = k_indexmap(y.shape[0], y.shape[1], angle=0, sector=180, kstep=1.0) popt, pcov = _fit_data(x, y, imap) ki, kj = rfft2_grid(y.shape[0], y.shape[1]) k = (ki**2 + kj**2)**0.5 #mask of valid (successfully fitted) data mask = np.all(np.logical_not(np.isnan(popt)), axis=-1) return mask, k, popt, pcov
ax1, ax1a = fig1.subplots(1, 2) fig2 = plt.figure() ax2, ax2a = fig2.subplots(1, 2) for i, norm in enumerate((2, 3, 6)): x = np.load(path.join(DATA_PATH, "corr_{}_t.npy".format(METHOD))) y = np.load( path.join(DATA_PATH, "corr_{}_data_norm{}.npy".format(METHOD, norm))) #time mask for valid data. For a given time, all data at any k value must be valid mask = np.isnan(y) mask = np.logical_not(np.all(mask, axis=tuple(range(mask.ndim - 1)))) x, y = x[mask], y[..., mask] imap = k_indexmap(y.shape[0], y.shape[1], angle=0, sector=180, kstep=1.0) ki, kj = rfft2_grid(y.shape[0], y.shape[1]) ks = (ki**2 + kj**2)**0.5 if METHOD == "dual": popt, cov = _fit_data(x, y, imap) else: #skip the first element (zero time) popt, cov = _fit_data(x[1:], y[..., 1:], imap) m = np.all(np.logical_not(np.isnan(popt)), axis=-1) popt = popt[m] cov = cov[m] k = ks[m] imap = imap[m]
"""Demonstrates how to create mask array for data masking during computation""" from cddm.map import k_indexmap, plot_indexmap from examples.conf import KISIZE, KJSIZE kmap = k_indexmap(KISIZE, KJSIZE, angle=0, sector=90) mask = (kmap >= 20) & (kmap <= 30) if __name__ == "__main__": plot_indexmap(mask)
def test_plot(self): kmap = k_indexmap(33, 32, angle=0, sector=5, kstep=1.) plot_indexmap(kmap)