コード例 #1
0
ファイル: AeffServicePar.py プロジェクト: olivas/pisa
    def get_aeff_flavor(self,flavor,aeff_egy_par,aeff_coszen_par):
        '''
        Creates the 2d aeff file from the parameterized aeff
        vs. energy .dat file, an input to the parametric settings file.
        '''

        aeff_file = aeff_egy_par[flavor]
        aeff_arr = np.loadtxt(open_resource(aeff_file)).T
        # interpolate
        aeff_func = interp1d(aeff_arr[0], aeff_arr[1], kind='linear',
                             bounds_error=False, fill_value=0)

        czcen = get_bin_centers(self.czbins)
        ecen = get_bin_centers(self.ebins)

        # Get 1D array interpolated values at bin centers, assume no cz dep
        aeff1d = aeff_func(ecen)

        # Make this into a 2D array:
        aeff2d = np.reshape(np.repeat(aeff1d, len(czcen)), (len(ecen), len(czcen)))

        # Now add cz-dependence, assuming nu and nu_bar has same dependence:
        cz_dep = eval(aeff_coszen_par[flavor.strip('_bar')])(czcen)
        # Normalize:
        cz_dep *= len(cz_dep)/np.sum(cz_dep)

        return (aeff2d*cz_dep)
コード例 #2
0
ファイル: HondaFluxService.py プロジェクト: mdunkman/pisa
    def __init__(self, tables, smooth=0.05, **params):
        logging.info("Loading atmospheric flux table %s" %tables)
        
        #Load the data table
        table = np.loadtxt(open_resource(tables)).T

        #columns in Honda files are in the same order 
        cols = ['energy']+primaries 

        flux_dict = dict(zip(cols, table))
        for key in flux_dict.iterkeys():
            
            #There are 20 lines per zenith range
            flux_dict[key] = np.array(np.split(flux_dict[key], 20))
            if not key=='energy':
                flux_dict[key] = flux_dict[key].T
    
        #Set the zenith and energy range 
        flux_dict['energy'] = flux_dict['energy'][0]
        flux_dict['coszen'] = np.linspace(0.95, -0.95, 20)
    
        #Now get a spline representation of the flux table.
        logging.debug('Make spline representation of flux')
        # do this in log of energy and log of flux (more stable)
        logE, C = np.meshgrid(np.log10(flux_dict['energy']), flux_dict['coszen'])

        self.spline_dict = {}
        for nutype in primaries:
            #Get the logarithmic flux
            log_flux = np.log10(flux_dict[nutype]).T
            #Get a spline representation
            spline =  bisplrep(logE, C, log_flux, s=smooth)
            #and store
            self.spline_dict[nutype] = spline
コード例 #3
0
ファイル: HondaFluxService.py プロジェクト: mamday/pisa
    def __init__(self, flux_file=None, smooth=0.05, **params):
        logging.info("Loading atmospheric flux table %s" % flux_file)

        #Load the data table
        table = np.loadtxt(open_resource(flux_file)).T

        #columns in Honda files are in the same order
        cols = ['energy'] + primaries

        flux_dict = dict(zip(cols, table))
        for key in flux_dict.iterkeys():

            #There are 20 lines per zenith range
            flux_dict[key] = np.array(np.split(flux_dict[key], 20))
            if not key == 'energy':
                flux_dict[key] = flux_dict[key].T

        #Set the zenith and energy range
        flux_dict['energy'] = flux_dict['energy'][0]
        flux_dict['coszen'] = np.linspace(0.95, -0.95, 20)

        #Now get a spline representation of the flux table.
        logging.debug('Make spline representation of flux')
        # do this in log of energy and log of flux (more stable)
        logE, C = np.meshgrid(np.log10(flux_dict['energy']),
                              flux_dict['coszen'])

        self.spline_dict = {}
        for nutype in primaries:
            #Get the logarithmic flux
            log_flux = np.log10(flux_dict[nutype]).T
            #Get a spline representation
            spline = bisplrep(logE, C, log_flux, s=smooth)
            #and store
            self.spline_dict[nutype] = spline
コード例 #4
0
ファイル: AeffServicePar.py プロジェクト: mamday/pisa
    def get_aeff_flavor(self, flavor, aeff_egy_par, aeff_coszen_par):
        '''
        Creates the 2d aeff file from the parameterized aeff
        vs. energy .dat file, an input to the parametric settings file.
        '''

        aeff_file = aeff_egy_par[flavor]
        aeff_arr = np.loadtxt(open_resource(aeff_file)).T
        # interpolate
        aeff_func = interp1d(aeff_arr[0],
                             aeff_arr[1],
                             kind='linear',
                             bounds_error=False,
                             fill_value=0)

        czcen = get_bin_centers(self.czbins)
        ecen = get_bin_centers(self.ebins)

        # Get 1D array interpolated values at bin centers, assume no cz dep
        aeff1d = aeff_func(ecen)

        # Correct for final energy bin, since interpolation does not
        # extend to JUST right outside the final bin:
        if aeff1d[-1] == 0.0: aeff1d[-1] = aeff1d[-2]

        # Make this into a 2D array:
        aeff2d = np.reshape(np.repeat(aeff1d, len(czcen)),
                            (len(ecen), len(czcen)))

        # Now add cz-dependence, assuming nu and nu_bar has same dependence:
        cz_dep = eval(aeff_coszen_par[flavor.strip('_bar')])(czcen)
        # Normalize:
        cz_dep *= len(cz_dep) / np.sum(cz_dep)

        return (aeff2d * cz_dep)
コード例 #5
0
from pisa.flux.HondaFluxService import primaries
from pisa.utils.plot import show_map, delta_map, ratio_map
from pisa.resources.resources import open_resource

parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument('-IP','--IP_flux_file',type=str,help="JSON file containing IP flux values to work with")
parser.add_argument('-SI','--SI_flux_file',type=str,help="JSON file containing standard interpolation flux values to work with")
args = parser.parse_args()

titles = {}
titles['nue'] = r'$\nu_e$'
titles['nue_bar'] = r'$\bar{\nu}_e$'
titles['numu'] = r'$\nu_{\mu}$'
titles['numu_bar'] = r'$\bar{\nu}_{\mu}$'

HondaFluxTable = np.loadtxt(open_resource('/Users/steven/IceCube/PISA/pisa/pisa/resources/flux/spl-2015-solmax-aa.d')).T
cols = ['energy']+primaries
flux_dict = dict(zip(cols, HondaFluxTable))
for key in flux_dict.iterkeys():

    #There are 20 lines per zenith range
    flux_dict[key] = np.array(np.split(flux_dict[key], 20))
    new_array = []
    for i in range(0,len(flux_dict[key])):
        new_array.append(flux_dict[key][len(flux_dict[key])-1-i])
    flux_dict[key] = np.array(new_array)
    if not key=='energy':
        flux_dict[key] = flux_dict[key].T

flux_dict['energy'] = flux_dict['energy'][0]
flux_dict['coszen'] = np.linspace(0.95, -0.95, 20)