Ejemplo n.º 1
0
    def get_template(self, params, return_stages=False):
        '''
        Runs entire template-making chain, using parameters found in
        'params' dict. If 'return_stages' is set to True, returns
        output from each stage as a simple tuple.
        '''

        logging.info("STAGE 1: Getting Atm Flux maps...")
        with Timer() as t:
            flux_maps = get_flux_maps(self.flux_service, self.ebins,
                                      self.czbins, **params)
        profile.debug("==> elapsed time for flux stage: %s sec" % t.secs)

        logging.info("STAGE 2: Getting osc prob maps...")
        with Timer() as t:
            osc_flux_maps = get_osc_flux(flux_maps,
                                         self.osc_service,
                                         oversample_e=self.oversample_e,
                                         oversample_cz=self.oversample_cz,
                                         **params)
        profile.debug("==> elapsed time for oscillations stage: %s sec" %
                      t.secs)

        logging.info("STAGE 3: Getting event rate true maps...")
        with Timer() as t:
            event_rate_maps = get_event_rates(osc_flux_maps, self.aeff_service,
                                              **params)
        profile.debug("==> elapsed time for aeff stage: %s sec" % t.secs)

        logging.info("STAGE 4: Getting event rate reco maps...")
        with Timer() as t:
            event_rate_reco_maps = get_reco_maps(event_rate_maps,
                                                 self.reco_service, **params)
        profile.debug("==> elapsed time for reco stage: %s sec" % t.secs)

        logging.info("STAGE 5: Getting pid maps...")
        with Timer(verbose=False) as t:
            final_event_rate = get_pid_maps(event_rate_reco_maps,
                                            self.pid_service)
        profile.debug("==> elapsed time for pid stage: %s sec" % t.secs)

        if not return_stages:
            return final_event_rate

        # Otherwise, return all stages as a simple tuple
        return (flux_maps, osc_flux_maps, event_rate_maps,
                event_rate_reco_maps, final_event_rate)
Ejemplo n.º 2
0
    def get_template(self, params, return_stages=False):
        '''
        Runs entire template-making chain, using parameters found in
        'params' dict. If 'return_stages' is set to True, returns
        output from each stage as a simple tuple.
        '''

        logging.info("STAGE 1: Getting Atm Flux maps...")
        with Timer() as t:
            flux_maps = get_flux_maps(self.flux_service, self.ebins,
                                      self.czbins, **params)
        profile.debug("==> elapsed time for flux stage: %s sec"%t.secs)

        logging.info("STAGE 2: Getting osc prob maps...")
        with Timer() as t:
            osc_flux_maps = get_osc_flux(flux_maps, self.osc_service,
                                         oversample_e=self.oversample_e,
                                         oversample_cz=self.oversample_cz,
                                         **params)
        profile.debug("==> elapsed time for oscillations stage: %s sec"%t.secs)

        logging.info("STAGE 3: Getting event rate true maps...")
        with Timer() as t:
            event_rate_maps = get_event_rates(osc_flux_maps,
                                              self.aeff_service, **params)
        profile.debug("==> elapsed time for aeff stage: %s sec"%t.secs)

        logging.info("STAGE 4: Getting event rate reco maps...")
        with Timer() as t:
            event_rate_reco_maps = get_reco_maps(event_rate_maps,
                                                 self.reco_service,
                                                 **params)
        profile.debug("==> elapsed time for reco stage: %s sec"%t.secs)

        logging.info("STAGE 5: Getting pid maps...")
        with Timer(verbose=False) as t:
            final_event_rate = get_pid_maps(event_rate_reco_maps,
                                            self.pid_service)
        profile.debug("==> elapsed time for pid stage: %s sec"%t.secs)

        if not return_stages:
            return final_event_rate

        # Otherwise, return all stages as a simple tuple
        return (flux_maps, osc_flux_maps, event_rate_maps,
                event_rate_reco_maps, final_event_rate)
Ejemplo n.º 3
0
    def get_osc_prob_maps(self, **kwargs):
        """
        Returns an oscillation probability map dictionary calculated
        at the values of the input parameters:
          deltam21,deltam31,theta12,theta13,theta23,deltacp
        for flavor_from to flavor_to, with the binning of ebins,czbins.
        The dictionary is formatted as:
          'nue_maps': {'nue':map,'numu':map,'nutau':map},
          'numu_maps': {...}
          'nue_bar_maps': {...}
          'numu_bar_maps': {...}
        NOTES:
          * expects all angles in [rad]
          * this method doesn't calculate the oscillation probabilities
            itself, but calls get_osc_probLT_dict internally, to get a
            high resolution map of the oscillation probs,
        """

        # Get the finely binned maps as implemented in the derived class
        logging.info("Retrieving finely binned maps")
        with Timer(verbose=False) as t:
            fine_maps = self.get_osc_probLT_dict(**kwargs)
        print "       ==> elapsed time to get all fine maps: %s sec" % t.secs

        logging.info("Smoothing fine maps...")
        smoothed_maps = {}
        smoothed_maps["ebins"] = self.ebins
        smoothed_maps["czbins"] = self.czbins

        with Timer(verbose=False) as t:
            for from_nu, tomap_dict in fine_maps.items():
                if "vals" in from_nu:
                    continue
                new_tomaps = {}
                for to_nu, pvals in tomap_dict.items():
                    logging.debug("Getting smoothed map %s/%s" % (from_nu, to_nu))

                    new_tomaps[to_nu] = get_smoothed_map(
                        pvals, fine_maps["evals"], fine_maps["czvals"], self.ebins, self.czbins
                    )

                smoothed_maps[from_nu] = new_tomaps

        profile.debug("       ==> elapsed time to smooth maps: %s sec" % t.secs)

        return smoothed_maps
Ejemplo n.º 4
0
    def get_osc_prob_maps(self, **kwargs):
        """
        Returns an oscillation probability map dictionary calculated
        at the values of the input parameters:
          deltam21,deltam31,theta12,theta13,theta23,deltacp
        for flavor_from to flavor_to, with the binning of ebins,czbins.
        The dictionary is formatted as:
          'nue_maps': {'nue':map,'numu':map,'nutau':map},
          'numu_maps': {...}
          'nue_bar_maps': {...}
          'numu_bar_maps': {...}
        NOTES:
          * expects all angles in [rad]
          * this method doesn't calculate the oscillation probabilities
            itself, but calls get_osc_probLT_dict internally, to get a
            high resolution map of the oscillation probs,
        """

        #Get the finely binned maps as implemented in the derived class
        logging.info('Retrieving finely binned maps')
        with Timer(verbose=False) as t:
            fine_maps = self.get_osc_probLT_dict(**kwargs)
        print "       ==> elapsed time to get all fine maps: %s sec"%t.secs

        logging.info("Smoothing fine maps...")
        smoothed_maps = {}
        smoothed_maps['ebins'] = self.ebins
        smoothed_maps['czbins'] = self.czbins

        with Timer(verbose=False) as t:
            for from_nu, tomap_dict in fine_maps.items():
                if 'vals' in from_nu: continue
                new_tomaps = {}
                for to_nu, pvals in tomap_dict.items():
                    logging.debug("Getting smoothed map %s/%s"%(from_nu,to_nu))

                    new_tomaps[to_nu] = get_smoothed_map(
                        pvals,fine_maps['evals'],fine_maps['czvals'],
                        self.ebins, self.czbins)

                smoothed_maps[from_nu] = new_tomaps

        profile.debug("       ==> elapsed time to smooth maps: %s sec"%t.secs)

        return smoothed_maps
Ejemplo n.º 5
0
    def get_template_no_osc(self, params):
        '''
        Runs template making chain, but without oscillations
        '''

        logging.info("STAGE 1: Getting Atm Flux maps...")
        with Timer() as t:
            flux_maps = get_flux_maps(self.flux_service, self.ebins,
                                      self.czbins, **params)
        profile.debug("==> elapsed time for flux stage: %s sec" % t.secs)

        # Skipping oscillation stage...
        logging.info("  >>Skipping Stage 2 in no oscillations case...")
        flavours = ['nutau', 'nutau_bar']
        # Create the empty nutau maps:
        test_map = flux_maps['nue']
        for flav in flavours:
            flux_maps[flav] = {
                'map': np.zeros_like(test_map['map']),
                'ebins': np.zeros_like(test_map['ebins']),
                'czbins': np.zeros_like(test_map['czbins'])
            }

        logging.info("STAGE 3: Getting event rate true maps...")
        with Timer() as t:
            event_rate_maps = get_event_rates(flux_maps, self.aeff_service,
                                              **params)
        profile.debug("==> elapsed time for aeff stage: %s sec" % t.secs)

        logging.info("STAGE 4: Getting event rate reco maps...")
        with Timer() as t:
            event_rate_reco_maps = get_reco_maps(event_rate_maps,
                                                 self.reco_service, **params)
        profile.debug("==> elapsed time for reco stage: %s sec" % t.secs)

        logging.info("STAGE 5: Getting pid maps...")
        with Timer(verbose=False) as t:
            final_event_rate = get_pid_maps(event_rate_reco_maps,
                                            self.pid_service)
        profile.debug("==> elapsed time for pid stage: %s sec" % t.secs)

        return final_event_rate
Ejemplo n.º 6
0
    def get_template_no_osc(self, params):
        '''
        Runs template making chain, but without oscillations
        '''

        logging.info("STAGE 1: Getting Atm Flux maps...")
        with Timer() as t:
            flux_maps = get_flux_maps(self.flux_service, self.ebins,
                                      self.czbins, **params)
        profile.debug("==> elapsed time for flux stage: %s sec"%t.secs)

        # Skipping oscillation stage...
        logging.info("  >>Skipping Stage 2 in no oscillations case...")
        flavours = ['nutau', 'nutau_bar']
        # Create the empty nutau maps:
        test_map = flux_maps['nue']
        for flav in flavours:
            flux_maps[flav] = {'map': np.zeros_like(test_map['map']),
                               'ebins': np.zeros_like(test_map['ebins']),
                               'czbins': np.zeros_like(test_map['czbins'])}

        logging.info("STAGE 3: Getting event rate true maps...")
        with Timer() as t:
            event_rate_maps = get_event_rates(flux_maps, self.aeff_service,
                                              **params)
        profile.debug("==> elapsed time for aeff stage: %s sec"%t.secs)

        logging.info("STAGE 4: Getting event rate reco maps...")
        with Timer() as t:
            event_rate_reco_maps = get_reco_maps(event_rate_maps,
                                                 self.reco_service, **params)
        profile.debug("==> elapsed time for reco stage: %s sec"%t.secs)

        logging.info("STAGE 5: Getting pid maps...")
        with Timer(verbose=False) as t:
            final_event_rate = get_pid_maps(event_rate_reco_maps,
                                            self.pid_service)
        profile.debug("==> elapsed time for pid stage: %s sec"%t.secs)

        return final_event_rate