yinches = len(r)/float(dpi) figsize = (xinches + 1.5, yinches + 1) fig = plt.figure(figsize=figsize) ax = plt.subplot(111) el.make_axes_fixed(ax, xinches, yinches) img = el.rtiplot(z, t, r, ax=ax, csize=0.0625, cpad=0.05, **kwargs) plt.tight_layout(0.1) return fig basedir = 'figures' if not os.path.exists(basedir): os.makedirs(basedir) cmap = copy.copy(plt.cm.coolwarm) cmap.set_bad(cmap(0)) rslc = el.slice_by_value(cs.r, 97000, 113500) for pslc in [slice(0, None, 5), slice(1, None, 5), slice(2, None, 5), slice(3, None, 5), slice(4, None, 5), slice(None)]: fig1 = plotter(20*np.log10(cs.h_sig[pslc, rslc]/cs.noise_sigma), cs.t[pslc], cs.r[rslc]/1e3, exact_ticks=False, vmin=0, vmax=40, cmap=cmap, ylabel='Range (km)', clabel='SNR (dB)') path = os.path.join(basedir, basefilename + '_recovered_rti_{0}.pdf') if pslc.start is not None: path = path.format(pslc.start) else: path = path.format('all') fig1.savefig(path, dpi=savedpi, bbox_inches='tight', pad_inches=0.05, transparent=True) fig2 = plotter(20*np.log10(np.abs(cs.h_noise[pslc, rslc])/cs.noise_sigma),
return np.exp(2*np.pi*1j*(0.5*slope*t - bandwidth_hz/2.)*t) barker13 = np.array([1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1]).astype(np.float_) msl = np.array([-1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1]).astype(np.float_) uncoded = np.ones(40) lfm = make_lfm(51, 1e-6, 1e6) psrnd = np.array([-1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1]).astype(np.float_) codes = [barker13, msl, uncoded, lfm, psrnd] code_delays = [0]*len(codes) files = el.jicamarca.find_files(datadir) vlt_o = el.jicamarca.voltage_reader(files[565]) rall = vlt_o.r rslc = el.slice_by_value(rall, 80000, 120000) r = rall[rslc] vlt1 = vlt_o.read_from_block(22, 150, 0, sample_idx=rslc, chan_idx=0) vlt2 = vlt_o.read_from_block(23, 0, 150, sample_idx=rslc, chan_idx=0) vlt = np.concatenate((vlt1, vlt2), axis=0) t = vlt_o.block_times[22] + (150 + np.arange(vlt.shape[0]))*vlt_o.ipp ts = vlt_o.ts ipp = vlt_o.ipp f0 = 49920000.0 noise_vlt = vlt_o.read_from_block(22, 0, 0, sample_idx=el.slice_by_value(rall, None, 80000), chan_idx=0) noise_sigma = np.sqrt(np.mean(noise_vlt.real**2 + noise_vlt.imag**2)) store = Bunch(vlt=vlt, r=r, t=t, codes=codes, code_delays=code_delays, ts=ts, ipp=ipp, f0=f0, noise_sigma=noise_sigma)
yinches = len(r)/float(dpi) figsize = (xinches + 1.5, yinches + 1) fig = plt.figure(figsize=figsize) ax = plt.subplot(111) el.make_axes_fixed(ax, xinches, yinches) img = el.rtiplot(z, t, r, ax=ax, csize=0.0625, cpad=0.05, **kwargs) plt.tight_layout(0.1) return fig basedir = 'figures' if not os.path.exists(basedir): os.makedirs(basedir) cmap = copy.copy(plt.cm.coolwarm) cmap.set_bad(cmap(0)) rslc = el.slice_by_value(mf.r, 85000, 120000) pend = -100 for pslc in [slice(0, pend, 5), slice(1, pend, 5), slice(2, pend, 5), slice(3, pend, 5), slice(4, pend, 5), slice(0, pend)]: fig4 = plotter(20*np.log10(np.abs(mf.vlt[pslc, rslc])/mf.noise_sigma), mf.t[pslc], mf.r[rslc]/1e3, exact_ticks=False, vmin=0, vmax=40, ylabel='Range (km)', clabel='SNR (dB)') path = os.path.join(basedir, basefilename + '_mf_rti_{0}.pdf') if pslc.start is not None: path = path.format(pslc.start) else: path = path.format('all') fig4.savefig(path, dpi=savedpi, bbox_inches='tight', pad_inches=0.05, transparent=True)
return fig basefilename = 'ejet_two_heads_trail' with open(basefilename + '.pkl', 'rb') as f: data = cPickle.load(f) with open(basefilename + '_recovered_range.pkl', 'rb') as f: cs = cPickle.load(f) dpi = 75*2 # should be sized to match font size savedpi = dpi*2 # should be a multiple of dpi pixelaspect = 1 basedir = 'figures' if not os.path.exists(basedir): os.makedirs(basedir) cmap = copy.copy(plt.cm.coolwarm) cmap.set_bad(cmap(0)) rslc = el.slice_by_value(cs.r, 90000, 110000) fig = plot_block(20*np.log10(np.abs(cs.h[:, rslc])/cs.noise_sigma), cs.t, cs.r[rslc], dpi=dpi, pixelaspect=pixelaspect, vmin=0, vmax=25, csize=0.0625, cpad=0.05) fpath = os.path.join(basedir, basefilename + '_recovered_rti_block.pdf') fig.savefig(fpath, dpi=savedpi, bbox_inches='tight', pad_inches=0, transparent=True) plt.close(fig) plt.show()
import echolect as el import radarmodel mfblksize = 5 mfvoters = [1, 2, 4] basefilename = 'ejet_head_flare' with open(basefilename + '.pkl', 'rb') as f: data = cPickle.load(f) n = 1 freqs = np.fft.fftfreq(int(n), data.ts/np.timedelta64(1, 's')) v = freqs/data.f0*sp.constants.c/2 rslc = el.slice_by_value(data.r, 80000, 140000) r = data.r[rslc] m = r.shape[0] filts = [] for code, delay in zip(data.codes, data.code_delays): s = (code/np.linalg.norm(code)).astype(data.vlt.dtype) filt = el.filtering.MatchedDoppler(s, n, data.vlt.shape[-1], xdtype=data.vlt.dtype) filt.nodelay = slice(filt.L - 1 - delay, filt.L - 1 - delay + filt.M) filts.append(filt) vlt_mf_all = np.zeros((mfblksize, n, m), data.vlt.dtype) vlt_mf = np.zeros((data.vlt.shape[0], m), data.vlt.dtype) freq = np.zeros(data.vlt.shape[0]) for kp in xrange(data.vlt.shape[0]): y = data.vlt[kp]
basefilename = 'head_and_flare' with open(basefilename + '.pkl', 'rb') as f: data = cPickle.load(f) with open(basefilename + '_mf.pkl', 'rb') as f: mf = cPickle.load(f) dpi = 75*4 # should be sized to match font size savedpi = dpi*1 # should be a multiple of dpi pixelaspect = 4 basedir = 'figures' if not os.path.exists(basedir): os.makedirs(basedir) cmap = copy.copy(plt.cm.coolwarm) cmap.set_bad(cmap(0)) rslc = el.slice_by_value(mf.r, 86000, 97000) fig = plot_block(20*np.log10(np.abs(mf.vlt[:, rslc])/mf.noise_sigma), 20*np.log10(np.abs(data.vlt[2::5, rslc])/data.noise_sigma), mf.t, mf.r[rslc], dpi=dpi, pixelaspect=pixelaspect, vmin=0, vmax=40, csize=0.0625, cpad=0.05) fpath = os.path.join(basedir, basefilename + '_mf_rti_block.pdf') fig.savefig(fpath, dpi=savedpi, bbox_inches='tight', pad_inches=0, transparent=True) plt.close(fig) plt.show()
return np.exp(2*np.pi*1j*(0.5*slope*t - bandwidth_hz/2.)*t) barker13 = np.array([1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1]).astype(np.float_) msl = np.array([-1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1]).astype(np.float_) uncoded = np.ones(40) lfm = make_lfm(51, 1e-6, 1e6) psrnd = np.array([-1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1]).astype(np.float_) codes = [barker13, msl, uncoded, lfm, psrnd] code_delays = [0]*len(codes) files = el.jicamarca.find_files(datadir) vlt_o = el.jicamarca.voltage_reader(files[598]) r = vlt_o.r vlt1 = vlt_o.read_from_block(8, 700, 0, chan_idx=0) vlt2 = vlt_o.read_from_block(9, 0, 700, chan_idx=0) vlt = np.concatenate((vlt1, vlt2), axis=0) t = vlt_o.block_times[8] + (700 + np.arange(vlt.shape[0]))*vlt_o.ipp ts = vlt_o.ts ipp = vlt_o.ipp f0 = 49920000.0 noise_vlt = vlt_o.read_from_block(8, 0, 0, sample_idx=el.slice_by_value(r, None, 80000), chan_idx=0) noise_sigma = np.sqrt(np.mean(noise_vlt.real**2 + noise_vlt.imag**2)) store = Bunch(vlt=vlt, r=r, t=t, codes=codes, code_delays=code_delays, ts=ts, ipp=ipp, f0=f0, noise_sigma=noise_sigma) with open('ejet_head_flare.pkl', 'wb') as f: cPickle.dump(store, f, protocol=-1)