Ejemplo n.º 1
0
    def _init_header(self, path):
        config = _load_config(path)
        metadata = config['metadata']
        header = Stats()
        config_key = self._config['header_sampling_rate_key']
        try:
            header.sampling_rate = float(metadata[config_key])
        except KeyError:
            raise KeyError("The following key was not found in the metadata: " +
                           "{}. Did you set the correct ".format(config_key) +
                           "'sample rate metadata key' in PAL H5 Output module?")
        header.npts = int(metadata[self._config['header_samples_per_record_key']]) - 1
        try:
            if self._config['dd_300']:
                header.calib = metadata['dd_300_calibration']
            elif self._config['dd_900']:
                header.calib = metadata['dd_900_calibration']
            elif self._config['vd_08']:
                header.calib = metadata['vd_08_calibration']
            elif self._config['vd_09']:
                header.calib = metadata['vd_09_calibration']
        except KeyError:
            pass
        header.comments = str(config['comments'])
        header.place = metadata

        if self._config['header_extra1_name'] != '' and self._config['header_extra1_val'] != '':
            header[self._config['header_extra1_name']] = self._config['header_extra1_val']
        if self._config['header_extra2_name'] != '' and self._config['header_extra2_val'] != '':
            header[self._config['header_extra2_name']] = self._config['header_extra2_val']
        return header
Ejemplo n.º 2
0
    def _init_header(self, path):
        config = _load_config(path)
        metadata = config['metadata']
        header = Stats()

        if 'ATS9440' in config['plugins'].keys():
            ats_config = config['plugins']['ATS9440']['config']
        elif 'ATS660' in config['plugins'].keys():
            ats_config = config['plugins']['ATS660']['config']
        else:
            raise KeyError('Cannot locate trace config data')

        if 'Polytec' in config['plugins'].keys():
            polytec_config = config['plugins']['Polytec']['config']
        else:
            raise KeyError('Cannot locate vibrometer config data')

        header.sampling_rate = _calc_sampling_rate(ats_config['sample_rate'])
        header.npts = int(ats_config['pre_trigger_samples'] +
                          ats_config['post_trigger_samples']) - 1

        if polytec_config['dd_300']:
            header.calib = float(
                re.findall(_NUMBER, polytec_config['dd_300_range'])[0])
        elif polytec_config['dd_900']:
            header.calib = float(
                re.findall(_NUMBER, polytec_config['dd_900_range'])[0])
        elif polytec_config['vd_08']:
            header.calib = float(
                re.findall(_NUMBER, polytec_config['vd_08_range'])[0])
        elif polytec_config['vd_09']:
            header.calib = float(
                re.findall(_NUMBER, polytec_config['vd_09_range'])[0])
        else:
            raise KeyError('Cannot locate vibrometer calibration data')

        header.comments = str(config['comments'])
        header.place = metadata

        if self._config['header_extra1_name'] != '' and self._config[
                'header_extra1_val'] != '':
            header[self._config['header_extra1_name']] = self._config[
                'header_extra1_val']
        if self._config['header_extra2_name'] != '' and self._config[
                'header_extra2_val'] != '':
            header[self._config['header_extra2_name']] = self._config[
                'header_extra2_val']
        return header
Ejemplo n.º 3
0
    def _init_header(self, path):
        config = _load_config(path)
        metadata = config['metadata']
        header = Stats()

        if 'ATS9440' in config['plugins'].keys():
            ats_config = config['plugins']['ATS9440']['config']
        elif 'ATS660' in config['plugins'].keys():
            ats_config = config['plugins']['ATS660']['config']
        else:
            raise KeyError('Cannot locate trace config data')

        if 'Polytec' in config['plugins'].keys():
            polytec_config = config['plugins']['Polytec']['config']
        else:
            raise KeyError('Cannot locate vibrometer config data')

        header.sampling_rate = _calc_sampling_rate(ats_config['sample_rate'])
        header.npts = int(ats_config['pre_trigger_samples'] +
                          ats_config['post_trigger_samples']) - 1

        if polytec_config['dd_300']:
            header.calib = float(re.findall(
                _NUMBER, polytec_config['dd_300_range'])[0])
        elif polytec_config['dd_900']:
            header.calib = float(re.findall(
                _NUMBER, polytec_config['dd_900_range'])[0])
        elif polytec_config['vd_08']:
            header.calib = float(re.findall(
                _NUMBER, polytec_config['vd_08_range'])[0])
        elif polytec_config['vd_09']:
            header.calib = float(re.findall(
                _NUMBER, polytec_config['vd_09_range'])[0])
        else:
            raise KeyError('Cannot locate vibrometer calibration data')

        header.comments = str(config['comments'])
        header.place = metadata

        if self._config['header_extra1_name'] != '' and self._config['header_extra1_val'] != '':
            header[self._config['header_extra1_name']
                   ] = self._config['header_extra1_val']
        if self._config['header_extra2_name'] != '' and self._config['header_extra2_val'] != '':
            header[self._config['header_extra2_name']
                   ] = self._config['header_extra2_val']
        return header