示例#1
0
 def UpperLimit(self,
                fp,
                fn,
                delta,
                mx_min,
                mx_max,
                num_steps,
                output_file,
                processes=None):
     """ Computes the upper limit in cross-section as a function of DM mass mx.
     """
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     kwargs = ({
         'mx': mx,
         'fp': fp,
         'fn': fn,
         'delta': delta,
         'output_file': output_file
     } for mx in mx_list)
     upper_limit = np.array(
         par.parmap(self.MaximumGapUpperBoundSHM, kwargs,
                    processes)).flatten()
     upper_limit = 1. / conversion_factor * mx_list * upper_limit
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     result = np.log10(np.transpose([mx_list, upper_limit]))
     return result[result[:, 1] != np.inf]
示例#2
0
 def UpperLimit(self,
                fp,
                fn,
                delta,
                mx_min,
                mx_max,
                num_steps,
                output_file,
                processes=None):
     """ Computes the upper limit in cross-section as a function of DM mass mx.
     """
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     #        mx_list= np.array([2.891, 3.029, 3.175, 3.327, 3.486, 3.654, 3.829, 4.012, 4.205, 4.406, \
     #            4.617, 4.839, 5.071, 5.314, 5.569, 5.836, 6.116, 6.409, 6.716, 7.038, \
     #            7.376, 7.729, 8.1, 8.488, 8.895, 9.322, 9.769, 10.237, 10.728, \
     #                11.242, 11.781, 12.346, 12.938, 13.558, 14.208, 14.89, 15.603, \
     #                16.352, 17.136, 17.957, 18.818, 19.72, 20.666, 21.657, 22.695, \
     #                23.783, 24.924, 26.119, 27.371, 28.683, 30.058, 31.5, 33.01, 34.593, \
     #                36.251, 37.989, 39.811])
     kwargs = ({
         'mx': mx,
         'fp': fp,
         'fn': fn,
         'delta': delta,
         'output_file': output_file
     } for mx in mx_list)
     upper_limit = np.array(
         par.parmap(self.MaximumGapUpperBoundSHM, kwargs,
                    processes)).flatten()
     upper_limit = 1. / conversion_factor * mx_list * upper_limit
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     result = np.log10(np.transpose([mx_list, upper_limit]))
     return result[result[:, 1] != np.inf]
示例#3
0
    def UpperLimit(self, fp, fn, delta, mx_min, mx_max, num_steps, output_file,
                   processes=None):
        """ Computes the upper limit in cross-section as a function of DM mass mx.
        """
        mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
#        mx_list= np.array([2.891, 3.029, 3.175, 3.327, 3.486, 3.654, 3.829, 4.012, 4.205, 4.406, \
#            4.617, 4.839, 5.071, 5.314, 5.569, 5.836, 6.116, 6.409, 6.716, 7.038, \
#            7.376, 7.729, 8.1, 8.488, 8.895, 9.322, 9.769, 10.237, 10.728, \
#                11.242, 11.781, 12.346, 12.938, 13.558, 14.208, 14.89, 15.603, \
#                16.352, 17.136, 17.957, 18.818, 19.72, 20.666, 21.657, 22.695, \
#                23.783, 24.924, 26.119, 27.371, 28.683, 30.058, 31.5, 33.01, 34.593, \
#                36.251, 37.989, 39.811])
        kwargs = ({'mx': mx,
                   'fp': fp,
                   'fn': fn,
                   'delta': delta,
                   'output_file': output_file}
                  for mx in mx_list)
        upper_limit = np.array(par.parmap(self.MaximumGapUpperBoundSHM, kwargs, processes)
                               ).flatten()
        upper_limit = 1./conversion_factor * mx_list * upper_limit
        print("mx_list = ", mx_list)
        print("upper_limit = ", upper_limit)
        result = np.log10(np.transpose([mx_list, upper_limit]))
        return result[result[:, 1] != np.inf]
示例#4
0
    def UpperLimit(self, fp, fn, delta, mx_min, mx_max, num_steps, output_file,
                   processes=None):
        """ Computes the upper limit in cross-section as a function of DM mass mx.
        Input:
            fp, fn: float
                Couplings to proton and neutron.
            delta: float
                DM mass split.
            mx_min, mx_max: float
                Minimum and maximum DM mass.
            num_steps: int
                Number of steps in the range of DM mass values.
            output_file: string
                Name of output file where the result will be printed.
        Returns:
            upperlimit: ndarray
                Table with the first row giving the base-10 log of the DM mass, and
                the second row giving the base-10 log of the upper limit in cross-section.
        """
        mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
        kwargs = ({'mx': mx,
                   'fp': fp,
                   'fn': fn,
                   'delta': delta}
                  for mx in mx_list)

        upper_limit = np.array(par.parmap(self._MinusLogLikelihood, kwargs, processes)).flatten()
        print("mx_list = ", mx_list)
        print("upper_limit = ", upper_limit)
        result = np.log10(np.transpose([mx_list, 10.0**-upper_limit]))
        result = result[result[:, 1] != np.inf]
        with open(output_file, 'ab') as f_handle:
            np.savetxt(f_handle, result)
        return result
示例#5
0
 def UpperLimit(self, fp, fn, delta, mx_min, mx_max, num_steps, output_file,
                processes=None):
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     kwargs = ({'mx': mx,
                'fp': fp,
                'fn': fn,
                'delta': delta,
                'output_file': output_file}
               for mx in mx_list)
     upper_limit = np.array(par.parmap(self.RegionSHM, kwargs, processes))
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     return upper_limit
示例#6
0
    def UpperLowerLists(self, CL, output_file, output_file_lower, output_file_upper,
                        num_mx=1000, processes=None):
        print('CL =', CL, 'chi2 =', chi_squared(2, CL))
        self.logL_target = self.logL_max - chi_squared(2, CL)/2

        table = np.transpose(np.loadtxt(output_file))
        num_dimensions = table.shape[0]
        num_bins = (num_dimensions - 3)//3
        print('num_dimensions =', num_dimensions)
        print('num_bins =', num_bins)
        mx_list = table[0]
        sigma_fit_interp = interpolate.interp1d(mx_list, table[1])
        log_likelihood_max_interp = interpolate.interp1d(mx_list, table[2])

        predicted_interp = [interpolate.interp1d(mx_list, table[i])
                            for i in range(3, 3 + num_bins)]
        data_interp = [interpolate.interp1d(mx_list, table[i])
                       for i in range(3 + num_bins, 3 + 2 * num_bins)]
        error_interp = [interpolate.interp1d(mx_list, table[i])
                        for i in range(3 + 2 * num_bins, 3 + 3 * num_bins)]

        mx_list = np.logspace(np.log10(mx_list[0]), np.log10(mx_list[-1]), num=num_mx)

        sigma_fit = np.array([sigma_fit_interp(mx) for mx in mx_list])
        logL_max = np.array([log_likelihood_max_interp(mx) for mx in mx_list])
        predicted = np.array([[p(mx) for p in predicted_interp] for mx in mx_list])
        data = np.array([[d(mx) for d in data_interp] for mx in mx_list])
        error = np.array([[err(mx) for err in error_interp] for mx in mx_list])

        kwargs = ({'mx': mx_list[index],
                   'logL_max': logL_max[index],
                   'sigma': sigma_fit[index],
                   'pred': predicted[index],
                   'data': data[index],
                   'err': error[index]
                   }
                  for index in range(len(mx_list)))
        limits = [l for l in par.parmap(self._UpperLowerLists, kwargs,
                                        processes=processes, verbose=False) if l]
        if limits:
            limits = np.transpose(limits, axes=(1, 0, 2))
            limit_low = limits[0]
            limit_high = limits[1]
        else:
            limit_low = limit_high = []
        return [np.array(limit_low), np.array(limit_high)]
示例#7
0
 def UpperLimit(self, fp, fn, delta, mx_min, mx_max, num_steps, output_file,
                processes=None):
     """ Computes the upper limit in cross-section as a function of DM mass mx.
     """
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     kwargs = ({'mx': mx,
                'fp': fp,
                'fn': fn,
                'delta': delta,
                'output_file': output_file}
               for mx in mx_list)
     upper_limit = np.array(par.parmap(self._GaussianUpperBoundSHM, kwargs, processes)
                            ).flatten()
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     result = np.log10(np.transpose([mx_list, upper_limit]))
     return result[result[:, 1] != np.inf]
示例#8
0
 def UpperLimit(self,
                fp,
                fn,
                delta,
                mx_min,
                mx_max,
                num_steps,
                output_file,
                processes=None):
     """ Computes the upper limit in cross-section as a function of DM mass mx.
     Input:
         fp, fn: float
             Couplings to proton and neutron.
         delta: float
             DM mass split.
         mx_min, mx_max: float
             Minimum and maximum DM mass.
         num_steps: int
             Number of steps in the range of DM mass values.
         output_file: string
             Name of output file where the result will be printed.
     Returns:
         upperlimit: ndarray
             Table with the first row giving the base-10 log of the DM mass, and
             the second row giving the base-10 log of the upper limit in cross-section.
     """
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     kwargs = ({
         'mx': mx,
         'fp': fp,
         'fn': fn,
         'delta': delta
     } for mx in mx_list)
     upper_limit = np.array(
         par.parmap(self._PoissonUpperBoundSHM, kwargs, processes))
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     upper_limit = 1 / conversion_factor * mx_list * upper_limit
     result = np.log10(np.transpose([mx_list, upper_limit]))
     result = result[result[:, 1] != np.inf]
     with open(output_file, 'ab') as f_handle:
         np.savetxt(f_handle, result)
     return result
示例#9
0
 def UpperLimit(self,
                fp,
                fn,
                delta,
                mx_min,
                mx_max,
                num_steps,
                output_file,
                processes=None):
     mx_list = np.logspace(np.log10(mx_min), np.log10(mx_max), num_steps)
     kwargs = ({
         'mx': mx,
         'fp': fp,
         'fn': fn,
         'delta': delta,
         'output_file': output_file
     } for mx in mx_list)
     upper_limit = np.array(par.parmap(self.RegionSHM, kwargs, processes))
     print("mx_list = ", mx_list)
     print("upper_limit = ", upper_limit)
     return upper_limit
示例#10
0
    def UpperLowerLists(self,
                        CL,
                        output_file,
                        output_file_lower,
                        output_file_upper,
                        num_mx=1000,
                        processes=None):
        print('CL =', CL, 'chi2 =', chi_squared(2, CL))
        self.logL_target = self.logL_max - chi_squared(2, CL) / 2

        table = np.transpose(np.loadtxt(output_file))
        num_dimensions = table.shape[0]
        num_bins = (num_dimensions - 3) // 3
        print('num_dimensions =', num_dimensions)
        print('num_bins =', num_bins)
        mx_list = table[0]
        sigma_fit_interp = interpolate.interp1d(mx_list, table[1])
        log_likelihood_max_interp = interpolate.interp1d(mx_list, table[2])

        predicted_interp = [
            interpolate.interp1d(mx_list, table[i])
            for i in range(3, 3 + num_bins)
        ]
        data_interp = [
            interpolate.interp1d(mx_list, table[i])
            for i in range(3 + num_bins, 3 + 2 * num_bins)
        ]
        error_interp = [
            interpolate.interp1d(mx_list, table[i])
            for i in range(3 + 2 * num_bins, 3 + 3 * num_bins)
        ]

        mx_list = np.logspace(np.log10(mx_list[0]),
                              np.log10(mx_list[-1]),
                              num=num_mx)

        sigma_fit = np.array([sigma_fit_interp(mx) for mx in mx_list])
        logL_max = np.array([log_likelihood_max_interp(mx) for mx in mx_list])
        predicted = np.array([[p(mx) for p in predicted_interp]
                              for mx in mx_list])
        data = np.array([[d(mx) for d in data_interp] for mx in mx_list])
        error = np.array([[err(mx) for err in error_interp] for mx in mx_list])

        kwargs = ({
            'mx': mx_list[index],
            'logL_max': logL_max[index],
            'sigma': sigma_fit[index],
            'pred': predicted[index],
            'data': data[index],
            'err': error[index]
        } for index in range(len(mx_list)))
        limits = [
            l for l in par.parmap(self._UpperLowerLists,
                                  kwargs,
                                  processes=processes,
                                  verbose=False) if l
        ]
        if limits:
            limits = np.transpose(limits, axes=(1, 0, 2))
            limit_low = limits[0]
            limit_high = limits[1]
        else:
            limit_low = limit_high = []
        return [np.array(limit_low), np.array(limit_high)]