Пример #1
0
 def options(cls):
     options = ArrayWriter.options()
     options['pack'] = Option('pack', type=bool, default=False, required=False,
                              help=('If specified, dependent variables will be put in one table, instead of creating one '
                                    'table per dependent variable in CSV file'))
     options['separator'] = Option('separator', type=str, default=',', required=False,
                                   help='Defines separator for CSV file, the default is comma: ","')
     
     return options
Пример #2
0
 def options(cls):
     options = ArrayWriter.options()
     options['rivet_analysis_name'] = Option(
         'rivet-analysis-name',
         'r',
         type=str,
         default='RIVET_ANALYSIS_NAME',
         required=False,
         variable_mapping='rivet_analysis_name',
         help='Rivet analysis name, e.g. "ATLAS_2016_I1424838"')
     return options
Пример #3
0
    def options(cls):
        options = ArrayWriter.options()
        options['pack'] = Option(
            'pack',
            type=bool,
            default=False,
            required=False,
            help=
            ('If specified, dependent variables will be put in one table, instead of creating one '
             'table per dependent variable in CSV file'))
        options['separator'] = Option(
            'separator',
            type=str,
            default=',',
            required=False,
            help='Defines separator for CSV file, the default is comma: ","')

        return options
Пример #4
0
    def create_objects(self):
        self.calculate_total_errors()

        error_hists = []
        error_labels = {}
        error_indices = {}
        index = 0

        is_number_list = self.is_number_var(self.dependent_variable)

        for i, value in enumerate(self.dependent_variable.get('values', [])):

            if not is_number_list[i]: continue  # skip non-numeric y values

            # process the error labels to ensure uniqueness
            ArrayWriter.process_error_labels(value)

            for error in value.get('errors', []):
                if 'label' not in error:
                    error['label'] = 'error'
                label = error['label']
                if label not in error_labels:
                    index += 1
                    error_indices[index] = label
                if 'symerror' in error and label not in error_labels:
                    error_labels[label] = 'symerror'
                elif 'asymerror' in error and error_labels.get(
                        label, 'symerror') == 'symerror':
                    error_labels[label] = 'asymerror'

        yvals = []
        for index in range(1, len(error_labels) + 1):
            error_label = error_indices[index]
            if error_labels[error_label] == 'asymerror':
                yval_plus_label = error_label + '_plus'
                yval_plus = []
                yval_minus_label = error_label + '_minus'
                yval_minus = []

                for i, value in enumerate(
                        self.dependent_variable.get('values', [])):
                    if not is_number_list[i]:
                        continue  # skip non-numeric y values
                    error = [
                        x for x in value.get('errors', [])
                        if x.get('label') == error_label
                    ]
                    if len(error) == 0:
                        yval_plus.append(0.0)
                        yval_minus.append(0.0)
                    elif 'symerror' in error[0]:
                        err_val = error_value_processor(
                            value['value'], error[0]['symerror'])
                        yval_plus.append(err_val)
                        yval_minus.append(-err_val)
                    elif 'asymerror' in error[0]:
                        err_plus = error_value_processor(
                            value['value'], error[0]['asymerror']['plus'])
                        err_min = error_value_processor(
                            value['value'], error[0]['asymerror']['minus'])
                        yval_plus.append(err_plus)
                        yval_minus.append(err_min)
                    else:
                        yval_plus.append(0.0)
                        yval_minus.append(0.0)

                yvals += [
                    (yval_plus_label, yval_plus, '%s%s' % (index, 'plus')),
                    (yval_minus_label, yval_minus, '%s%s' % (index, 'minus'))
                ]
            else:
                yval = []

                for i, value in enumerate(
                        self.dependent_variable.get('values', [])):
                    if not is_number_list[i]:
                        continue  # skip non-numeric y values
                    error = [
                        x for x in value.get('errors', [])
                        if x.get('label') == error_label
                    ]
                    if len(error) == 0:
                        yval.append(0.0)
                    elif 'symerror' in error[0]:
                        err_val = error_value_processor(
                            value['value'], error[0]['symerror'])
                        yval.append(err_val)
                    else:
                        yval.append(0.0)

                yvals += [(error_label, yval, index)]

        for name, vals, index in yvals:
            try:
                error_hists.append(self._create_empty_hist(name, index, vals))
            except:
                log.error("Failed to create empty histogram")

        xval = []
        for i in range(self.dim):
            xval.append([])
            i_var = self.independent_variables[i]['values']
            for ix, x in enumerate(i_var):
                if not is_number_list[
                        ix] and 'labels' not in self.independent_variables[i]:
                    continue  # skip defining bins for non-numeric y values unless alphanumeric bin labels are present
                if x['low'] not in xval[i]:
                    xval[i].append(x['low'])
                if x['high'] not in xval[i]:
                    xval[i].append(x['high'])

        try:
            hist = self._create_hist(xval)
        except:
            log.error("Failed to create histogram")
            return [] + error_hists

        return [hist] + error_hists
Пример #5
0
 def options(cls):
     options = ArrayWriter.options()
     options['rivet_analysis_name'] = Option('rivet-analysis-name', 'r', type=str, default='RIVET_ANALYSIS_NAME',
                                             required=False, variable_mapping='rivet_analysis_name',
                                             help='Rivet analysis name, e.g. "ATLAS_2016_I1424838"')
     return options