def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, oversample_e=None,oversample_cz=None, **kwargs): """ \params: * 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. """ logging.info('Instantiating %s'%self.__class__.__name__) self.ebins = np.array(ebins) self.czbins = np.array(czbins) for ax in [self.ebins, self.czbins]: if (len(np.shape(ax)) != 1): raise IndexError('Axes must be 1d! '+str(np.shape(ax))) report_params(get_params(),['km','','','','km']) earth_model = find_resource(earth_model) self.earth_model = earth_model self.FTYPE = np.float64 self.ebins_fine = oversample_binning(self.ebins, oversample_e) self.czbins_fine = oversample_binning(self.czbins, oversample_cz) self.ecen_fine = get_bin_centers(self.ebins_fine) self.czcen_fine = get_bin_centers(self.czbins_fine) self.initialize_kernel() return
def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, oversample_e=None, oversample_cz=None, gpu_id=None, **kwargs): """ \params: * 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. * gpu_id: If running on a system with multiple GPUs, it will choose the one with gpu_id. Otherwise, defaults to default context """ self.gpu_id = gpu_id try: import pycuda.autoinit self.context = cuda.Device(self.gpu_id).make_context() print "Initializing PyCUDA using gpu id: %d" % self.gpu_id except: import pycuda.autoinit print "Auto initializing PyCUDA..." #mfree,mtot = cuda.mem_get_info() #print "free memory: %s mb",mfree/1.0e6 #print "tot memory: %s mb",mtot/1.0e6 #raw_input("PAUSED...") logging.info('Instantiating %s' % self.__class__.__name__) self.ebins = np.array(ebins) self.czbins = np.array(czbins) self.prop_height = prop_height for ax in [self.ebins, self.czbins]: if (len(np.shape(ax)) != 1): raise IndexError('Axes must be 1d! ' + str(np.shape(ax))) report_params(get_params(), ['km', '', '', '', '']) earth_model = find_resource(earth_model) self.earth_model = earth_model self.FTYPE = np.float64 self.ebins_fine = oversample_binning(self.ebins, oversample_e) self.czbins_fine = oversample_binning(self.czbins, oversample_cz) self.ecen_fine = get_bin_centers(self.ebins_fine) self.czcen_fine = get_bin_centers(self.czbins_fine) self.initialize_kernel(detector_depth, **kwargs) return
def __init__(self, ebins, czbins, detector_depth=None, earth_model=None, prop_height=None, oversample_e=None,oversample_cz=None,gpu_id=None, **kwargs): """ \params: * 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. * gpu_id: If running on a system with multiple GPUs, it will choose the one with gpu_id. Otherwise, defaults to default context """ self.gpu_id = gpu_id try: import pycuda.autoinit self.context = cuda.Device(self.gpu_id).make_context() print "Initializing PyCUDA using gpu id: %d"%self.gpu_id except: import pycuda.autoinit print "Auto initializing PyCUDA..." #mfree,mtot = cuda.mem_get_info() #print "free memory: %s mb",mfree/1.0e6 #print "tot memory: %s mb",mtot/1.0e6 #raw_input("PAUSED...") logging.info('Instantiating %s'%self.__class__.__name__) self.ebins = np.array(ebins) self.czbins = np.array(czbins) self.prop_height = prop_height for ax in [self.ebins, self.czbins]: if (len(np.shape(ax)) != 1): raise IndexError('Axes must be 1d! '+str(np.shape(ax))) report_params(get_params(),['km','','','','']) earth_model = find_resource(earth_model) self.earth_model = earth_model self.FTYPE = np.float64 self.ebins_fine = oversample_binning(self.ebins, oversample_e) self.czbins_fine = oversample_binning(self.czbins, oversample_cz) self.ecen_fine = get_bin_centers(self.ebins_fine) self.czcen_fine = get_bin_centers(self.czbins_fine) self.initialize_kernel(detector_depth,**kwargs) return
def get_osc_probLT_dict(self, ebins=None, czbins=None, oversample_e=None, oversample_cz=None, **kwargs): """ 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} Will call fill_osc_prob to calculate the individual probabilities on the fly. By default, the standard binning is oversampled by a factor 10. Alternatively, the oversampling factor can be changed or a fine binning specified explicitly. In the latter case, the oversampling factor is ignored. """ #First initialize the fine binning if not explicitly given if not check_fine_binning(ebins, self.ebins): ebins = oversample_binning(self.ebins, oversample_e) if not check_fine_binning(czbins, self.czbins): czbins = oversample_binning(self.czbins, oversample_cz) ecen = get_bin_centers(ebins) czcen = get_bin_centers(czbins) osc_prob_dict = {} for nu in ['nue_maps', 'numu_maps', 'nue_bar_maps', 'numu_bar_maps']: isbar = '_bar' if 'bar' in nu else '' osc_prob_dict[nu] = { 'nue' + isbar: [], 'numu' + isbar: [], 'nutau' + isbar: [], } evals, czvals = self.fill_osc_prob(osc_prob_dict, ecen, czcen, **kwargs) osc_prob_dict['evals'] = evals osc_prob_dict['czvals'] = czvals return osc_prob_dict
def get_osc_probLT_dict(self, ebins=None, czbins=None, oversample_e=None,oversample_cz=None, **kwargs): """ 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} Will call fill_osc_prob to calculate the individual probabilities on the fly. By default, the standard binning is oversampled by a factor 10. Alternatively, the oversampling factor can be changed or a fine binning specified explicitly. In the latter case, the oversampling factor is ignored. """ #First initialize the fine binning if not explicitly given if not check_fine_binning(ebins, self.ebins): ebins = oversample_binning(self.ebins, oversample_e) if not check_fine_binning(czbins, self.czbins): czbins = oversample_binning(self.czbins, oversample_cz) ecen = get_bin_centers(ebins) czcen = get_bin_centers(czbins) osc_prob_dict = {} for nu in ['nue_maps','numu_maps','nue_bar_maps','numu_bar_maps']: isbar = '_bar' if 'bar' in nu else '' osc_prob_dict[nu] = {'nue'+isbar: [], 'numu'+isbar: [], 'nutau'+isbar: [],} evals,czvals = self.fill_osc_prob(osc_prob_dict, ecen, czcen, **kwargs) osc_prob_dict['evals'] = evals osc_prob_dict['czvals'] = czvals return osc_prob_dict