예제 #1
0
    def augment_csdata(self, csdata, outdir, title, units_e, units_sigma,
                       augment_dicts=None, debug=False, test=False):

        check_process_attr = ['lhs', 'rhs', 'lhs_hv', 'rhs_hv',
                              'lhs_v', 'rhs_v', 'lhs_j', 'rhs_j']
        for cs in csdata:
            cs['metadata']['nepc_filename'] = outdir + '/' + title + '_' + cs['metadata']['file_suffix']

            process_attr_values = nepc.process_attr(cs['metadata']['process'],
                                                    check_process_attr, test)

            process_attr_keys = {'lhs': ['lhs_a', 'lhs_b'],
                                 'rhs': ['rhs_a', 'rhs_b'],
                                 'lhs_v': ['lhs_v'],
                                 'rhs_v': ['rhs_v'],
                                 'lhs_hv': ['lhs_hv'],
                                 'rhs_hv': ['rhs_hv'],
                                 'lhs_j': ['lhs_j'],
                                 'rhs_j': ['rhs_j']}

            for _, (key, value) in enumerate(process_attr_keys.items()):
                if sum(k in cs['metadata'].keys() for k in value) != process_attr_values[key]:
                    raise Exception(f"Mismatch in cs['metadata'] for {key} in {cs['metadata']['file_suffix']}.")
                for v in value:
                    cs['metadata'][v] = self.value(cs['metadata'], v)
예제 #2
0
    def augment_csdata(self, csdata, outdir, title, units_e, units_sigma,
                       augment_dicts=None, debug=False, test=False):

        csdata_augmented = csdata
        
        csdata_augmented['nepc_filename'] = outdir + '/' + title

        check_process_attr = ['lhs', 'rhs', 'lhs_hv', 'rhs_hv',
                              'lhs_v', 'rhs_v', 'lhs_j', 'rhs_j']

        process_attr_values = nepc.process_attr(augment_dicts['process'],
                                                check_process_attr, test)

        process_attr_keys = {'lhs': ['lhs_a', 'lhs_b'],
                             'rhs': ['rhs_a', 'rhs_b'],
                             'lhs_v': ['lhs_v'],
                             'rhs_v': ['rhs_v'],
                             'lhs_hv': ['lhs_hv'],
                             'rhs_hv': ['rhs_hv'],
                             'lhs_j': ['lhs_j'],
                             'rhs_j': ['rhs_j']}

        for _, (key, value) in enumerate(process_attr_keys.items()):
            for v in value:
                csdata_augmented[v] = self.value(csdata_augmented, v)
            if sum(k in augment_dicts.keys() for k in value) != process_attr_values[key]:
                raise Exception(f'Mismatch in augment_dicts for {key}')

        for _, (key, value) in enumerate(augment_dicts.items()):
            csdata_augmented[key] = value
            if debug:
                print(f'csdata_augmented[{key}]: {csdata_augmented[key]}')

        return csdata_augmented
예제 #3
0
    def augment_csdata(self, csdata, outdir, title, units_e, units_sigma,
                       augment_dicts=None, debug=False, test=False):

        consolidated_metadata = ['ref']
        matched_metadata = ['specie', 'units_e', 'units_sigma']
        self.check_for_unmatched_metadata(csdata, matched_metadata)

        csdata_lumped = self.lump(csdata)
        csdata_lumped['nepc_filename'] = outdir + '/' + title

        check_process_attr = ['lhs', 'rhs', 'lhs_hv', 'rhs_hv',
                              'lhs_v', 'rhs_v', 'lhs_j', 'rhs_j']

        process_attr_values = nepc.process_attr(augment_dicts['process'],
                                                check_process_attr, test)

        process_attr_keys = {'lhs': ['lhs_a', 'lhs_b'],
                             'rhs': ['rhs_a', 'rhs_b'],
                             'lhs_v': ['lhs_v'],
                             'rhs_v': ['rhs_v'],
                             'lhs_hv': ['lhs_hv'],
                             'rhs_hv': ['rhs_hv'],
                             'lhs_j': ['lhs_j'],
                             'rhs_j': ['rhs_j']}

        for _, (key, value) in enumerate(process_attr_keys.items()):
            for v in value:
                csdata_lumped[v] = self.value(csdata_lumped, v)
            if sum(k in augment_dicts.keys() for k in value) != process_attr_values[key]:
                raise Exception(f'Mismatch in augment_dicts for {key}')

        for key in matched_metadata + consolidated_metadata:
            csdata_lumped[key] = ','.join(self.unique_metadata(csdata, key))
            if debug:
                print(f'csdata_lumped[{key}]: {csdata_lumped[key]}')

        for _, (key, value) in enumerate(augment_dicts.items()):
            csdata_lumped[key] = value
            if debug:
                print(f'csdata_lumped[{key}]: {csdata_lumped[key]}')

        return csdata_lumped