def plot_epq_all_m(): # manually without dbData d = uswipha(year=[1993, 1994], tf=[[1, 366]]) d.set_mask('Master', 'ech', 10, 2400) fig, ax = plt.subplots() valx = d.get_data('Master', 'tch') valy = d.get_data('Master', 'epq') binx = arange(180, 480) biny = arange(0, 66) C, X, Y = histogram2d(valx, valy, bins=[binx, biny]) vmin = amin(C[C > 0]) vmax = amax(C) colormap = plt.cm.get_cmap("viridis") colormap.set_under('white') Mesh = ax.pcolormesh(X, Y, C.T, cmap=colormap, vmin=vmin, vmax=vmax, rasterized=True, norm=colors.LogNorm(vmin=vmin, vmax=vmax)) ax.xaxis.grid(True, c='k', ls=':') ax.yaxis.grid(True, c='k', ls=':') # colorbar: divider = make_axes_locatable(ax) cbax = divider.append_axes("right", size="5%", pad=0.05) cb = plt.colorbar(Mesh, cax=cbax) cb.ax.tick_params(labelsize=10) cb.set_label('counts') ax.set_xlabel('ToF Channel') ax.set_ylabel('ESA') plt.savefig('Plots/epq_all.pdf')
def test_plot(size=(10, 8)): d = uswipha(year=[1993, 1994], tf=[[1, 366]]) d.set_mask('Master', 'ech', 10, 2400) fig, ax = plt.subplots(figsize=size) valx = d.get_data('Master', 'tch') valy = d.get_data('Master', 'epq') binx = arange(200, 430) biny = arange(0, 65) C, X, Y = histogram2d(valx, valy, bins=[binx, biny]) vmin = amin(C[C > 0]) vmax = amax(C) colormap = plt.cm.get_cmap("viridis") colormap.set_under('white') Mesh = ax.pcolormesh(X, Y, C.T, cmap=colormap, vmin=vmin, vmax=vmax, rasterized=True) ax.xaxis.grid(True, c='k', ls=':') ax.yaxis.grid(True, c='k', ls=':') divider = make_axes_locatable(ax) cbax = divider.append_axes("right", size="5%", pad=0.05) cb = plt.colorbar(Mesh, cax=cbax) cb.ax.tick_params(labelsize=10) cb.set_label('counts') ax.set_xlabel('TCH') ax.set_ylabel('EPQ') plt.savefig('%s_%s.pdf' % (size[0], size[1]))
def plot_epq_He1_m(): d = uswipha(year=[1993, 1994], tf=[[1, 366]], path='/home/asterix/fischer/PUI/Ulysses/data_misc/pha_he/') fig, ax = plt.subplots() valx = d.get_data('Master', 'tch') valy = d.get_data('Master', 'epq') binx = arange(180, 480) biny = arange(0, 66) C, X, Y = histogram2d(valx, valy, bins=[binx, biny]) # vmin = amin(C[C > 0]) # vmax = amax(C) vmin = 1. vmax = 63504. colormap = plt.cm.get_cmap("viridis") colormap.set_under('white') Mesh = ax.pcolormesh(X, Y, C.T, cmap=colormap, vmin=vmin, vmax=vmax, rasterized=True, norm=colors.LogNorm(vmin=vmin, vmax=vmax)) ax.xaxis.grid(True, c='k', ls=':') ax.yaxis.grid(True, c='k', ls=':') # colorbar: divider = make_axes_locatable(ax) cbax = divider.append_axes("right", size="5%", pad=0.05) cb = plt.colorbar(Mesh, cax=cbax) cb.ax.tick_params(labelsize=10) cb.set_label('counts') ax.set_xlabel('ToF Channel') ax.set_ylabel('ESA') plt.savefig('Plots/epq_He1.pdf')
def load_B(year, B=90): d1 = uswipha(year=year, tf=[[1, 366]], path='/home/asterix/fischer/PUI/Ulysses/data_misc/PHA_mag/') d1.sync_swoops() d1.sync_traj() d1.set_mask('Master', 'vsw', 600, max_vel, reset=True) d1.set_mask('Master', 'rng', 0, 0, reset=True) d1.set_mask('Master', 'det', 0, 2, reset=True) # cut out det = 3 (=rubbish?) d1.set_mask('Master', 'ech', 12, 250, reset=True) # exclude doubles d1.set_mask('Master', 'brw', 1, 1, reset=True) d1.set_mask('Master', 'Btheta', -5. / 180. * np.pi, 5. / 180. * np.pi, reset=True) if B == 90: #d1.set_mask('Master','Bphi',-93./180.*np.pi,-87./180.*np.pi,reset=True) d1.set_mask('Master', 'Bphi', 87. / 180. * np.pi, 93. / 180. * np.pi) if B == 0: d1.set_mask('Master', 'Bphi', -15 / 180. * np.pi, 15. / 180. * np.pi, reset=True) if B == 45: d1.set_mask('Master', 'Bphi', -140. / 180. * np.pi, -130. / 180. * np.pi, reset=True) d1.set_mask('Master', 'Bphi', 40. / 180. * np.pi, 50. / 180. * np.pi) # get a real subset with masks applied: print('*** Save Subset ***') d1.save_subset('Master', filename='d1.tmp') print('*** Load Subset ***') d1.load_subset(filename='d1.tmp', force=True) D = Dist3D(d1, mass=4, charge=1, sc_vel=True) norm_arr, H0 = D.calc_skymapspec(phirange=phirange, thetarange=thetarange, angstep=angstep, wshellbins=wbins) H0[norm_arr == 0] = -5 norm_arr[norm_arr == 0] = 1 H = H0 / norm_arr return H
def load_data_year(y, start=1, stop=166, vel2=max_vel, r_au=None, ax=None): d1 = uswipha( year=y, tf=[[start, stop]], path='/home/asterix/fischer/PUI/Ulysses/data_misc/PHA_mag/') d1.sync_swoops() d1.sync_traj() d1.set_mask('Master', 'vsw', 700, vel2, reset=True) d1.set_mask('Master', 'rng', 0, 0, reset=True) d1.set_mask('Master', 'det', 0, 2, reset=True) # cut out det = 3 (=rubbish?) d1.set_mask('Master', 'ech', 12, 250, reset=True) # exclude doubles d1.set_mask('Master', 'brw', 1, 1, reset=True) d1.set_mask('Master', 'epq', 0, 17, reset=True) # set masks for excluding ecliptic: d1.set_mask('Master', 'lat_hg', -90, -25, reset=True) d1.set_mask('Master', 'lat_hg', 25, 90) #d1.set_mask('Master','rau', r_au-0.05, r_au+0.05) # get a real subset with masks applied: print('*** Save Subset ***') d1.save_subset('Master', filename='d1.tmp') print('*** Load Subset ***') d1.load_subset(filename='d1.tmp', force=True) D = Dist3D(d1, mass=4, charge=1, sc_vel=True) nr = D.d.data['year'].shape H0, norm_arr = D.wspec_1d(ax=ax, name="%s, %s - %s" % (y, start, stop), mode='ps', wbins=wbins) H_cts = H0[:] H0[norm_arr == 0] = 0 norm_arr[norm_arr == 0] = 1 H = H0 / norm_arr # # set up single plot: # fig, ax = plt.subplots(figsize=(6,5)) # fig.suptitle('%s'%y) # ax.set_xlim(-0.55,2.1) # ax.xaxis.set_minor_locator(MultipleLocator(.5)) # ax.set_xlabel(r'$\mathrm{w_{sw}}$') # ax.set_ylabel('phase space density') # ax.plot(wbins[:-1], H, drawstyle ='steps-post', label='PSD', linestyle = '-') # ax.plot(wbins[:-1], H_cts, drawstyle='steps-post', label = 'counts', linestyle = ':') # ax.plot(wbins[:-1], norm_arr, drawstyle='steps-post', label = 'norm', linestyle = '--') # ax.legend() #pylab.show() return H
def plot_epq_all(): d = uswipha(year=[1993, 1994], tf=[[1, 6]]) d.set_mask('Master', 'ech', 10, 2400) d.hist2d('tch', 'epq', binx=arange(200, 430), biny=arange(0, 65), xlabel='TCH', ylabel='ECH', cb='normalized counts', style='contour', norm='ymax') plt.savefig('test.pdf')
def plot_et_matrix(): d = uswipha(year=[1993, 1994], tf=[[1, 366]]) d.set_mask('Master', 'epq', 24, 24) d.set_mask('Master', 'ech', 10, 2400) d.hist2d('tch', 'ech', binx=arange(240, 560), biny=arange(0, 130), xlabel='TCH', ylabel='ECH', cb='counts', style='contour')
def load_year(y): d1 = uswipha(year=y, tf=[[1, 366]], path='/home/asterix/fischer/PUI/Ulysses/data_misc/pha_he/') d1.sync_swoops() #d1.sync_traj() d1.set_mask('Master', 'rng', 0, 0, reset=True) d1.set_mask('Master', 'det', 0, 2, reset=True) # cut out det = 3 (=rubbish?) d1.set_mask('Master', 'ech', 12, 250, reset=True) # exclude doubles #d1.set_mask('Master', 'brw', 1, 1, reset=True) d1.set_mask('Master', 'epq', 0, 17, reset=True) # get a real subset with masks applied: print('*** Save Subset ***') d1.save_subset('Master', filename='d1.tmp') print('*** Load Subset ***') d1.load_subset(filename='d1.tmp', force=True) vsw = d1.data['vsw'] return vsw
def evolution_B_PHA(): ''' plot B data from reduced PHA file ''' fig1, ax1 = plt.subplots(figsize=(8, 7)) fig2, ax2 = plt.subplots(figsize=(8, 7)) fig3, ax3 = plt.subplots(figsize=(8, 7)) d = uswipha(year=range(1993, 2001), tf=[[1, 366]], path='/home/asterix/fischer/PUI/Ulysses/data_misc/PHA_mag/') doy = d.data['doy'][::10] year = d.data['year'][::10] time = year + doy / 365. ax1.plot(time, d.data['Bphi'][::10], marker='o', label='Bphi', ms=1) ax2.plot(time, d.data['Btheta'][::10], marker='o', label='Btheta', ms=1) # ax1.plot(time, d.data['BR'][::100], marker='o', label='BR', ms=1) # ax2.plot(time, d.data['BT'][::100], marker='o', label='BT', ms=1) # ax3.plot(time, d.data['BN'][::100], marker='o', label='BN', ms=1) ax1.legend() ax2.legend() ax3.legend() plt.show()
#from WSky import WSky ### # Script for creating an instance d of uswipha and setting masks (s.b.) ### He1 = True #False He2 = False #True # load Ulysses data: years = [1995] start = time.time() if He1: d1 = uswipha(year=years, tf=[[101, 122]]) d1.sync_swoops() d1.sync_traj_spice() d1.sync_mag() d1.set_mask('Master', 'rng', 0, 0, reset=True) # priority range 0 d1.set_mask('Master', 'det', 0, 2, reset=True) # cut out det = 3 (=rubbish?) d1.set_mask('Master', 'ech', 12, 250, reset=True) # exclude doubles d1.set_mask('Master', 'brw', 1, 1, reset=True) #d1.set_mask('Master','vsw',750,780, reset = True) #d1.set_mask('Master', 'epq', 0, 19, reset=True) #d1.set_mask('Master', 'epq', 30,31, reset=True) #d1.set_mask('Master', 'r', 0, 1.38, reset=True)
from matplotlib import pylab from DataLoader.uswipha import uswipha # PHA loader from dist3D_pui_ulysses import Dist3D from WSlice import WSlice d = uswipha(year=1995, tf=[[1, 4]]) # load He+ PHA data d.sync_swoops() # synchronize SW data d.sync_traj() # synchronize trajectory data ''' some filtering ''' d.set_mask('Master', 'rng', 0, 0, reset=True) d.set_mask('Master', 'det', 0, 2, reset=True) # cut out det = 3 (=rubbish?) d.set_mask('Master', 'ech', 12, 250, reset=True) # exclude doubles d.set_mask('Master', 'epq', 0, 19, reset=True) # get a real subset with masks applied: print('*** Save Subset ***') d.save_subset('Master', filename='d1.tmp') print('*** Load Subset ***') d.load_subset(filename='d1.tmp', force=True) D3 = Dist3D(d, mass=4, charge=1, sc_vel=True) W = WSlice( D3, mode='ps' ) # mode is 'ps' for phase space density, can also be 'counts' or 'norm' (for phase space volume) # W.init_plot() in ipython opens an interactive figure: click thoruh the slices with arrows left/right and change the cut direction (along R/T/N) with arrows up/down