Example #1
0
def create_nuSQuIDS():
    global numuSQUIDSDict, numubarSQUIDSDict, nueSQUIDSDict, nuebarSQUIDSDict
    #    print 'MT: ',etau
    #      print 'TT: ',tautau
    #nuSQBar = nsq.nuSQUIDSAtm(-1,1,400,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.antineutrino,True,False)
    nuSQ = nsq.nuSQUIDSAtm(-1, 1, 100, mutau, tautau, 0.0, 0.0, beg_ene,
                           end_ene, 200, 3, nsq.NeutrinoType.neutrino, True,
                           False)
    #print nuSQ.GetNumCos(),nuSQ.GetNumE()
    #Muon neutrinos
    SetNSQParams(nuSQ, 1)
    #SetNSQParams(this_zen,nuSQBar,1)
    numu_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/FourD/Atm-NuMu-Squid-%.4fMT_%.3fTT_%.3fTH_%.3fDM.hdf5" % (
        mutau, tautau, th23, dm2)
    #   numubar_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/Atm-NuMuBar-Squid-%.4fET%.3fEM.hdf5" % (mutau,tautau)
    nue_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/FourD/Atm-NuE-Squid-%.4fMT_%.3fTT_%.3fTH_%.3fDM.hdf5" % (
        mutau, tautau, th23, dm2)
    #  nuebar_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/Atm-NuEBar-Squid-%.4fET%.3fEM.hdf5" % (mutau,tautau)
    #  groupname = "/NuMu%.4fET%.3fEM" % (mutau, tautau)
    #nuSQ.WriteStateHDF5(filename,groupname,True,"/")
    #Current output
    nuSQ.WriteStateHDF5(numu_filename)
    #nuSQBar.WriteStateHDF5(numubar_filename)
    #Electron neutrinos
    SetNSQParams(nuSQ, 0)
    #SetNSQParams(this_zen,nuSQBar,0)
    #Current output
    nuSQ.WriteStateHDF5(nue_filename)
Example #2
0
 def initialize_nuSQuIDS(self):
     czens, energies, initial_flux = self._make_initial_data()
     interactions = True
     self.nsq_atm = nsq.nuSQUIDSAtm(czens, energies*pc.GeV, 3, nsq.NeutrinoType.both, interactions)
     self.nsq_atm.Set_initial_state(initial_flux, nsq.Basis.flavor)
     
     self.nsq_atm.Set_rel_error(1.0e-15)
     self.nsq_atm.Set_abs_error(1.0e-15)
     self.nsq_atm.EvolveState()
Example #3
0
def create_nuSQuIDS():

  nuSQ = nsq.nuSQUIDSAtm(-1,1,100,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.both,True,True)
####  nuSQBar = nsq.nuSQUIDSAtm(-1,1,100,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.antineutrino,True,True)

#Muon neutrinos
  SetNSQParams(nuSQ,1)
  #SetNSQParams(nuSQBar,1)
  for ene in np.linspace(1,1011,1012):
    print 'Neutrino',ene,nuSQ.EvalFlavor(1,-1.0,ene*nuSQ.units.GeV,0)
  #  print 'Anti-Neutrino',ene,nuSQBar.EvalFlavor(1,-1.0,ene*nuSQBar.units.GeV,0)

  nuSQ.WriteStateHDF5("Test.hd5")
Example #4
0
def make_squids():
  file_name = file 
  nuSQ = nsq.nuSQUIDSAtm(file_name)

#Neutrinos
  print "NuToTau",ene,zen,nuSQ.EvalFlavor(2,zen,ene*nuSQ.units.GeV,0)
  print "NuToMu",ene,zen,nuSQ.EvalFlavor(1,zen,ene*nuSQ.units.GeV,0)
  print "NuToE",ene,zen,nuSQ.EvalFlavor(0,zen,ene*nuSQ.units.GeV,0)

#Anti-Neutrinos
  print "NuBartoTau",ene,zen,nuSQ.EvalFlavor(2,zen,ene*nuSQ.units.GeV,1)
  print "NuBarToMu",ene,zen,nuSQ.EvalFlavor(1,zen,ene*nuSQ.units.GeV,1)
  print "NuBarToE",ene,zen,nuSQ.EvalFlavor(0,zen,ene*nuSQ.units.GeV,1)
def create_nuSQuIDS():

    nuSQ = nsq.nuSQUIDSAtm(-1, 1, 100, mutau, tautau, 0.0, 0.0, beg_ene,
                           end_ene, 200, 3, nsq.NeutrinoType.both, True, True)
    ####  nuSQBar = nsq.nuSQUIDSAtm(-1,1,100,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.antineutrino,True,True)

    #Muon neutrinos
    SetNSQParams(nuSQ, 1)
    #SetNSQParams(nuSQBar,1)
    for ene in np.linspace(1, 1011, 1012):
        print 'Neutrino', ene, nuSQ.EvalFlavor(1, -1.0, ene * nuSQ.units.GeV,
                                               0)
    #  print 'Anti-Neutrino',ene,nuSQBar.EvalFlavor(1,-1.0,ene*nuSQBar.units.GeV,0)

    nuSQ.WriteStateHDF5("Test.hd5")
def make_squids():
    file_name = file
    nuSQ = nsq.nuSQUIDSAtm(file_name)

    #Neutrinos
    print "NuToTau", ene, zen, nuSQ.EvalFlavor(2, zen, ene * nuSQ.units.GeV, 0)
    print "NuToMu", ene, zen, nuSQ.EvalFlavor(1, zen, ene * nuSQ.units.GeV, 0)
    print "NuToE", ene, zen, nuSQ.EvalFlavor(0, zen, ene * nuSQ.units.GeV, 0)

    #Anti-Neutrinos
    print "NuBartoTau", ene, zen, nuSQ.EvalFlavor(2, zen, ene * nuSQ.units.GeV,
                                                  1)
    print "NuBarToMu", ene, zen, nuSQ.EvalFlavor(1, zen, ene * nuSQ.units.GeV,
                                                 1)
    print "NuBarToE", ene, zen, nuSQ.EvalFlavor(0, zen, ene * nuSQ.units.GeV,
                                                1)
Example #7
0
def create_nuSQuIDS():
  global numuSQUIDSDict, numubarSQUIDSDict, nueSQUIDSDict, nuebarSQUIDSDict
#    print 'MT: ',etau 
#      print 'TT: ',tautau 
  #nuSQBar = nsq.nuSQUIDSAtm(-1,1,400,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.antineutrino,True,False)
  nuSQ = nsq.nuSQUIDSAtm(-1,1,100,mutau,tautau,0.0,0.0,beg_ene,end_ene,200,3,nsq.NeutrinoType.neutrino,True,False)
  #print nuSQ.GetNumCos(),nuSQ.GetNumE()
#Muon neutrinos
  SetNSQParams(nuSQ,1)
  #SetNSQParams(this_zen,nuSQBar,1)
  numu_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/FourD/Atm-NuMu-Squid-%.4fMT_%.3fTT_%.3fTH_%.3fDM.hdf5" % (mutau,tautau,th23,dm2)
#   numubar_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/Atm-NuMuBar-Squid-%.4fET%.3fEM.hdf5" % (mutau,tautau)
  nue_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/FourD/Atm-NuE-Squid-%.4fMT_%.3fTT_%.3fTH_%.3fDM.hdf5" % (mutau,tautau,th23,dm2)
#  nuebar_filename = "/data/user/mamday/newSQuIDS/nuSQuIDS/resources/python/bindings/HD5Files/Atm-NuEBar-Squid-%.4fET%.3fEM.hdf5" % (mutau,tautau)
#  groupname = "/NuMu%.4fET%.3fEM" % (mutau, tautau)
  #nuSQ.WriteStateHDF5(filename,groupname,True,"/")
#Current output
  nuSQ.WriteStateHDF5(numu_filename)
  #nuSQBar.WriteStateHDF5(numubar_filename)
#Electron neutrinos
  SetNSQParams(nuSQ,0)
  #SetNSQParams(this_zen,nuSQBar,0)
#Current output
  nuSQ.WriteStateHDF5(nue_filename)
Example #8
0
interactions = True

E_min = 500.0*units.GeV
E_max = 1.0*units.PeV
E_nodes = 100
energy_nodes = nsq.logspace(E_min,E_max,E_nodes)

cth_min = -1.0
cth_max = 0.1
cth_nodes = 20
cth_nodes = nsq.linspace(cth_min,cth_max,cth_nodes)

neutrino_flavors = 3

nsq_atm = nsq.nuSQUIDSAtm(cth_nodes,energy_nodes,neutrino_flavors,nsq.NeutrinoType.both,interactions)

N0 = 1.0e18; Power = -1.0
Eflux = lambda E: N0*E**Power

AtmInitialFlux = np.zeros((len(cth_nodes),len(energy_nodes),2,neutrino_flavors))
for ic,cth in enumerate(nsq_atm.GetCosthRange()):
    for ie,E in enumerate(nsq_atm.GetERange()):
        AtmInitialFlux[ic][ie][0][0] = 0.0 # nue
        AtmInitialFlux[ic][ie][1][0] = 0.0 # bar nue
        AtmInitialFlux[ic][ie][0][1] = Eflux(E) # nu mu
        AtmInitialFlux[ic][ie][1][1] = Eflux(E) # bar nu mu
        AtmInitialFlux[ic][ie][0][2] = Eflux(E) # nu tau
        AtmInitialFlux[ic][ie][1][2] = Eflux(E) # bar nu tau

nsq_atm.Set_initial_state(AtmInitialFlux,nsq.Basis.flavor)
Example #9
0
    def _compute_outputs(self, inputs=None):
        """Compute histograms for output channels."""
        logging.debug('Entering nusquids._compute_outputs')
        if not isinstance(inputs, MapSet):
            raise AssertionError('inputs is not a MapSet object, instead '
                                 'is type {0}'.format(type(inputs)))
        # TODO(shivesh): oversampling
        # TODO(shivesh): more options
        # TODO(shivesh): static function
        # TODO(shivesh): hashing
        binning = self.input_binning.basename_binning
        binning = binning.reorder_dimensions(('coszen', 'energy'),
                                             use_basenames=True)
        cz_binning = binning['coszen']
        en_binning = binning['energy']

        units = nsq.Const()

        interactions = False
        cz_min = cz_binning.bin_edges.min().m_as('radian')
        cz_max = cz_binning.bin_edges.max().m_as('radian')
        en_min = en_binning.bin_edges.min().m_as('GeV') * units.GeV
        en_max = en_binning.bin_edges.max().m_as('GeV') * units.GeV
        cz_centers = cz_binning.weighted_centers.m_as('radian')
        en_centers = en_binning.weighted_centers.m_as('GeV') * units.GeV
        cz_grid = np.array([cz_min] + cz_centers.tolist() + [cz_max])
        en_grid = np.array([en_min] + en_centers.tolist() + [en_max])
        nu_flavours = 3

        nuSQ = nsq.nuSQUIDSAtm(cz_grid, en_grid, nu_flavours,
                               nsq.NeutrinoType.both, interactions)

        nuSQ.Set_EvalThreads(multiprocessing.cpu_count())

        theta12 = self.params['theta12'].value.m_as('radian')
        theta13 = self.params['theta13'].value.m_as('radian')
        theta23 = self.params['theta23'].value.m_as('radian')

        deltam21 = self.params['deltam21'].value.m_as('eV**2')
        deltam31 = self.params['deltam21'].value.m_as('eV**2')

        # TODO(shivesh): check if deltacp should be in radians
        deltacp = self.params['deltacp'].value.m_as('radian')

        nuSQ.Set_MixingAngle(0, 1, theta12)
        nuSQ.Set_MixingAngle(0, 2, theta13)
        nuSQ.Set_MixingAngle(1, 2, theta23)

        nuSQ.Set_SquareMassDifference(1, deltam21)
        nuSQ.Set_SquareMassDifference(2, deltam31)

        nuSQ.Set_CPPhase(0, 2, deltacp)

        nuSQ.Set_rel_error(1.0e-10)
        nuSQ.Set_abs_error(1.0e-10)

        # Pad the edges of the energy, coszen space to cover the entire grid range
        cz_shape = cz_binning.shape[0] + 2
        en_shape = en_binning.shape[0] + 2
        shape = (cz_shape, en_shape) + (2, 3)
        initial_state = np.full(shape, np.nan)

        def pad_inputs(x):
            return np.pad(unp.nominal_values(x.hist), 1, 'edge')

        # Third index is selecting nu(0), nubar(1)
        # Fourth index is selecting flavour nue(0), numu(1), nutau(2)
        initial_state[:, :, 0, 0] = pad_inputs(inputs['nue'])
        initial_state[:, :, 1, 0] = pad_inputs(inputs['nuebar'])
        initial_state[:, :, 0, 1] = pad_inputs(inputs['numu'])
        initial_state[:, :, 1, 1] = pad_inputs(inputs['numubar'])
        initial_state[:, :, 0, 2] = np.zeros(pad_inputs(inputs['nue']).shape)
        initial_state[:, :, 1, 2] = np.zeros(pad_inputs(inputs['nue']).shape)

        if np.any(np.isnan(initial_state)):
            raise AssertionError('nan entries in initial_state: '
                                 '{0}'.format(initial_state))
        nuSQ.Set_initial_state(initial_state, nsq.Basis.flavor)

        # TODO(shivesh): use verbosity level to set this
        nuSQ.Set_ProgressBar(True)
        nuSQ.EvolveState()

        os = self.params['oversample'].value.m
        os_binning = binning.oversample(os)
        os_cz_binning = os_binning['coszen']
        os_en_binning = os_binning['energy']
        os_cz_centers = os_cz_binning.weighted_centers.m_as('radians')
        os_en_centers = os_en_binning.weighted_centers.m_as('GeV')

        fs = {}
        for nu in self.output_names:
            fs[nu] = np.full(os_binning.shape, np.nan)

        for icz, cz_bin in enumerate(os_cz_centers):
            for ie, en_bin in enumerate(os_en_centers):
                en_bin_u = en_bin * units.GeV
                fs['nue'][icz][ie] = nuSQ.EvalFlavor(0, cz_bin, en_bin_u, 0)
                fs['nuebar'][icz][ie] = nuSQ.EvalFlavor(0, cz_bin, en_bin_u, 1)
                fs['numu'][icz][ie] = nuSQ.EvalFlavor(1, cz_bin, en_bin_u, 0)
                fs['numubar'][icz][ie] = nuSQ.EvalFlavor(
                    1, cz_bin, en_bin_u, 1)
                fs['nutau'][icz][ie] = nuSQ.EvalFlavor(2, cz_bin, en_bin_u, 0)
                fs['nutaubar'][icz][ie] = nuSQ.EvalFlavor(
                    2, cz_bin, en_bin_u, 1)

        out_binning = self.input_binning.reorder_dimensions(
            ('coszen', 'energy'), use_basenames=True)
        os_out_binning = out_binning.oversample(os)

        outputs = []
        for key in fs.iterkeys():
            if np.any(np.isnan(fs[key])):
                raise AssertionError(
                    'Invalid value computed for {0} oscillated output: '
                    '\n{1}'.format(key, fs[key]))
            map = Map(name=key, binning=os_out_binning, hist=fs[key])
            map = map.downsample(os) / float(os)
            map = map.reorder_dimensions(self.input_binning)
            outputs.append(map)

        return MapSet(outputs)
Example #10
0
def make_plots():
    Emin = 1 * un.GeV
    Emax = 10 * un.PeV

    energies = nsq.logspace(Emin, Emax, 100)
    angles = nsq.linspace(-0.99, -0.98, 2)

    # just look at straight up/down
    # get MCEq flux there

    mag = 0.
    angle = 0.  #degrees

    mceq = MCEqRun(interaction_model='SIBYLL23C',
                   primary_model=(crf.HillasGaisser2012, 'H3a'),
                   theta_deg=0.)

    mceq.solve()

    n_nu = 3
    inistate = np.zeros(shape=(2, len(energies), 2, n_nu))
    flux = {}

    flux['e_grid'] = mceq.e_grid
    flux['nue_flux'] = mceq.get_solution('nue', mag) + mceq.get_solution(
        'pr_nue', mag)
    flux['nue_bar_flux'] = mceq.get_solution(
        'antinue', mag) + mceq.get_solution('pr_antinue', mag)
    flux['numu_flux'] = mceq.get_solution('numu', mag) + mceq.get_solution(
        'pr_numu', mag)
    flux['numu_bar_flux'] = mceq.get_solution(
        'antinumu', mag) + mceq.get_solution('pr_antinumu', mag)
    flux['nutau_flux'] = mceq.get_solution('nutau', mag) + mceq.get_solution(
        'pr_nutau', mag)
    flux['nutau_bar_flux'] = mceq.get_solution(
        'antinutau', mag) + mceq.get_solution('pr_antinutau', mag)

    # propagate it with nusquids
    for neut_type in range(2):
        for flavor in range(n_nu):
            flav_key = get_key(flavor, neut_type)
            if flav_key == "":
                continue
            for energy_bin in range(len(energies)):
                inistate[0][energy_bin][neut_type][flavor] = get_closest(
                    energies[energy_bin] / un.GeV, flux['e_grid'],
                    flux[flav_key])

                inistate[1][energy_bin][neut_type][flavor] = get_closest(
                    energies[energy_bin] / un.GeV, flux['e_grid'],
                    flux[flav_key])

    nus_atm = nsq.nuSQUIDSAtm(angles, energies, n_nu, nsq.NeutrinoType.both,
                              True)

    nus_atm.Set_MixingAngle(0, 1, 0.563942)
    nus_atm.Set_MixingAngle(0, 2, 0.154085)
    nus_atm.Set_MixingAngle(1, 2, 0.785398)

    nus_atm.Set_SquareMassDifference(1, 7.65e-05)
    nus_atm.Set_SquareMassDifference(2, 0.00247)

    nus_atm.SetNeutrinoCrossSections(xs)

    #settting some zenith angle stuff
    nus_atm.Set_rel_error(1.0e-6)
    nus_atm.Set_abs_error(1.0e-6)
    #nus_atm.Set_GSL_step(gsl_odeiv2_step_rk4)
    nus_atm.Set_GSL_step(nsq.GSL_STEP_FUNCTIONS.GSL_STEP_RK4)

    # we load in the initial state. Generating or Loading from a file
    nus_atm.Set_initial_state(inistate, nsq.Basis.flavor)
    print("Done setting initial state")

    # we turn off the progress bar for jobs run on the cobalts
    nus_atm.Set_ProgressBar(False)
    nus_atm.Set_IncludeOscillations(True)

    print("Evolving State")
    nus_atm.EvolveState()

    # Evaluate the flux at the energies, flavors, and shit we care about

    eval_flux = {}
    for flavor in range(3):
        for nute in range(2):
            key = get_key(flavor, nute)
            if key == "":
                continue
            eval_flux[key] = np.zeros(len(energies))

            for energy in range(len(energies)):
                powed = energies[energy]

                eval_flux[key][energy] = nus_atm.EvalFlavor(
                    flavor, -0.985, powed, nute)

    # multiply the fluxes with total cross sections at that energy

    conv_flux = {}
    for flavor in flavors.keys():
        if flavor == "electron":
            i_flav = 0
        elif flavor == "muon":
            i_flav = 1
        else:
            i_flav = 2
        for neut_type in neut_types.keys():
            if neut_type == "neutrino":
                i_neut = 0
            else:
                i_neut = 1

            eval_key = get_key(i_flav, i_neut)
            for current in currents.keys():
                conv_key = "_".join([flavor, neut_type, current])
                conv_flux[conv_key] = np.zeros(len(energies))
                for energy in range(len(energies)):
                    powed = energies[energy]

                    conv_flux[conv_key][
                        energy] = eval_flux[eval_key][energy] * get_total_flux(
                            powed, flavors[flavor], neut_types[neut_type],
                            currents[current])

    # sum up the cascades and compare them with the cross sections

    casc_fluxes = np.zeros(len(energies))
    track_fluxes = np.zeros(len(energies))
    for key in conv_flux:
        if is_cascade(key):
            casc_fluxes += conv_flux[key]
        else:
            track_fluxes += conv_flux[key]

    plt.plot(energies / un.GeV, casc_fluxes, label="Cascades")
    plt.plot(energies / un.GeV, track_fluxes, label="Tracks")
    plt.xscale('log')
    plt.xlim([10**2, 10**7])
    plt.yscale('log')
    plt.legend()
    plt.xlabel("Energy [GeV]", size=14)
    plt.ylabel(r"Flux$\cdot\sigma_{total}$ [s GeV sr]$^{-1}$", size=14)
    plt.show()