本文整理汇总了Python中utils.saveplot函数的典型用法代码示例。如果您正苦于以下问题:Python saveplot函数的具体用法?Python saveplot怎么用?Python saveplot使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了saveplot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_scatter_reconstructed_core
def plot_scatter_reconstructed_core(table, N=None):
# Make sure to get a *copy*
figsize = list(rcParams['figure.figsize'])
figsize[0] = figsize[1] * 2
figure(figsize=figsize)
station = table.attrs.cluster.stations[0]
subplot(121)
x, y = table.col('reference_core_pos')[:N].T
#scatter(x, y, c='b', s=1, edgecolor='none', zorder=1)
plot(x, y, ',', c='b', markeredgecolor='b', zorder=1)
for detector in station.detectors:
x, y = detector.get_xy_coordinates()
plt.scatter(x, y, c='r', s=20, edgecolor='none', zorder=2)
xlabel("Distance [m]")
ylabel("Distance [m]")
xlim(-60, 60)
ylim(-60, 60)
title("simulated")
subplot(122)
x, y = table.col('reconstructed_core_pos')[:N].T
#scatter(x, y, c='b', s=1, edgecolor='none', zorder=1)
plot(x, y, ',', c='b', markeredgecolor='b', zorder=1)
for detector in station.detectors:
x, y = detector.get_xy_coordinates()
plt.scatter(x, y, c='r', s=20, edgecolor='none', zorder=2)
xlabel("Distance [m]")
ylabel("Distance [m]")
xlim(-60, 60)
ylim(-60, 60)
title("reconstructed")
utils.saveplot()
示例2: plot_uncertainty_core_distance
def plot_uncertainty_core_distance(table):
N = 2
THETA = deg2rad(22.5)
DTHETA = deg2rad(5.)
DN = .5
DR = 10
LOGENERGY = 15
DLOGENERGY = .5
figure()
x, y, y2 = [], [], []
for R in range(0, 81, 20):
x.append(R)
events = table.readWhere('(abs(min_n134 - N) <= DN) & (abs(reference_theta - THETA) <= DTHETA) & (abs(r - R) <= DR) & (abs(log10(k_energy) - LOGENERGY) <= DLOGENERGY)')
print len(events),
errors = events['reference_theta'] - events['reconstructed_theta']
# Make sure -pi < errors < pi
errors = (errors + pi) % (2 * pi) - pi
errors2 = events['reference_phi'] - events['reconstructed_phi']
# Make sure -pi < errors2 < pi
errors2 = (errors2 + pi) % (2 * pi) - pi
#y.append(std(errors))
#y2.append(std(errors2))
y.append((scoreatpercentile(errors, 83) - scoreatpercentile(errors, 17)) / 2)
y2.append((scoreatpercentile(errors2, 83) - scoreatpercentile(errors2, 17)) / 2)
print
print "R: theta_std, phi_std"
for u, v, w in zip(x, y, y2):
print u, v, w
print
# # Simulation data
sx, sy, sy2 = loadtxt(os.path.join(DATADIR, 'DIR-plot_uncertainty_core_distance.txt'))
graph = GraphArtist()
# Plots
plot(x, rad2deg(y), '^-', label="Theta")
graph.plot(x[:-1], rad2deg(y[:-1]), mark='o')
plot(sx, rad2deg(sy), '^-', label="Theta (sim)")
graph.plot(sx[:-1], rad2deg(sy[:-1]), mark='square')
plot(x, rad2deg(y2), 'v-', label="Phi")
graph.plot(x[:-1], rad2deg(y2[:-1]), mark='*')
plot(sx, rad2deg(sy2), 'v-', label="Phi (sim)")
graph.plot(sx[:-1], rad2deg(sy2[:-1]), mark='square*')
# Labels etc.
xlabel("Core distance [m] $\pm %d$" % DR)
graph.set_xlabel(r"Core distance [\si{\meter}] $\pm \SI{%d}{\meter}$" % DR)
ylabel("Angle reconstruction uncertainty [deg]")
graph.set_ylabel(r"Angle reconstruction uncertainty [\si{\degree}]")
title(r"$N_{MIP} = %d \pm %.1f, \theta = 22.5^\circ \pm %d^\circ, %.1f \leq \log(E) \leq %.1f$" % (N, DN, rad2deg(DTHETA), LOGENERGY - DLOGENERGY, LOGENERGY + DLOGENERGY))
ylim(ymin=0)
graph.set_ylimits(min=0)
xlim(-2, 62)
legend(numpoints=1, loc='best')
utils.saveplot()
artist.utils.save_graph(graph, dirname='plots')
print
示例3: plot_core_pos_uncertainty_vs_R
def plot_core_pos_uncertainty_vs_R(table):
figure()
x, y = table.col('reference_core_pos').T
x2, y2 = table.col('reconstructed_core_pos').T
d = sqrt((x - x2) ** 2 + (y - y2) ** 2)
r = table.col('r')
bins = linspace(0, 50, 41)
x, d25, d50, d75 = [], [], [], []
for low, high in zip(bins[:-1], bins[1:]):
sel = d.compress((low <= r) & (r < high))
if len(sel) > 0:
x.append((low + high) / 2)
d25.append(scoreatpercentile(sel, 25))
d50.append(scoreatpercentile(sel, 50))
d75.append(scoreatpercentile(sel, 75))
fill_between(x, d25, d75, color='0.75')
plot(x, d50, 'o-', color='black')
xlabel("Core distance [m]")
ylabel("Core position uncertainty [m]")
utils.saveplot()
示例4: plot_phi_reconstruction_results_for_MIP
def plot_phi_reconstruction_results_for_MIP(table, N):
THETA = deg2rad(22.5)
DTHETA = deg2rad(5.)
events = table.readWhere('(min_n134 >= N) & (abs(reference_theta - THETA) <= DTHETA)')
sim_phi = events['reference_phi']
r_phi = events['reconstructed_phi']
figure()
plot_2d_histogram(rad2deg(sim_phi), rad2deg(r_phi), 180)
xlabel(r"$\phi_K$ [deg]")
ylabel(r"$\phi_H$ [deg]")
title(r"$N_{MIP} \geq %d, \quad \theta = 22.5^\circ \pm %d^\circ$" % (N, rad2deg(DTHETA)))
utils.saveplot(N)
graph = artist.GraphArtist()
bins = linspace(-180, 180, 73)
H, x_edges, y_edges = histogram2d(rad2deg(sim_phi), rad2deg(r_phi),
bins=bins)
graph.histogram2d(H, x_edges, y_edges, type='reverse_bw')
graph.set_xlabel(r'$\phi_K$ [\si{\degree}]')
graph.set_ylabel(r'$\phi_H$ [\si{\degree}]')
graph.set_xticks(range(-180, 181, 90))
graph.set_yticks(range(-180, 181, 90))
artist.utils.save_graph(graph, suffix=N, dirname='plots')
示例5: plot_sciencepark_cluster
def plot_sciencepark_cluster():
stations = range(501, 507)
cluster = clusters.ScienceParkCluster(stations)
figure()
x_list, y_list = [], []
x_stations, y_stations = [], []
for station in cluster.stations:
x_detectors, y_detectors = [], []
for detector in station.detectors:
x, y = detector.get_xy_coordinates()
x_detectors.append(x)
y_detectors.append(y)
scatter(x, y, c='black', s=3)
x_list.extend(x_detectors)
y_list.extend(y_detectors)
x_stations.append(mean(x_detectors))
y_stations.append(mean(y_detectors))
axis('equal')
cluster = clusters.ScienceParkCluster([501, 503, 506])
pos = []
for station in cluster.stations:
x, y, alpha = station.get_xyalpha_coordinates()
pos.append((x, y))
for (x0, y0), (x1, y1) in itertools.combinations(pos, 2):
plot([x0, x1], [y0, y1], 'gray')
utils.savedata([x_list, y_list])
utils.saveplot()
artist.utils.save_data([x_list, y_list], suffix='detectors',
dirname='plots')
artist.utils.save_data([stations, x_stations, y_stations],
suffix='stations', dirname='plots')
示例6: median_core_distance_vs_time
def median_core_distance_vs_time():
plt.figure()
plot_and_fit_statistic(lambda a: scoreatpercentile(a, 25))
plot_and_fit_statistic(lambda a: scoreatpercentile(a, 75))
utils.title("Shower front timing structure (25, 75 %)")
utils.saveplot()
plt.xlabel("Core distance [m]")
plt.ylabel("Median arrival time [ns]")
legend(loc='lower right')
示例7: plot_spectrum_fit_chisq
def plot_spectrum_fit_chisq(self):
global integrals
if 'integrals' not in globals():
events = self.data.root.hisparc.cluster_kascade.station_601.events
integrals = events.col('integrals')[:, 0]
bins = np.linspace(0, RANGE_MAX, N_BINS + 1)
n, bins = np.histogram(integrals, bins=bins)
x = (bins[:-1] + bins[1:]) / 2
p_gamma, p_landau = self.full_spectrum_fit(x, n, (1., 1.),
(5e3 / .32, 3.38 / 5000, 1.))
print "FULL FIT"
print p_gamma, p_landau
print "charged fraction:", self.calc_charged_fraction(x, n, p_gamma, p_landau)
landaus = scintillator.conv_landau_for_x(x, *p_landau)
gammas = self.gamma_func(x, *p_gamma)
fit = landaus + gammas
x_trunc = x.compress((LOW <= x) & (x < HIGH))
n_trunc = n.compress((LOW <= x) & (x < HIGH))
fit_trunc = fit.compress((LOW <= x) & (x < HIGH))
chisq, pvalue = stats.chisquare(n_trunc, fit_trunc, ddof=5)
chisq /= (len(n_trunc) - 1 - 5)
print "Chi-square statistic:", chisq, pvalue
plt.figure()
plt.plot(x * VNS, n)
self.plot_landau_and_gamma(x, p_gamma, p_landau)
#plt.plot(x_trunc * VNS, fit_trunc, linewidth=4)
plt.axvline(LOW * VNS)
plt.axvline(HIGH * VNS)
plt.xlabel("Pulse integral [V ns]")
plt.ylabel("Count")
plt.yscale('log')
plt.xlim(0, 20)
plt.ylim(1e2, 1e5)
plt.title(r"$\chi^2_{red}$: %.2f, p-value: %.2e" % (chisq, pvalue))
utils.saveplot()
plt.figure()
plt.plot(x_trunc * VNS, n_trunc - fit_trunc)
plt.axhline(0)
plt.xlabel("Pulse integral [V ns]")
plt.ylabel("Data - Fit")
plt.title(r"$\chi^2_{red}$: %.2f, p-value: %.2e" % (chisq, pvalue))
utils.saveplot(suffix='residuals')
示例8: plot_fsot_vs_lint_for_zenith
def plot_fsot_vs_lint_for_zenith(fsot, lint):
bins = linspace(0, 35, 21)
min_N = 1
x, f_y, f_y2, l_y, l_y2 = [], [], [], [], []
for low, high in zip(bins[:-1], bins[1:]):
rad_low = deg2rad(low)
rad_high = deg2rad(high)
query = '(min_n134 >= min_N) & (rad_low <= reference_theta) & (reference_theta < rad_high)'
f_sel = fsot.readWhere(query)
l_sel = lint.readWhere(query)
errors = f_sel['reconstructed_phi'] - f_sel['reference_phi']
errors2 = f_sel['reconstructed_theta'] - f_sel['reference_theta']
#f_y.append(std(errors))
#f_y2.append(std(errors2))
f_y.append((scoreatpercentile(errors, 83) - scoreatpercentile(errors, 17)) / 2)
f_y2.append((scoreatpercentile(errors2, 83) - scoreatpercentile(errors2, 17)) / 2)
errors = l_sel['reconstructed_phi'] - l_sel['reference_phi']
errors2 = l_sel['reconstructed_theta'] - l_sel['reference_theta']
#l_y.append(std(errors))
#l_y2.append(std(errors2))
l_y.append((scoreatpercentile(errors, 83) - scoreatpercentile(errors, 17)) / 2)
l_y2.append((scoreatpercentile(errors2, 83) - scoreatpercentile(errors2, 17)) / 2)
x.append((low + high) / 2)
print x[-1], len(f_sel), len(l_sel)
clf()
plot(x, rad2deg(f_y), label="FSOT phi")
plot(x, rad2deg(f_y2), label="FSOT theta")
plot(x, rad2deg(l_y), label="LINT phi")
plot(x, rad2deg(l_y2), label="LINT theta")
legend()
xlabel("Shower zenith angle [deg]")
ylabel("Angle reconstruction uncertainty [deg]")
title(r"$N_{MIP} \geq %d$" % min_N)
utils.saveplot()
graph = GraphArtist()
graph.plot(x, rad2deg(f_y), mark=None)
graph.plot(x, rad2deg(l_y), mark=None, linestyle='dashed')
graph.plot(x, rad2deg(f_y2), mark=None)
graph.plot(x, rad2deg(l_y2), mark=None, linestyle='dashed')
graph.set_xlabel(r"Shower zenith angle [\si{\degree}]")
graph.set_ylabel(r"Angle reconstruction uncertainty [\si{\degree}]")
artist.utils.save_graph(graph, dirname='plots')
示例9: plot_shower_size_hist
def plot_shower_size_hist(table):
figure()
reconstructed = table.col('reconstructed_shower_size')
hist(log10(reconstructed), bins=200, histtype='step')
reference_shower_size = table[0]['reference_shower_size']
if reference_shower_size == 0.:
reference_shower_size = 10 ** 4.8
axvline(log10(reference_shower_size))
xlabel("log shower size")
ylabel("count")
utils.saveplot()
示例10: hist_theta_single_stations
def hist_theta_single_stations(data):
reconstructions = data.root.reconstructions.reconstructions
figure()
for n, station in enumerate(range(501, 507), 1):
subplot(2, 3, n)
query = '(N == 1) & s%d' % station
theta = reconstructions.read_where(query, field='reconstructed_theta')
hist(rad2deg(theta), bins=linspace(0, 45, 21), histtype='step')
xlabel(r"$\theta$")
legend([station])
locator_params(tight=True, nbins=4)
utils.saveplot()
示例11: boxplot_arrival_times
def boxplot_arrival_times(group, N):
table = group.E_1PeV.zenith_0
sel = table.read_where('min_n134 >= N')
t1 = sel[:]['t1']
t3 = sel[:]['t3']
t4 = sel[:]['t4']
ts = concatenate([t1, t3, t4])
print "Median arrival time delay over all detected events", median(ts)
figure()
bin_edges = linspace(0, 100, 11)
x, arrival_times = [], []
t25, t50, t75 = [], [], []
for low, high in zip(bin_edges[:-1], bin_edges[1:]):
query = '(min_n134 >= N) & (low <= r) & (r < high)'
sel = table.read_where(query)
t1 = sel[:]['t1']
t2 = sel[:]['t2']
ct1 = t1.compress((t1 > -999) & (t2 > -999))
ct2 = t2.compress((t1 > -999) & (t2 > -999))
ts = abs(ct2 - ct1)
t25.append(scoreatpercentile(ts, 25))
t50.append(scoreatpercentile(ts, 50))
t75.append(scoreatpercentile(ts, 75))
x.append((low + high) / 2)
fill_between(x, t25, t75, color='0.75')
plot(x, t50, 'o-', color='black')
xlabel("Core distance [m]")
ylabel("Arrival time delay [ns]")
#title(r"$N_{MIP} \geq %d, \quad \theta = 0^\circ$" % N)
xticks(arange(0, 100.5, 10))
utils.savedata((x, t25, t50, t75), N)
utils.saveplot(N)
graph = GraphArtist()
graph.shade_region(x, t25, t75)
graph.plot(x, t50, linestyle=None)
graph.set_xlabel(r"Core distance [\si{\meter}]")
graph.set_ylabel(r"Arrival time difference $|t_2 - t_1|$ [\si{\nano\second}]")
graph.set_xlimits(0, 100)
graph.set_ylimits(min=0)
artist.utils.save_graph(graph, suffix=N, dirname='plots')
示例12: scatterplot_core_distance_vs_time
def scatterplot_core_distance_vs_time():
plt.figure()
sim = data.root.showers.E_1PeV.zenith_0
electrons = sim.electrons
plt.loglog(electrons[:]['core_distance'], electrons[:]['arrival_time'], ',')
plt.xlim(1e0, 1e2)
plt.ylim(1e-3, 1e3)
plt.xlabel("Core distance [m]")
plt.ylabel("Arrival time [ns]")
utils.title("Shower front timing structure")
utils.saveplot()
示例13: plot_coordinate_density
def plot_coordinate_density():
figure()
suptitle("densities")
x, y, alpha = generate_random_coordinates_in_circle(10, 100000)
xp, yp, alphap = transform_coordinates(x, y, alpha)
subplot("121", aspect="equal")
draw_coordinate_density(x, y)
title("shower-centered coordinates")
subplot("122", aspect="equal")
draw_coordinate_density(xp, yp)
title("cluster-centered coordinates")
utils.saveplot()
示例14: plot_uncertainty_zenith_angular_distance
def plot_uncertainty_zenith_angular_distance(group):
group = group.E_1PeV
rec = DirectionReconstruction
N = 2
# constants for uncertainty estimation
# BEWARE: stations must be the same over all reconstruction tables used
station = group.zenith_0.attrs.cluster.stations[0]
r1, phi1 = station.calc_r_and_phi_for_detectors(1, 3)
r2, phi2 = station.calc_r_and_phi_for_detectors(1, 4)
figure()
graph = GraphArtist()
# Uncertainty estimate
x = linspace(0, deg2rad(45), 50)
#x = array([pi / 8])
phis = linspace(-pi, pi, 50)
y, y2 = [], []
for t in x:
y.append(mean(rec.rel_phi_errorsq(t, phis, phi1, phi2, r1, r2)))
y2.append(mean(rec.rel_theta1_errorsq(t, phis, phi1, phi2, r1, r2)))
y = TIMING_ERROR * sqrt(array(y))
y2 = TIMING_ERROR * sqrt(array(y2))
ang_dist = sqrt((y * sin(x)) ** 2 + y2 ** 2)
#plot(rad2deg(x), rad2deg(y), label="Estimate Phi")
#plot(rad2deg(x), rad2deg(y2), label="Estimate Theta")
plot(rad2deg(x), rad2deg(ang_dist), label="Angular distance")
graph.plot(rad2deg(x), rad2deg(ang_dist), mark=None)
print rad2deg(x)
print rad2deg(y)
print rad2deg(y2)
print rad2deg(y * sin(x))
print rad2deg(ang_dist)
# Labels etc.
xlabel("Shower zenith angle [deg]")
ylabel("Angular distance [deg]")
graph.set_xlabel(r"Shower zenith angle [\si{\degree}]")
graph.set_ylabel(r"Angular distance [\si{\degree}]")
graph.set_ylimits(min=6)
#title(r"$N_{MIP} \geq %d$" % N)
#ylim(0, 100)
#legend(numpoints=1)
utils.saveplot()
artist.utils.save_graph(graph, dirname='plots')
print
示例15: plot_detection_efficiency_vs_R_for_angles
def plot_detection_efficiency_vs_R_for_angles(N):
figure()
graph = GraphArtist()
locations = iter(['right', 'left', 'below left'])
positions = iter([.18, .14, .15])
bin_edges = linspace(0, 100, 20)
x = (bin_edges[:-1] + bin_edges[1:]) / 2.
for angle in [0, 22.5, 35]:
angle_str = str(angle).replace('.', '_')
shower_group = '/simulations/E_1PeV/zenith_%s' % angle_str
efficiencies = []
for low, high in zip(bin_edges[:-1], bin_edges[1:]):
shower_results = []
for shower in data.list_nodes(shower_group):
sel_query = '(low <= r) & (r < high)'
coinc_sel = shower.coincidences.read_where(sel_query)
ids = coinc_sel['id']
obs_sel = shower.observables.read_coordinates(ids)
assert (obs_sel['id'] == ids).all()
o = obs_sel
sel = obs_sel.compress((o['n1'] >= N) & (o['n3'] >= N) &
(o['n4'] >= N))
shower_results.append(len(sel) / len(obs_sel))
efficiencies.append(mean(shower_results))
plot(x, efficiencies, label=r'$\theta = %s^\circ$' % angle)
graph.plot(x, efficiencies, mark=None)
graph.add_pin(r'\SI{%s}{\degree}' % angle,
location=locations.next(), use_arrow=True,
relative_position=positions.next())
xlabel("Core distance [m]")
graph.set_xlabel(r"Core distance [\si{\meter}]")
ylabel("Detection efficiency")
graph.set_ylabel("Detection efficiency")
#title(r"$N_{MIP} \geq %d$" % N)
legend()
graph.set_xlimits(0, 100)
graph.set_ylimits(0, 1)
utils.saveplot(N)
artist.utils.save_graph(graph, suffix=N, dirname='plots')