Esempio n. 1
0
    def produce(self, spectrum):
        bin_boundaries = spectrum.binning()
        n_bins = len(bin_boundaries) - 1

        row = newtables.BaseRow()
        row.append(newtables.CellString(spectrum.latex_title))

        i_left = self.binning.index(bin_boundaries[0])
        i_right = self.binning.index(bin_boundaries[-1])

        for i in xrange(i_left):
            row.append(newtables.CellString('-'))

        if self.normalize: incl_xs = self.get_incl_xs(spectrum)

        for i_scan, scan in enumerate(spectrum.scans):
            left = bin_boundaries[i_scan]
            right = bin_boundaries[i_scan + 1]

            up = scan.unc.right_error
            down = scan.unc.left_error

            cell = CellSymmRelativeUncs(-abs(down), up)
            cell.span = self.binning.index(right) - self.binning.index(left)

            row.append(cell)

        for i in xrange(i_right, n_bins):
            row.append(newtables.CellString('-'))

        return row
Esempio n. 2
0
    def produce_from_hist(self, H):
        row = newtables.BaseRow()
        row.append(newtables.CellString(H.title))

        for i in xrange(H.n_bins):
            cell = CellSymmRelativeUncs(-abs(H.errs_down[i]), H.errs_up[i])
            row.append(cell)

        return row
Esempio n. 3
0
 def produce_binning_row(self, title=''):
     self.int_binning_where_possible()
     row = newtables.BaseRow()
     row.append(newtables.CellString(title))
     for left, right in zip(self.binning[:-1], self.binning[1:]):
         if right == 10000. or (self.last_bin_is_overflow
                                and right == self.binning[-1]):
             row.append(newtables.CellString('$>${0}'.format(left)))
         else:
             row.append(newtables.CellString('{0}-{1}'.format(left, right)))
     return row
Esempio n. 4
0
    def produce(self, spectrum):
        bin_boundaries = spectrum.binning()
        n_bins = len(bin_boundaries) - 1

        row = newtables.BaseRow()
        row.append(newtables.CellString(spectrum.latex_title))

        if self.do_xs:
            CellAsymmUncCrossSection.scientific_notation = True
            CellAsymmUncCrossSection.n_decimals = 3

        i_left = self.binning.index(bin_boundaries[0])
        i_right = self.binning.index(bin_boundaries[-1])

        for i in xrange(i_left):
            row.append(newtables.CellString('-'))

        if self.normalize: incl_xs = self.get_incl_xs(spectrum)

        for i_scan, scan in enumerate(spectrum.scans):
            left = bin_boundaries[i_scan]
            right = bin_boundaries[i_scan + 1]

            center = scan.unc.x_min
            up = scan.unc.right_error
            down = scan.unc.left_error

            if self.do_xs:
                xs = spectrum.smxs[i_scan]
                bin_width = right - left
                if self.normalize:
                    center *= xs * bin_width / incl_xs
                    up *= xs * bin_width / incl_xs
                    down *= xs * bin_width / incl_xs
                else:
                    center *= xs
                    up *= xs
                    down *= xs

            cell = CellAsymmUncCrossSection(center, up, -abs(down))
            cell.span = self.binning.index(right) - self.binning.index(left)

            row.append(cell)

        for i in xrange(i_right, n_bins):
            row.append(newtables.CellString('-'))

        return row
Esempio n. 5
0
 def produce_row_given_labels(self, labels):
     row = newtables.BaseRow()
     for label in labels:
         row.append(newtables.CellString(label))
     return row