def __init__(self, ebins, czbins, earth_model='oscillations/PREM_60layer.dat'): self.ebins = ebins self.czbins = czbins earth_model = find_resource(earth_model) #TODO: These should be parameters detector_depth = 2.0 # Detector depth in km self.prop_height = 20.0 # Height in the atmosphere to begin (default= 20 km) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False)
def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. * detector_depth: Detector depth in km. * prop_height: Height in the atmosphere to begin in km. """ OscillationServiceBase.__init__(self, ebins, czbins) logging.info('Initializing %s...' % self.__class__.__name__) report_params(get_params(), ['km', '', 'km']) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False)
def __init__(self, ebins, czbins, earth_model='oscillations/PREM_60layer.dat', detector_depth=2.0, prop_height=20.0, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. Default: 60-layer PREM model shipped with pisa. * detector_depth: Detector depth in km. Default: 2.0 * prop_height: Height in the atmosphere to begin in km. Default: 20.0 """ OscillationServiceBase.__init__(self, ebins, czbins) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False)
def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. * detector_depth: Detector depth in km. * prop_height: Height in the atmosphere to begin in km. """ OscillationServiceBase.__init__(self, ebins, czbins) report_params(get_params(),['km','','km']) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False)
class Prob3OscillationService(OscillationServiceBase): """ This class handles all tasks related to the oscillation probability calculations using the prob3 oscillation code """ def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. * detector_depth: Detector depth in km. * prop_height: Height in the atmosphere to begin in km. """ OscillationServiceBase.__init__(self, ebins, czbins) logging.info('Initializing %s...' % self.__class__.__name__) report_params(get_params(), ['km', '', 'km']) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False) 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, YeI=None, YeO=None, YeM=None, **kwargs): ''' Loops over ecen,czcen and fills the osc_prob_dict maps, with probabilities calculated according to prob3 ''' neutrinos = ['nue', 'numu', 'nutau'] anti_neutrinos = ['nue_bar', 'numu_bar', 'nutau_bar'] mID = ['', '_bar'] nu_barger = { 'nue': 1, 'numu': 2, 'nutau': 3, 'nue_bar': 1, 'numu_bar': 2, 'nutau_bar': 3 } logging.info("Defining osc_prob_dict from BargerPropagator...") tprofile.info("start oscillation calculation") # Set to true, since we are using sin^2(theta) variables kSquared = True sin2th12Sq = np.sin(theta12)**2 sin2th13Sq = np.sin(theta13)**2 sin2th23Sq = np.sin(theta23)**2 evals = [] czvals = [] total_bins = int(len(ecen) * len(czcen)) mod = total_bins / 20 loglevel = logging.root.getEffectiveLevel() for ie, energy in enumerate(ecen): for icz, coszen in enumerate(czcen): evals.append(energy) czvals.append(coszen) scaled_energy = energy * energy_scale if loglevel <= logging.INFO: if ((ie + 1) * (icz + 1) % mod == 0): sys.stdout.write(".") sys.stdout.flush() # In BargerPropagator code, it takes the "atmospheric # mass difference"-the nearest two mass differences, so # that it takes as input deltam31 for IMH and deltam32 # for NMH mAtm = deltam31 if deltam31 < 0.0 else (deltam31 - deltam21) ########### FIRST FOR NEUTRINOS ########## kNuBar = 1 # +1 for nu -1 for nubar self.barger_prop.SetMNS(sin2th12Sq, sin2th13Sq, sin2th23Sq, deltam21, mAtm, deltacp, scaled_energy, kSquared, kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height, YeI, YeO, YeM) self.barger_prop.propagate(kNuBar) for nu in ['nue', 'numu']: nu_i = nu_barger[nu] nu = nu + '_maps' for to_nu in neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu].append( self.barger_prop.GetProb(nu_i, nu_f)) ########### SECOND FOR ANTINEUTRINOS ########## kNuBar = -1 self.barger_prop.SetMNS(sin2th12Sq, sin2th13Sq, sin2th23Sq, deltam21, mAtm, deltacp, scaled_energy, kSquared, kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height, YeI, YeO, YeM) self.barger_prop.propagate(kNuBar) for nu in ['nue_bar', 'numu_bar']: nu_i = nu_barger[nu] nu += '_maps' for to_nu in anti_neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu].append( self.barger_prop.GetProb(nu_i, nu_f)) if loglevel <= logging.INFO: sys.stdout.write("\n") tprofile.info("stop oscillation calculation") return evals, czvals
class Prob3OscillationService: """ This class handles all tasks related to the oscillation probability calculations... """ def __init__(self, ebins, czbins, earth_model='oscillations/PREM_60layer.dat'): self.ebins = ebins self.czbins = czbins earth_model = find_resource(earth_model) #TODO: These should be parameters detector_depth = 2.0 # Detector depth in km self.prop_height = 20.0 # Height in the atmosphere to begin (default= 20 km) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False) def get_osc_prob_maps(self,deltam21=None,deltam31=None,theta12=None, theta13=None,theta23=None,deltacp=None,**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': {...} NOTE: expects all angles in [rad] """ osc_probLT_dict = self.get_osc_probLT_dict(theta12,theta13,theta23, deltam21,deltam31,deltacp) ebinsLT = osc_probLT_dict['ebins'] czbinsLT = osc_probLT_dict['czbins'] start_time = datetime.now() logging.info("Getting smoothed maps...") # do smoothing smoothed_maps = {} smoothed_maps['ebins'] = self.ebins smoothed_maps['czbins'] = self.czbins for from_nu in ['nue','numu','nue_bar','numu_bar']: path_base = from_nu+'_maps' to_maps = {} to_nu_list = ['nue_bar','numu_bar','nutau_bar'] if 'bar' in from_nu else ['nue','numu','nutau'] for to_nu in to_nu_list: logging.info("Getting smoothed map %s"%(from_nu+'_maps/'+to_nu)) to_maps[to_nu]=get_smoothed_map(osc_probLT_dict[from_nu+'_maps'][to_nu], ebinsLT,czbinsLT,self.ebins,self.czbins) smoothed_maps[from_nu+'_maps'] = to_maps logging.info("Finshed getting smoothed maps. This took: %s"%(datetime.now()-start_time)) return smoothed_maps def get_osc_probLT_dict(self,theta12,theta13,theta23,deltam21,deltam31,deltacp, eminLT = 1.0, emaxLT =80.0, nebinsLT=500, czminLT=-1.0, czmaxLT= 1.0, nczbinsLT=500): ''' This will create the oscillation probability map lookup tables (LT) corresponding to atmospheric neutrinos oscillation through the earth, and will return a dictionary of maps: {'nue_maps':[to_nue_map, to_numu_map, to_nutau_map], 'numu_maps: [...], 'nue_bar_maps': [...], 'numu_bar_maps': [...], 'czbins':czbins, 'ebins': ebins} Uses the BargerPropagator code to calculate the individual probabilities on the fly. NOTE: Expects all angles to be in [rad], and all deltam to be in [eV^2] ''' # First initialize all empty maps to use in osc_prob_dict ebins = np.logspace(np.log10(eminLT),np.log10(emaxLT),nebinsLT+1) czbins = np.linspace(czminLT,czmaxLT,nczbinsLT+1) ecen = get_bin_centers(ebins) czcen = get_bin_centers(czbins) osc_prob_dict = {'ebins':ebins, 'czbins':czbins} shape = (len(ecen),len(czcen)) for nu in ['nue_maps','numu_maps','nue_bar_maps','numu_bar_maps']: if 'bar' in nu: osc_prob_dict[nu] = {'nue_bar': np.zeros(shape,dtype=np.float32), 'numu_bar': np.zeros(shape,dtype=np.float32), 'nutau_bar': np.zeros(shape,dtype=np.float32)} else: osc_prob_dict[nu] = {'nue': np.zeros(shape,dtype=np.float32), 'numu': np.zeros(shape,dtype=np.float32), 'nutau': np.zeros(shape,dtype=np.float32)} self.fill_osc_prob(osc_prob_dict, ecen, czcen, theta12=theta12, theta13=theta13, theta23=theta23, deltam21=deltam21, deltam31=deltam31, deltacp=deltacp) return osc_prob_dict def fill_osc_prob(self, osc_prob_dict, ecen,czcen, theta12=None, theta13=None, theta23=None, deltam21=None, deltam31=None, deltacp=None): ''' Loops over ecen,czcen and fills the osc_prob_dict maps, with probabilities calculated according to NuCraft ''' neutrinos = ['nue','numu','nutau'] anti_neutrinos = ['nue_bar','numu_bar','nutau_bar'] mID = ['','_bar'] nu_barger = {'nue':1,'numu':2,'nutau':3, 'nue_bar':1,'numu_bar':2,'nutau_bar':3} logging.info("Defining osc_prob_dict from BargerPropagator...") # Set to false, since we are using sin^2(2 theta) variables kSquared = False sin2th12Sq = np.sin(2.0*theta12)**2 sin2th13Sq = np.sin(2.0*theta13)**2 sin2th23Sq = np.sin(2.0*theta23)**2 total_bins = int(len(ecen)*len(czcen)) mod = total_bins/50 ibin = 0 for icz, coszen in enumerate(czcen): for ie,energy in enumerate(ecen): ibin+=1 if (ibin%mod) == 0: sys.stdout.write(".") sys.stdout.flush() # In BargerPropagator code, it takes the "atmospheric # mass difference"-the nearest two mass differences, so # that it takes as input deltam31 for IMH and deltam32 # for NMH mAtm = deltam31 if deltam31 < 0.0 else (deltam31 - deltam21) ########### FIRST FOR NEUTRINOS ########## kNuBar = 1 # +1 for nu -1 for nubar self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21,mAtm, deltacp,energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height) self.barger_prop.propagate(kNuBar) for nu in ['nue','numu']: nu_i = nu_barger[nu] nu = nu+'_maps' for to_nu in neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu][ie][icz]=self.barger_prop.GetProb(nu_i,nu_f) ########### SECOND FOR ANTINEUTRINOS ########## kNuBar = -1 self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21, mAtm,deltacp,energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height) self.barger_prop.propagate(kNuBar) for nu in ['nue_bar','numu_bar']: nu_i = nu_barger[nu] nu+='_maps' for to_nu in anti_neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu][ie][icz] = self.barger_prop.GetProb(nu_i,nu_f) print "" return
start_time = datetime.now() osc_params = {'deltacp':args.deltacp, 'deltam21':args.deltam21, 'deltam31':args.deltam31,'theta12':args.theta12, 'theta13':args.theta13,'theta23':args.theta23} report_params(osc_params, units = ['rad','eV^2','eV^2','rad','rad','rad']) # Initialize binning for prob maps: ebins = np.linspace(1,80,150) czbins = np.linspace(-1,0,150) # Initialize barger propagator which contains the methods for # extracting the oscillation probabilities through the earth. earth_model = find_resource(args.earth_model) barger_prop = BargerPropagator(earth_model, args.detector_depth) barger_prop.UseMassEigenstates(False) mAtm = args.deltam31 if args.deltam31 < 0.0 else (args.deltam31 - args.deltam21) # Set to false, since we are using sin^2(2 theta) variables kSquared = False sin2th12Sq = np.sin(2.0*args.theta12)**2 sin2th13Sq = np.sin(2.0*args.theta13)**2 sin2th23Sq = np.sin(2.0*args.theta23)**2 neutrinos = ['nue','numu','nutau'] anti_neutrinos = ['nue_bar','numu_bar','nutau_bar'] nu_barger = {'nue':1,'numu':2,'nutau':3, 'nue_bar':1,'numu_bar':2,'nutau_bar':3}
class Prob3OscillationService(OscillationServiceBase): """ This class handles all tasks related to the oscillation probability calculations using the prob3 oscillation code """ def __init__(self, ebins, czbins, earth_model='oscillations/PREM_60layer.dat', detector_depth=2.0, prop_height=20.0, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. Default: 60-layer PREM model shipped with pisa. * detector_depth: Detector depth in km. Default: 2.0 * prop_height: Height in the atmosphere to begin in km. Default: 20.0 """ OscillationServiceBase.__init__(self, ebins, czbins) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False) 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 prob3 ''' neutrinos = ['nue','numu','nutau'] anti_neutrinos = ['nue_bar','numu_bar','nutau_bar'] mID = ['','_bar'] nu_barger = {'nue':1,'numu':2,'nutau':3, 'nue_bar':1,'numu_bar':2,'nutau_bar':3} logging.info("Defining osc_prob_dict from BargerPropagator...") profile.info("start oscillation calculation") # Set to false, since we are using sin^2(2 theta) variables kSquared = False sin2th12Sq = np.sin(2.0*theta12)**2 sin2th13Sq = np.sin(2.0*theta13)**2 sin2th23Sq = np.sin(2.0*theta23)**2 total_bins = int(len(ecen)*len(czcen)) mod = total_bins/50 ibin = 0 loglevel = logging.root.getEffectiveLevel() for icz, coszen in enumerate(czcen): for ie,energy in enumerate(ecen): if energy_scale is not None: energy*=energy_scale ibin+=1 if loglevel <= logging.INFO: if (ibin%mod) == 0: sys.stdout.write(".") sys.stdout.flush() # In BargerPropagator code, it takes the "atmospheric # mass difference"-the nearest two mass differences, so # that it takes as input deltam31 for IMH and deltam32 # for NMH mAtm = deltam31 if deltam31 < 0.0 else (deltam31 - deltam21) ########### FIRST FOR NEUTRINOS ########## kNuBar = 1 # +1 for nu -1 for nubar self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21,mAtm, deltacp,energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height) self.barger_prop.propagate(kNuBar) for nu in ['nue','numu']: nu_i = nu_barger[nu] nu = nu+'_maps' for to_nu in neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu][ie][icz]=self.barger_prop.GetProb(nu_i,nu_f) ########### SECOND FOR ANTINEUTRINOS ########## kNuBar = -1 self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21, mAtm,deltacp,energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height) self.barger_prop.propagate(kNuBar) for nu in ['nue_bar','numu_bar']: nu_i = nu_barger[nu] nu+='_maps' for to_nu in anti_neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu][ie][icz] = self.barger_prop.GetProb(nu_i,nu_f) if loglevel <= logging.INFO: sys.stdout.write("\n") profile.info("stop oscillation calculation") return
class Prob3OscillationService(OscillationServiceBase): """ This class handles all tasks related to the oscillation probability calculations using the prob3 oscillation code """ def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, **kwargs): """ Parameters needed to instantiate a Prob3OscillationService: * ebins: Energy bin edges * czbins: cos(zenith) bin edges * earth_model: Earth density model used for matter oscillations. * detector_depth: Detector depth in km. * prop_height: Height in the atmosphere to begin in km. """ OscillationServiceBase.__init__(self, ebins, czbins) logging.info('Initializing %s...'%self.__class__.__name__) report_params(get_params(),['km','','km']) self.prop_height = prop_height earth_model = find_resource(earth_model) self.barger_prop = BargerPropagator(earth_model, detector_depth) self.barger_prop.UseMassEigenstates(False) 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, YeI = None, YeO = None, YeM = None,**kwargs): ''' Loops over ecen,czcen and fills the osc_prob_dict maps, with probabilities calculated according to prob3 ''' neutrinos = ['nue','numu','nutau'] anti_neutrinos = ['nue_bar','numu_bar','nutau_bar'] mID = ['','_bar'] nu_barger = {'nue':1,'numu':2,'nutau':3, 'nue_bar':1,'numu_bar':2,'nutau_bar':3} logging.info("Defining osc_prob_dict from BargerPropagator...") profile.info("start oscillation calculation") # Set to true, since we are using sin^2(theta) variables kSquared = True sin2th12Sq = np.sin(theta12)**2 sin2th13Sq = np.sin(theta13)**2 sin2th23Sq = np.sin(theta23)**2 evals = [] czvals = [] total_bins = int(len(ecen)*len(czcen)) mod = total_bins/20 loglevel = logging.root.getEffectiveLevel() for ie,energy in enumerate(ecen): for icz, coszen in enumerate(czcen): evals.append(energy) czvals.append(coszen) scaled_energy = energy*energy_scale if loglevel <= logging.INFO: if( (ie+1)*(icz+1) % mod == 0): sys.stdout.write(".") sys.stdout.flush() # In BargerPropagator code, it takes the "atmospheric # mass difference"-the nearest two mass differences, so # that it takes as input deltam31 for IMH and deltam32 # for NMH mAtm = deltam31 if deltam31 < 0.0 else (deltam31 - deltam21) ########### FIRST FOR NEUTRINOS ########## kNuBar = 1 # +1 for nu -1 for nubar self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21,mAtm, deltacp,scaled_energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height, YeI, YeO, YeM) self.barger_prop.propagate(kNuBar) for nu in ['nue','numu']: nu_i = nu_barger[nu] nu = nu+'_maps' for to_nu in neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu].append( self.barger_prop.GetProb(nu_i,nu_f)) ########### SECOND FOR ANTINEUTRINOS ########## kNuBar = -1 self.barger_prop.SetMNS(sin2th12Sq,sin2th13Sq,sin2th23Sq,deltam21, mAtm,deltacp,scaled_energy,kSquared,kNuBar) self.barger_prop.DefinePath(coszen, self.prop_height, YeI, YeO, YeM) self.barger_prop.propagate(kNuBar) for nu in ['nue_bar','numu_bar']: nu_i = nu_barger[nu] nu+='_maps' for to_nu in anti_neutrinos: nu_f = nu_barger[to_nu] osc_prob_dict[nu][to_nu].append( self.barger_prop.GetProb(nu_i,nu_f)) if loglevel <= logging.INFO: sys.stdout.write("\n") profile.info("stop oscillation calculation") return evals,czvals
'deltam21': args.deltam21, 'deltam31': args.deltam31, 'theta12': args.theta12, 'theta13': args.theta13, 'theta23': args.theta23 } report_params(osc_params, units=['rad', 'eV^2', 'eV^2', 'rad', 'rad', 'rad']) # Initialize binning for prob maps: ebins = np.linspace(1, 80, 150) czbins = np.linspace(-1, 0, 150) # Initialize barger propagator which contains the methods for # extracting the oscillation probabilities through the earth. earth_model = find_resource(args.earth_model) barger_prop = BargerPropagator(earth_model, args.detector_depth) barger_prop.UseMassEigenstates(False) mAtm = args.deltam31 if args.deltam31 < 0.0 else (args.deltam31 - args.deltam21) # Set to false, since we are using sin^2(2 theta) variables kSquared = False sin2th12Sq = np.sin(2.0 * args.theta12)**2 sin2th13Sq = np.sin(2.0 * args.theta13)**2 sin2th23Sq = np.sin(2.0 * args.theta23)**2 neutrinos = ['nue', 'numu', 'nutau'] anti_neutrinos = ['nue_bar', 'numu_bar', 'nutau_bar'] nu_barger = { 'nue': 1,