def plot_densities(data): """Make particle count plots for each detector to compare densities/responses""" n_min = 0.001 # remove peak at 0 n_max = 9 bins = np.linspace(n_min, n_max, 80) events = data.get_node('/s1001', 'events') sum_n = events.col('n1') + events.col('n2') n = [events.col('n1'), events.col('n2')] for minn in [0, 1, 2, 4, 8, 16]: filter = sum_n > minn plot = Plot(width=r'.25\linewidth', height=r'.25\linewidth') i = 0 j = 1 ncounts, x, y = np.histogram2d(n[i].compress(filter), n[j].compress(filter), bins=bins) plot.histogram2d(ncounts, x, y, type='reverse_bw', bitmap=True) plot.set_xlimits(min=0, max=n_max) plot.set_ylimits(min=0, max=n_max) plot.set_xlabel('Number of particles in detector 1') plot.set_ylabel('Number of particles in detector 2') plot.save_as_pdf('plots/n_minn%d_1001' % minn)
def plot_detected_v_energy(): plot = Plot(width=r'.6\textwidth') # plot.set_title('Detected core distances vs shower energy') c, xb, yb = histogram2d(r_in, energy_in, bins=(arange(0, 600, 40), arange(15.75, 17.76, .5))) plot.histogram2d(c, xb, yb, bitmap=True) plot.set_yticks([16, 16.5, 17, 17.5]) plot.set_ytick_labels(['$10^{%.1f}$' % e for e in [16, 16.5, 17, 17.5]]) plot.set_ylabel(r'Shower energy [\si{\eV}]') plot.set_xlabel(r'Core distance [\si{\meter}]') plot.save_as_pdf('detected_v_energy') plot = Plot(width=r'.6\textwidth') # plot.set_title('Detected core distances vs shower energy, scaled to bin area') counts, xbins, ybins = histogram2d(r_in, energy_in, bins=(arange(0, 600, 40), arange(15.75, 17.76, .5))) plot.histogram2d((-counts.T / (pi * (xbins[:-1]**2 - xbins[1:]**2))).T, xbins, ybins, type='area') plot.set_yticks([16, 16.5, 17, 17.5]) plot.set_ytick_labels(['$10^{%.1f}$' % e for e in [16, 16.5, 17, 17.5]]) plot.set_ylabel(r'Shower energy [\si{\eV}]') plot.set_xlabel(r'Core distance [\si{\meter}]') plot.save_as_pdf('detected_v_energy_scaled_area')
def plot_comparison_501_510(stats, field_name): plot = Plot() bins = arange(0, 1, .02) ref_stat = stats[501][field_name][0] stat = stats[510][field_name][0] tmp_stat = stat.compress((ref_stat > 0) & (stat > 0)) tmp_ref_stat = ref_stat.compress((ref_stat > 0) & (stat > 0)) counts, xbin, ybin = histogram2d(tmp_stat, tmp_ref_stat, bins=bins) plot.histogram2d(counts, xbin, ybin, type='reverse_bw', bitmap=True) plot.plot([0, 1.2], [0, 1.2], mark=None, linestyle='red, very thin') if field_name == 'event_rate': label = r'Event rate [\si{\hertz}]' elif field_name == 'mpv': label = r'MPV [ADC.ns]' else: label = (r'Fraction of bad %s data [\si{\percent}]' % field_name.replace('_', ' ')) plot.set_ylabel(label) plot.set_xlabel(label) if field_name in ['event_rate', 'mpv']: plot.save_as_pdf('plots_501_510/compare_%s' % field_name) else: plot.save_as_pdf('plots_501_510/compare_bad_fraction_%s' % field_name)
def main(): x = np.random.normal(0, 50, 50000) y = np.random.normal(0, 15, 50000) ranges = ([(-100, 0), (-50, 0)], [(0, 100), (-50, 0)], [(-100, 0), (0, 50)], [(0, 100), (0, 50)]) types = ('reverse_bw', 'color', 'bw', 'area') bitmaps = (True, True, False, False) subplot_idxs = [(1, 0), (1, 1), (0, 0), (0, 1)] plot = Plot() mplot = MultiPlot(2, 2, width=r'.4\linewidth') for idx, r, t, b in zip(subplot_idxs, ranges, types, bitmaps): n, xbins, ybins = np.histogram2d(x, y, bins=15, range=r) plot.histogram2d(n, xbins, ybins, type=t, bitmap=b) p = mplot.get_subplot_at(*idx) p.histogram2d(n, xbins, ybins, type=t, bitmap=b) mplot.show_yticklabels_for_all([(1, 0), (0, 1)]) mplot.show_xticklabels_for_all([(1, 0), (0, 1)]) plot.save('histogram2d') mplot.save('multi_histogram2d')
def analyse_reconstructions(data): cq = CoincidenceQuery(data) c_ids = data.root.coincidences.coincidences.read_where('s505 & (timestamp < 1366761600)', field='id') c_recs = cq.reconstructions.read_coordinates(c_ids) s_ids = data.root.hisparc.cluster_amsterdam.station_505.events.get_where_list('timestamp < 1366761600') s_recs = data.root.hisparc.cluster_amsterdam.station_505.reconstructions.read_coordinates(s_ids) assert len(c_recs) == len(s_recs) zenc = c_recs['zenith'] azic = c_recs['azimuth'] zens = s_recs['zenith'] azis = s_recs['azimuth'] high_zenith = (zenc > .2) & (zens > .2) for minn in [1, 2, 4, 8, 16]: filter = (s_recs['min_n'] > minn) length = len(azis.compress(high_zenith & filter)) shifts501 = np.random.normal(0, .06, length) azicounts, x, y = np.histogram2d(azis.compress(high_zenith & filter) + shifts501, azic.compress(high_zenith & filter), bins=np.linspace(-np.pi, np.pi, 73)) plota = Plot() plota.histogram2d(azicounts, np.degrees(x), np.degrees(y), type='reverse_bw', bitmap=True) # plota.set_title('Reconstructed azimuths for events in coincidence (zenith gt .2 rad)') plota.set_xlabel(r'$\phi_{505}$ [\si{\degree}]') plota.set_ylabel(r'$\phi_{Science Park}$ [\si{\degree}]') plota.set_xticks([-180, -90, 0, 90, 180]) plota.set_yticks([-180, -90, 0, 90, 180]) plota.save_as_pdf('azimuth_505_spa_minn%d' % minn)
def plot_results(distances, energies, results): plot = Plot('loglog') plot.histogram2d(np.log10(results[:-1, :-1] + 10), distances, energies, bitmap=True) plot.set_ylabel('Shower energy') plot.set_xlabel('Distance between stations') plot.save_as_pdf('distance_energy_v_area')
def compare_ttrigger(): with tables.open_file(DATA_PATH, 'r') as data: processed = data.get_node(GROUP, 'events_processed') filtered = data.get_node(GROUP, 'events_filtered') assert all( processed.col('ext_timestamp') == filtered.col('ext_timestamp')) trig_proc = processed.col('t_trigger') trig_filt = filtered.col('t_trigger') dt_trigger = trig_filt - trig_proc density = (processed.col('n1') + processed.col('n2') + processed.col('n3') + processed.col('n4')) / 2 print 'Density range:', density.min(), density.max() print 'dt trigger range:', dt_trigger.min(), dt_trigger.max() if len(trig_proc) > 4000: plot = Plot() bins = [linspace(0, 30, 100), arange(-11.25, 75, 2.5)] c, x, y = histogram2d(density, dt_trigger, bins=bins) # plot.histogram2d(c, x, y, bitmap=True, type='color', colormap='viridis') plot.histogram2d(log10(c + 0.01), x, y, type='area') plot.set_xlabel('Particle density') plot.set_ylabel('Difference in trigger time') plot.save_as_pdf('hist2d') else: plot = Plot() plot.scatter( density, dt_trigger, mark='o', markstyle='mark size=0.6pt, very thin, semitransparent') plot.set_xlabel('Particle density') plot.set_ylabel('Difference in trigger time') plot.save_as_pdf('scatter') plot = Plot() c, bins = histogram(dt_trigger, arange(-10, 200, 2.5)) c = where(c < 100, c, 100) plot.histogram(c, bins) plot.set_ylimits(0, 100) plot.set_ylabel('Counts') plot.set_xlabel('Difference in trigger time') plot.save_as_pdf('histogram') plot = Plot() c, bins = histogram(trig_proc, arange(-10, 200, 2.5)) plot.histogram(c, bins) c, bins = histogram(trig_filt, arange(-10, 200, 2.5)) plot.histogram(c, bins, linestyle='red') plot.set_ylimits(0) plot.set_ylabel('Counts') plot.set_xlabel('Trigger time') plot.save_as_pdf('histogram_t')
def plot_comparisons(data): multi_cidx = data.root.coincidences.coincidences.get_where_list('N > 2') c_idx = data.root.coincidences.c_index[multi_cidx] min_zenith = 0.2 r510 = data.get_node('/hisparc/cluster_amsterdam/station_510/', 'reconstructions') subset510 = [True] * r510.nrows id510 = next(i for i, s in enumerate(data.root.coincidences.s_index[:]) if s.endswith('_510')) for cidx in c_idx: if sum(cidx[:, 0] == id510) > 1: eid = next(i for s, i in cidx if s == id510) subset510[eid] = False r510a = r510.col('azimuth').compress(subset510) r510z = r510.col('zenith').compress(subset510) filter510 = r510z > min_zenith for order in itertools.permutations(range(4), 4): r507 = data.get_node('/hisparc/cluster_amsterdam/station_507/', REC_PATH % order) subset507 = [True] * r507.nrows id507 = next(i for i, s in enumerate(data.root.coincidences.s_index[:]) if s.endswith('_507')) for cidx in c_idx: if sum(cidx[:, 0] == id507) > 1: eid = next(i for s, i in cidx if s == id507) subset507[eid] = False r507a = r507.col('azimuth').compress(subset507) r507z = r507.col('zenith').compress(subset507) filter507 = r507z > min_zenith # Ensure neither has low zenith angle to avoid high uncertaintly # on azimuth. filter = filter510 & filter507 counts, xbins, ybins = histogram2d(r507a.compress(filter), r510a.compress(filter), bins=linspace(-pi, pi, 40)) plot = Plot() plot.histogram2d(counts, xbins, ybins, bitmap=True, type='color') plot.set_ylabel(r'Azimuth 510 [\si{\radian}]') plot.set_xlabel(r'Azimuth 507 [\si{\radian}]') plot.save_as_pdf(REC_PATH % order) counts, xbins, ybins = histogram2d(r507z, r510z, bins=linspace(0, pi / 2., 40)) plot = Plot() plot.histogram2d(counts, xbins, ybins, bitmap=True, type='color') plot.set_ylabel(r'Zenith 510 [\si{\radian}]') plot.set_xlabel(r'Zenith 507 [\si{\radian}]') plot.save_as_pdf('zenith_' + REC_PATH % order)
def plot_hisparc_kascade_station(self, n, k_n): plot = Plot('loglog') counts, xbins, ybins = histogram2d(n, k_n, bins=self.log_bins, normed=True) counts[counts == -inf] = 0 plot.histogram2d(counts, xbins, ybins, bitmap=True, type='reverse_bw') self.plot_xy(plot) plot.set_xlabel(r'HiSPARC detected density [\si{\per\meter\squared}]') plot.set_ylabel(r'KASCADE predicted density [\si{\per\meter\squared}]') return plot
def plot_zenith_core_distance_small_2d(): with tables.open_file(RESULT_DATA_SMALL, 'r') as data: sim = data.root.coincidences.coincidences.read_where('N == 1') core_distance = sqrt(sim['x'] ** 2 + sim['y'] ** 2) zenith = data.root.cluster_simulations.station_501.reconstructions.col('zenith') plot = Plot('semilogx') core_distance = core_distance[~isnan(zenith)] zenith = zenith[~isnan(zenith)] counts, x, y = histogram2d(core_distance, degrees(zenith), bins=50) plot.histogram2d(counts, x, y, type='color', bitmap=True) plot.set_xlabel(r'Core distance [\si{\meter}]') plot.set_ylabel(r'Reconstructed zenith [\si{\degree}]') plot.save_as_pdf('zenith_distance_e14_5_z0_2d')
def plot_interaction_altitude_size(cq): for p in ['proton', 'iron', 'gamma']: for z in cq.available_parameters('zenith', particle=p): sims = cq.simulations(zenith=z, particle=p) altitudes = sims['first_interaction_altitude'] / 1e3 size = sims['n_electron'] + sims['n_muon'] alt_size_hist = histogram2d( altitudes, size, bins=[linspace(0, 70, 100), logspace(0, 9, 100)]) plot = Plot('semilogy') plot.histogram2d(*alt_size_hist, bitmap=True, type='color') plot.set_xlabel(r'First interaction altitude [m]') plot.set_ylabel(r'Shower size') plot.save_as_pdf('plots/interaction_altitude_v_size_%s_%.1f.pdf' % (p if p is not None else 'all', z))
def round_trip(offsets): """Examine offset distribution using intermediate stations over time Start and end station are the same, but hops via some other stations. The result should ideally be an offset of 0 ns. :param offsets: Dictionary of dictionaries with offset functions. """ aoffsets = get_aligned_offsets(offsets, START, STOP, STEP) timestamps = range(START, STOP, STEP) stations = offsets.keys() for n in [2, 3, 4, 5]: plot = Plot() ts = [] offs = [] for ref in stations: # Intermediate stations for s in combinations(stations, n): if ref in s: continue offs.extend(aoffsets[ref][s[0]] + aoffsets[s[-1]][ref] + sum(aoffsets[s[i]][s[i + 1]] for i in range(n - 1))) ts.extend(timestamps) ts = array(ts) offs = array(offs) ts = ts.compress(~isnan(offs)) offs = offs.compress(~isnan(offs)) counts, xedges, yedges = histogram2d(ts, offs, bins=(timestamps[::4], range(-100, 101, 5))) plot.histogram2d(counts, xedges, yedges, bitmap=True, type='color', colormap='viridis') plot.set_colorbar() plot.set_ylimits(-100, 100) plot.set_title('n = %d' % n) plot.set_ylabel(r'Station offset residual [\si{\ns}]') plot.set_xlabel(r'Timestamp [\si{\s}]') plot.save_as_pdf('plots/round_trip_%d' % n)
def reconstruct_simulations(data): # Station 510 station = cluster.get_station(STATIONS[1]) station_group = '/hisparc/cluster_amsterdam/station_%d' % station.number rec_510 = ReconstructESDEvents(data, station_group, station, overwrite=True, progress=True) rec_510.offsets = offset(station.number) rec_510.reconstruct_directions() rec_510.theta = array(rec_510.theta) rec_510.phi = array(rec_510.phi) # Station 501 for order in itertools.permutations(range(4), 4): cluster = get_cluster() station = cluster.get_station(STATIONS[0]) station_group = '/hisparc/cluster_amsterdam/station_%d' % station.number station._detectors = [station.detectors[id] for id in order] rec_501 = ReconstructESDEvents(data, station_group, station, overwrite=True, progress=True) rec_501.offsets = offset(station.number) rec_501.reconstruct_directions() rec_501.theta = array(rec_501.theta) rec_501.phi = array(rec_501.phi) high_zenith = (rec_501.theta > .2) & (rec_510.theta > .2) plot = Plot() plot.histogram2d(*histogram2d(rec_501.phi.compress(high_zenith), rec_510.phi.compress(high_zenith), bins=linspace(-pi, pi, 100))) plot.save_as_pdf('order_%d%d%d%d' % order)
def plot_histogram(data, timestamps, station_numbers): """Make a 2D histogram plot of the number of events over time per station :param data: list of lists, with the number of events. :param station_numbers: list of station numbers in the data list. """ plot = Plot(width=r'\linewidth', height=r'1.3\linewidth') plot.histogram2d(data.T[::7][1:], timestamps[::7] / 1e9, np.arange(len(station_numbers) + 1), type='reverse_bw', bitmap=True) plot.set_label( gps_to_datetime(timestamps[-1]).date().isoformat(), 'upper left') plot.set_xlimits(min=YEARS_TICKS[0] / 1e9, max=timestamps[-1] / 1e9) plot.set_xticks(YEARS_TICKS / 1e9) plot.set_xtick_labels(YEARS_LABELS) plot.set_yticks(np.arange(0.5, len(station_numbers) + 0.5)) plot.set_ytick_labels(['%d' % s for s in sorted(station_numbers)], style=r'font=\sffamily\tiny') plot.set_axis_options('ytick pos=right') plot.save_as_pdf('eventtime_histogram_network_hour')
def plot_angles(data): """Make azimuth and zenith plots to compare the results""" rec501 = data.get_node('/hisparc/cluster_amsterdam/station_501', 'reconstructions') rec510 = data.get_node('/hisparc/cluster_amsterdam/station_510', 'reconstructions') zen501 = rec501.col('zenith') zen510 = rec510.col('zenith') azi501 = rec501.col('azimuth') azi510 = rec510.col('azimuth') minn501 = rec501.col('min_n') minn510 = rec510.col('min_n') sigmas = [] blas = [] minns = [0, 1, 2, 4, 8, 16, 24] high_zenith = (zen501 > .2) & (zen510 > .2) for minn in minns: filter = (minn501 > minn) & (minn510 > minn) length = len(azi501.compress(high_zenith & filter)) shifts501 = np.random.normal(0, .06, length) shifts510 = np.random.normal(0, .06, length) azicounts, x, y = np.histogram2d( azi501.compress(high_zenith & filter) + shifts501, azi510.compress(high_zenith & filter) + shifts510, bins=np.linspace(-pi, pi, 73)) plota = Plot() plota.histogram2d(azicounts, degrees(x), degrees(y), type='reverse_bw', bitmap=True) # plota.set_title('Reconstructed azimuths for events in coincidence (zenith gt .2 rad)') plota.set_xlabel(r'$\phi_{501}$ [\si{\degree}]') plota.set_ylabel(r'$\phi_{510}$ [\si{\degree}]') plota.set_xticks([-180, -90, 0, 90, 180]) plota.set_yticks([-180, -90, 0, 90, 180]) plota.save_as_pdf('azimuth_501_510_minn%d' % minn) length = len(zen501.compress(filter)) shifts501 = np.random.normal(0, .04, length) shifts510 = np.random.normal(0, .04, length) zencounts, x, y = np.histogram2d(zen501.compress(filter) + shifts501, zen510.compress(filter) + shifts510, bins=np.linspace(0, pi / 3., 41)) plotz = Plot() plotz.histogram2d(zencounts, degrees(x), degrees(y), type='reverse_bw', bitmap=True) # plotz.set_title('Reconstructed zeniths for station events in coincidence') plotz.set_xlabel(r'$\theta_{501}$ [\si{\degree}]') plotz.set_ylabel(r'$\theta_{510}$ [\si{\degree}]') plotz.set_xticks([0, 15, 30, 45, 60]) plotz.set_yticks([0, 15, 30, 45, 60]) plotz.save_as_pdf('zenith_501_510_minn%d' % minn) distances = angle_between(zen501.compress(filter), azi501.compress(filter), zen510.compress(filter), azi510.compress(filter)) counts, bins = np.histogram(distances, bins=linspace(0, pi, 100)) plotd = Plot() plotd.histogram(counts, degrees(bins)) sigma = degrees(percentile(distances[isfinite(distances)], 68)) sigmas.append(sigma) bla = degrees(percentile(distances[isfinite(distances)], 95)) blas.append(bla) plotd.set_label(r'67\%% within \SI{%.1f}{\degree}' % sigma) # plotd.set_title('Distance between reconstructed angles for station events') plotd.set_xlabel(r'Angle between reconstructions [\si{\degree}]') plotd.set_ylabel('Counts') plotd.set_xlimits(min=0, max=90) plotd.set_ylimits(min=0) plotd.save_as_pdf('angle_between_501_510_minn%d' % minn) plot = Plot() plot.plot(minns, sigmas, mark='*') plot.plot(minns, blas) plot.set_ylimits(min=0, max=40) plot.set_xlabel('Minimum number of particles in each station') plot.set_ylabel(r'Angle between reconstructions [\si{\degree}]') plot.save_as_pdf('angle_between_501_510_v_minn')
def plot_angles(data): """Make azimuth and zenith plots to compare the results""" rec = data.root.reconstructions zenhis = rec.col('reconstructed_theta') zenkas = rec.col('reference_theta') azihis = rec.col('reconstructed_phi') azikas = rec.col('reference_phi') min_n = rec.col('min_n134') high_zenith = (zenhis > .2) & (zenkas > .2) for minn in [0, 1, 2, 4]: filter = (min_n > minn) azicounts, x, y = np.histogram2d(azihis.compress(high_zenith & filter), azikas.compress(high_zenith & filter), bins=np.linspace(-pi, pi, 73)) plota = Plot() plota.histogram2d(azicounts, degrees(x), degrees(y), type='reverse_bw', bitmap=True) # plota.set_title('Reconstructed azimuths for events in coincidence (zenith gt .2 rad)') plota.set_xlabel(r'$\phi_\textrm{HiSPARC}$ [\si{\degree}]') plota.set_ylabel(r'$\phi_\textrm{KASCADE}$ [\si{\degree}]') plota.set_xticks([-180, -90, 0, 90, 180]) plota.set_yticks([-180, -90, 0, 90, 180]) plota.save_as_pdf('azimuth_his_kas_minn%d' % minn) zencounts, x, y = np.histogram2d(zenhis.compress(filter), zenkas.compress(filter), bins=np.linspace(0, pi / 3., 41)) plotz = Plot() plotz.histogram2d(zencounts, degrees(x), degrees(y), type='reverse_bw', bitmap=True) # plotz.set_title('Reconstructed zeniths for station events in coincidence') plotz.set_xlabel(r'$\theta_\textrm{HiSPARC}$ [\si{\degree}]') plotz.set_ylabel(r'$\theta_\textrm{KASCADE}$ [\si{\degree}]') plotz.set_xticks([0, 15, 30, 45, 60]) plotz.set_yticks([0, 15, 30, 45, 60]) plotz.save_as_pdf('zenith_his_kas_minn%d' % minn) distances = angle_between(zenhis.compress(filter), azihis.compress(filter), zenkas.compress(filter), azikas.compress(filter)) counts, bins = np.histogram(distances, bins=linspace(0, pi, 100)) plotd = Plot() plotd.histogram(counts, degrees(bins)) sigma = degrees(scoreatpercentile(distances, 67)) plotd.set_title(r'$N_\textrm{MIP} \geq %d$' % minn) plotd.set_label(r'67\%% within \SI{%.1f}{\degree}' % sigma) # plotd.set_title('Distance between reconstructed angles for station events') plotd.set_xlabel('Angle between reconstructions [\si{\degree}]') plotd.set_ylabel('Counts') plotd.set_xlimits(min=0, max=90) plotd.set_ylimits(min=0) plotd.save_as_pdf('angle_between_his_kas_minn%d' % minn)
CLUSTER = HiSPARCStations(SPA_STAT) DATA_PATH = '/Users/arne/Datastore/station_offsets/' def get_station_dt(data, station): table = data.get_node('/s%d' % station) return table if __name__ == '__main__': t_start = datetime_to_gps(datetime(2010, 1, 1)) t_end = datetime_to_gps(datetime(2015, 4, 1)) for i, station in enumerate(STATIONS, 1): with tables.open_file(DATA_PATH + 'dt_ref501_%d.h5' % station, 'r') as data: distance, _, _ = CLUSTER.calc_rphiz_for_stations(i, 0) max_dt = max(distance / .3, 100) * 1.5 table = get_station_dt(data, station) graph = Plot() counts, x, y = histogram2d(table.col('timestamp'), table.col('delta'), bins=(arange(t_start, t_end, XWEEK), linspace(-max_dt, max_dt, 150))) graph.histogram2d(counts, x, y, bitmap=True, type='color') graph.set_ylabel('$\Delta t$ [ns]') graph.set_xlabel('Timestamp [s]') graph.set_xlimits(t_start, t_end) graph.set_ylimits(-max_dt, max_dt) graph.save_as_pdf('plots/2d_distribution/dt_%d_xweek' % station)
def analyse_reconstructions(data): cq = CoincidenceQuery(data) c_ids = data.root.coincidences.coincidences.read_where('s501', field='id') c_recs = cq.reconstructions.read_coordinates(c_ids) s_recs = data.root.hisparc.cluster_amsterdam.station_501.reconstructions zenc = c_recs['zenith'] azic = c_recs['azimuth'] zens = s_recs.col('zenith') azis = s_recs.col('azimuth') high_zenith = (zenc > .2) & (zens > .2) for minn in [1, 2, 4, 8, 16]: filter = (s_recs.col('min_n') > minn) length = len(azis.compress(high_zenith & filter)) shifts501 = np.random.normal(0, .06, length) azicounts, x, y = np.histogram2d(azis.compress(high_zenith & filter) + shifts501, azic.compress(high_zenith & filter), bins=np.linspace(-np.pi, np.pi, 73)) plota = Plot() plota.histogram2d(azicounts, np.degrees(x), np.degrees(y), type='reverse_bw', bitmap=True) # plota.set_title('Reconstructed azimuths for events in coincidence (zenith gt .2 rad)') plota.set_xlabel(r'$\phi_{501}$ [\si{\degree}]') plota.set_ylabel(r'$\phi_{Science Park}$ [\si{\degree}]') plota.set_xticks([-180, -90, 0, 90, 180]) plota.set_yticks([-180, -90, 0, 90, 180]) plota.save_as_pdf('azimuth_501_spa_minn%d' % minn) length = sum(filter) shifts501 = np.random.normal(0, .04, length) zencounts, x, y = np.histogram2d(zens.compress(filter) + shifts501, zenc.compress(filter), bins=np.linspace(0, np.pi / 3., 41)) plotz = Plot() plotz.histogram2d(zencounts, np.degrees(x), np.degrees(y), type='reverse_bw', bitmap=True) # plotz.set_title('Reconstructed zeniths for station events in coincidence') plotz.set_xlabel(r'$\theta_{501}$ [\si{\degree}]') plotz.set_ylabel(r'$\theta_{Science Park}$ [\si{\degree}]') plotz.set_xticks([0, 15, 30, 45, 60]) plotz.set_yticks([0, 15, 30, 45, 60]) plotz.save_as_pdf('zenith_501_spa_minn%d' % minn) distances = angle_between(zens.compress(filter), azis.compress(filter), zenc.compress(filter), azic.compress(filter)) counts, bins = np.histogram(distances, bins=np.linspace(0, np.pi, 91)) plotd = Plot() plotd.histogram(counts, np.degrees(bins)) sigma = np.degrees(np.percentile(distances[np.isfinite(distances)], 67)) plotd.set_label(r'67\%% within \SI{%.1f}{\degree}' % sigma) # plotd.set_title('Distance between reconstructed angles for station and cluster') plotd.set_xlabel('Angle between reconstructions [\si{\degree}]') plotd.set_ylabel('Counts') plotd.set_xlimits(min=0, max=90) plotd.set_ylimits(min=0) plotd.save_as_pdf('angle_between_501_spa_minn%d' % minn)
def combine_delta_data(): delta_data = genfromtxt('data/time_delta.tsv', delimiter='\t', dtype=None, names=['ext_timestamp', 'time_delta']) delta_data = {ets: td for ets, td in delta_data} tm = [] ts = [] td = [] te = [] with tables.open_file('data/data.h5', 'r') as data: for row in data.root.s99.events: ets = row['ext_timestamp'] try: dt = delta_data[ets] except KeyError: continue tm.append(row['t1']) ts.append(row['t3']) td.append(dt) te.append(ets) tm = array(tm) ts = array(ts) td = array(td) te = array(te) filter = (tm >= 0) & (ts >= 0) tm = tm.compress(filter) ts = ts.compress(filter) td = td.compress(filter) te = te.compress(filter) bins = arange(-10.25, 10.26, .5) mplot = MultiPlot(3, 2, width=r'.4\linewidth', height=r'.3\linewidth') mplot.show_xticklabels_for_all([(2, 0), (2, 1)]) mplot.show_yticklabels_for_all([(0, 0), (1, 1), (2, 0)]) mplot.set_xlimits_for_all(min=-11, max=11) mplot.set_ylimits_for_all(min=0, max=1500) mplot.set_ylabel('Counts') mplot.set_xlabel(r'Time difference [\si{\nano\second}]') plot = mplot.get_subplot_at(0, 0) counts, bins = histogram(tm - ts, bins=bins) popt = fit_timing_offset(counts / 3., bins) plot.set_label(r'$t_{M} - t_{S}$, $%.1f\pm%.1f$\si{\nano\second}, scaled' % (popt[1], popt[2])) plot.histogram(counts / 3., bins) plot.plot(bins, gauss(bins, *popt), mark=None, linestyle='gray') plot = mplot.get_subplot_at(1, 0) plot.set_label(r'$t_{\delta}$') plot.histogram(*histogram(td, bins=bins)) plot = mplot.get_subplot_at(2, 0) counts, bins = histogram(tm - (ts + td), bins=bins) popt = fit_timing_offset(counts, bins) plot.set_label( r'$t_{M} - (t_{S} + t_{\delta})$, $%.1f\pm%.1f$\si{\nano\second}' % (popt[1], popt[2])) plot.histogram(counts, bins) plot.plot(bins, gauss(bins, *popt), mark=None, linestyle='gray') plot = mplot.get_subplot_at(0, 1) plot.set_label(r'$t_{\delta}$ where $t_{M} - t_{S} == -5$') plot.draw_vertical_line(-5, linestyle='gray') plot.histogram(*histogram(td.compress(tm - ts == -5), bins=bins)) plot = mplot.get_subplot_at(1, 1) plot.set_label(r'$t_{\delta}$ where $t_{M} - t_{S} == -2.5$') plot.draw_vertical_line(-2.5, linestyle='gray') plot.histogram(*histogram(td.compress(tm - ts == -2.5), bins=bins)) plot = mplot.get_subplot_at(2, 1) plot.set_label(r'$t_{\delta}$ where $t_{M} - t_{S} == 0$') plot.draw_vertical_line(0, linestyle='gray') plot.histogram(*histogram(td.compress(tm - ts == 0), bins=bins)) mplot.save_as_pdf('dt_time_delta') plot = Plot() counts, xbins, ybins = histogram2d(tm - ts, td, bins=bins) plot.histogram2d(counts, xbins, ybins, bitmap=True, type='reverse_bw') plot.set_xlabel(r'$t_{M} - t_{S}$ [\si{\nano\second}]') plot.set_ylabel(r'$t_{\delta}$ [\si{\nano\second}]') plot.save_as_pdf('dt_vs_time_delta')