示例#1
0
class StationPairEnergySensitivityQuarter(EnergySensitivity):
    """Subclass to only consider one quarter

    This only works if the cluster is (almost) symmetric.
    So either two 2-detector stations, or two 4-detector stations.

    """
    def __init__(self, pair):
        super(StationPairEnergySensitivityQuarter, self).__init__()

        # Detectors
        self.cluster = HiSPARCStations(pair, force_stale=True)

        # Conditions
        self.min_stations = 2

        # Shower parameters
        self.max_radius = 1e3
        self.bin_size = 10.
        #         self.max_radius = bin_size * np.sqrt(self.grid_points)

        # Throw showers in one grid around center mass of the stations
        #         xc, yc, _ = self.cluster.calc_center_of_mass_coordinates()
        #         self.xx = np.arange(-self.max_radius + xc, self.max_radius + xc, self.bin_size)
        #         self.yy = np.arange(-self.max_radius + yc, self.max_radius + yc, self.bin_size)

        # Rotate cluster to make stations aligned along x for easy symmetry
        _, phi, _ = self.cluster.calc_rphiz_for_stations(0, 1)
        self.cluster.alpha = -phi

        # Throw showers in one quarter from center mass of the stations
        xc, yc, _ = self.cluster.calc_center_of_mass_coordinates()
        self.xx = np.arange(xc + self.bin_size / 2., self.max_radius + xc,
                            self.bin_size)
        self.yy = np.arange(yc + self.bin_size / 2., self.max_radius + yc,
                            self.bin_size)

    def get_area_energy(self, energy):
        """Calculate area

        Multiply area by four, because only one quadrant was considered.

        """
        area = super(StationPairEnergySensitivity,
                     self).get_area_energy(energy)
        area *= 4.

        return area
示例#2
0
文件: plot_dt.py 项目: 153957/topaz
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)