示例#1
0
    def fill_osc_prob(
        self,
        osc_prob_dict,
        ecen,
        czcen,
        theta12=None,
        theta13=None,
        theta23=None,
        deltam21=None,
        deltam31=None,
        deltacp=None,
        energy_scale=None,
        **kwargs
    ):
        """
        Loops over ecen,czcen and fills the osc_prob_dict maps, with
        probabilities calculated according to NuCraft
        """

        # Setup NuCraft for the given oscillation parameters
        # TODO: compatible with new NuCraft version?
        mass_splitting = (1.0, deltam21, deltam31)
        mixing_angles = [
            (1, 2, np.rad2deg(theta12)),
            (1, 3, np.rad2deg(theta13), np.rad2deg(deltacp)),
            (2, 3, np.rad2deg(theta23)),
        ]
        # NOTE: (TCA - 25 March 2015) We are not using
        # self.earth_model, because the earth models are configured
        # according to prob3 specifications, but NuCraft needs a
        # completely different type of earth model, because it is
        # treated differently. For now, don't change the earth model
        # version in default NuCraft until we figure out how to
        # standardize it.
        engine = NuCraft(mass_splitting, mixing_angles)
        # earthModel = self.earth_model)
        engine.detectorDepth = self.detector_depth

        if self.prop_height != "sample":
            # Fix neutrino production height and detector depth for
            # simulating reactor experiments.
            # In this case, there should be only one zenith angle corresponding
            # to the baseline B. It can be calculated according to:
            #   cos(zen) = ( (r_E - detectorDepth)**2 + B**2 (r_E + atmHeight)**2 ) \
            #               / ( 2 * (r_E + detectorDepth) * B)
            # with r_E = 6371. km
            engine.atmHeight = self.prop_height

        # Make input arrays in correct format (nucraft input type 1)
        zs, es = np.meshgrid(czcen, ecen)
        zs, es = zs.flatten(), es.flatten()
        # we need flat lists with probabilities for further processing
        shape = int(len(ecen) * len(czcen))

        # Apply Energy scaling factor:
        if energy_scale is not None:
            es *= energy_scale

        for prim in osc_prob_dict:

            if "bins" in prim:
                continue

            # Convert the particle into a list of IceCube particle IDs
            ps = np.ones_like(es) * get_PDG_ID(prim.rsplit("_", 1)[0])

            # run it
            logging.debug(
                "Calculating oscillation probabilities for %s at %u points..." % (prim.rsplit("_", 1)[0], len(ps))
            )
            probs = engine.CalcWeights((ps, es, np.arccos(zs)), atmMode=self.height_mode, numPrec=self.num_prec)
            logging.debug("...done")

            # Bring into correct shape
            probs = np.array([x.reshape(shape).T for x in np.array(probs).T])

            # Fill probabilities into dict
            for i, sec in enumerate(["nue", "numu", "nutau"]):
                sec_key = sec + "_bar" if "bar" in prim else sec
                osc_prob_dict[prim][sec_key] = probs[i]

        evals, czvals = np.meshgrid(ecen, czcen, indexing="ij")
        return evals.flatten(), czvals.flatten()
示例#2
0
    def fill_osc_prob(self, osc_prob_dict, ecen, czcen,
                      theta12=None, theta13=None, theta23=None,
                      deltam21=None, deltam31=None, deltacp=None,
                      energy_scale=None,**kwargs):
        """
        Loops over ecen,czcen and fills the osc_prob_dict maps, with
        probabilities calculated according to NuCraft
        """

        #Setup NuCraft for the given oscillation parameters
        #TODO: compatible with new NuCraft version?
        mass_splitting = (1., deltam21, deltam31)
        mixing_angles = [(1,2,np.rad2deg(theta12)),
                         (1,3,np.rad2deg(theta13),np.rad2deg(deltacp)),
                         (2,3,np.rad2deg(theta23))]
        engine = NuCraft(mass_splitting, mixing_angles,
                         earthModel = self.earth_model)
        engine.detectorDepth = self.detector_depth

        if self.prop_height is not None:
            # Fix neutrino production height and detector depth for
            # simulating reactor experiments.
            # In this case, there should be only one zenith angle corresponding
            # to the baseline B. It can be calculated according to:
            #   cos(zen) = ( (r_E - detectorDepth)**2 + B**2 (r_E + atmHeight)**2 ) \
            #               / ( 2 * (r_E + detectorDepth) * B)
            # with r_E = 6371. km
            engine.atmHeight = self.prop_height

        #Make input arrays in correct format
        es, zs = np.meshgrid(ecen, czcen)
        shape = es.shape
        es, zs = es.flatten(), zs.flatten()

        # Apply Energy scaling factor:
        es *= energy_scale

        for prim in osc_prob_dict:

            if 'bins' in prim: continue

            #Convert the particle into a list of IceCube particle IDs
            ps = np.ones_like(es)*get_PDG_ID(prim.rsplit('_', 1)[0])

            # run it
            logging.debug("Calculating oscillation probabilites for %s at %u points..."
                            %(prim.rsplit('_', 1)[0], len(ps)))
            probs = engine.CalcWeights((ps, es, np.arccos(zs)),
                                       atmMode=self.height_mode,
                                       numPrec=self.num_prec)
            logging.debug("...done")

            #Bring into correct shape
            probs = np.array([ x.reshape(shape).T for x in np.array(probs).T ])

            #Fill probabilities into dict
            for i, sec in enumerate(['nue', 'numu', 'nutau']):
                sec_key = sec+'_bar' if 'bar' in prim else sec
                osc_prob_dict[prim][sec_key] = probs[i]

        return
示例#3
0
    def fill_osc_prob(self, osc_prob_dict, ecen, czcen,
                      theta12=None, theta13=None, theta23=None,
                      deltam21=None, deltam31=None, deltacp=None,
                      energy_scale=None,**kwargs):
        """
        Loops over ecen,czcen and fills the osc_prob_dict maps, with
        probabilities calculated according to NuCraft
        """

        #Setup NuCraft for the given oscillation parameters
        #TODO: compatible with new NuCraft version?
        mass_splitting = (1., deltam21, deltam31)
        mixing_angles = [(1,2,np.rad2deg(theta12)),
                         (1,3,np.rad2deg(theta13),np.rad2deg(deltacp)),
                         (2,3,np.rad2deg(theta23))]
        # NOTE: (TCA - 25 March 2015) We are not using
        # self.earth_model, because the earth models are configured
        # according to prob3 specifications, but NuCraft needs a
        # completely different type of earth model, because it is
        # treated differently. For now, don't change the earth model
        # version in default NuCraft until we figure out how to
        # standardize it.
        engine = NuCraft(mass_splitting, mixing_angles)
                         #earthModel = self.earth_model)
        engine.detectorDepth = self.detector_depth

        if self.prop_height != 'sample':
            # Fix neutrino production height and detector depth for
            # simulating reactor experiments.
            # In this case, there should be only one zenith angle corresponding
            # to the baseline B. It can be calculated according to:
            #   cos(zen) = ( (r_E - detectorDepth)**2 + B**2 (r_E + atmHeight)**2 ) \
            #               / ( 2 * (r_E + detectorDepth) * B)
            # with r_E = 6371. km
            engine.atmHeight = self.prop_height

        # Make input arrays in correct format (nucraft input type 1)
	zs, es = np.meshgrid(czcen, ecen)
        zs, es = zs.flatten(), es.flatten()
	# we need flat lists with probabilities for further processing
	shape = int(len(ecen)*len(czcen))

        # Apply Energy scaling factor:
	if energy_scale is not None:
	    es *= energy_scale

        for prim in osc_prob_dict:

            if 'bins' in prim: continue

            #Convert the particle into a list of IceCube particle IDs
            ps = np.ones_like(es)*get_PDG_ID(prim.rsplit('_', 1)[0])

            # run it
            logging.debug("Calculating oscillation probabilities for %s at %u points..."
                            %(prim.rsplit('_', 1)[0], len(ps)))
            probs = engine.CalcWeights((ps, es, np.arccos(zs)),
                                       atmMode=self.height_mode,
                                       numPrec=self.num_prec)
            logging.debug("...done")

            #Bring into correct shape
            probs = np.array([ x.reshape(shape).T for x in np.array(probs).T ])

            #Fill probabilities into dict
            for i, sec in enumerate(['nue', 'numu', 'nutau']):
                sec_key = sec+'_bar' if 'bar' in prim else sec
                osc_prob_dict[prim][sec_key] = probs[i]

        evals,czvals = np.meshgrid(ecen,czcen,indexing='ij')
        return evals.flatten(),czvals.flatten()