Пример #1
0
    def read_analogsignal(self, path=None, lazy=False):
        assert not lazy, 'This IO does not support lazy mode'

        if not HAVE_IGOR:
            raise Exception("`igor` package not installed. "
                            "Try `pip install igor`")
        if self.extension == 'ibw':
            data = bw.load(str(self.filename))
            version = data['version']
            if version > 5:
                raise IOError("Igor binary wave file format version {} "
                              "is not supported.".format(version))
        elif self.extension == 'pxp':
            assert type(path) is str, \
                "A colon-separated Igor-style path must be provided."
            if not self._filesystem:
                _, self.filesystem = pxp.load(str(self.filename))
                path = path.split(':')
                location = self.filesystem['root']
                for element in path:
                    if element != 'root':
                        location = location[element.encode('utf8')]
            data = location.wave

        return self._wave_to_analogsignal(data['wave'], [])
Пример #2
0
    def read_analogsignal(self, path=None, lazy=False):
        assert not lazy, 'Do not support lazy'

        if not HAVE_IGOR:
            raise Exception(("`igor` package not installed. "
                             "Try `pip install igor`"))
        if self.extension == 'ibw':
            data = bw.load(self.filename)
            version = data['version']
            if version > 5:
                raise IOError(("Igor binary wave file format version {0} "
                               "is not supported.".format(version)))
        elif self.extension == 'pxp':
            assert type(path) is str, \
                "A colon-separated Igor-style path must be provided."
            _, filesystem = pxp.load(self.filename)
            path = path.split(':')
            location = filesystem['root']
            for element in path:
                if element != 'root':
                    location = location[element.encode('utf8')]
            data = location.wave
        content = data['wave']
        if "padding" in content:
            assert content['padding'].size == 0, \
                "Cannot handle non-empty padding"
        signal = content['wData']
        note = content['note']
        header = content['wave_header']
        name = str(header['bname'].decode('utf-8'))
        units = "".join([x.decode() for x in header['dataUnits']])
        try:
            time_units = "".join([x.decode() for x in header['xUnits']])
            assert len(time_units)
        except:
            time_units = "s"
        try:
            t_start = pq.Quantity(header['hsB'], time_units)
        except KeyError:
            t_start = pq.Quantity(header['sfB'][0], time_units)
        try:
            sampling_period = pq.Quantity(header['hsA'], time_units)
        except:
            sampling_period = pq.Quantity(header['sfA'][0], time_units)
        if self.parse_notes:
            try:
                annotations = self.parse_notes(note)
            except ValueError:
                warn("Couldn't parse notes field.")
                annotations = {'note': note}
        else:
            annotations = {'note': note}

        signal = AnalogSignal(signal, units=units, copy=False, t_start=t_start,
                              sampling_period=sampling_period, name=name,
                              file_origin=self.filename, **annotations)
        return signal
Пример #3
0
    def read_analogsignal(self, path=None, lazy=False):
        assert not lazy, 'Do not support lazy'

        if not HAVE_IGOR:
            raise Exception(("`igor` package not installed. "
                             "Try `pip install igor`"))
        if self.extension == 'ibw':
            data = bw.load(self.filename)
            version = data['version']
            if version > 5:
                raise IOError(("Igor binary wave file format version {0} "
                               "is not supported.".format(version)))
        elif self.extension == 'pxp':
            assert type(path) is str, \
                "A colon-separated Igor-style path must be provided."
            _, filesystem = pxp.load(self.filename)
            path = path.split(':')
            location = filesystem['root']
            for element in path:
                if element != 'root':
                    location = location[element.encode('utf8')]
            data = location.wave
        content = data['wave']
        if "padding" in content:
            assert content['padding'].size == 0, \
                "Cannot handle non-empty padding"
        signal = content['wData']
        note = content['note']
        header = content['wave_header']
        name = str(header['bname'].decode('utf-8'))
        units = "".join([x.decode() for x in header['dataUnits']])
        try:
            time_units = "".join([x.decode() for x in header['xUnits']])
            assert len(time_units)
        except:
            time_units = "s"
        try:
            t_start = pq.Quantity(header['hsB'], time_units)
        except KeyError:
            t_start = pq.Quantity(header['sfB'][0], time_units)
        try:
            sampling_period = pq.Quantity(header['hsA'], time_units)
        except:
            sampling_period = pq.Quantity(header['sfA'][0], time_units)
        if self.parse_notes:
            try:
                annotations = self.parse_notes(note)
            except ValueError:
                warn("Couldn't parse notes field.")
                annotations = {'note': note}
        else:
            annotations = {'note': note}

        signal = AnalogSignal(signal, units=units, copy=False, t_start=t_start,
                              sampling_period=sampling_period, name=name,
                              file_origin=self.filename, **annotations)
        return signal
Пример #4
0
def run(args):
    records,filesystem = load(args.infile)
    if hasattr(args.outfile, 'write'):
        f = args.outfile  # filename is actually a stream object
    else:
        f = open(args.outfile, 'w')
    try:
        f.write(pprint.pformat(records))
        f.write('\n')
    finally:
        if f != args.outfile:
            f.close()
    if args.verbose > 0:
        pprint.pprint(filesystem)
Пример #5
0
 def _run(self, args):
     self.args = args
     records, filesystem = load(args.infile)
     if hasattr(args.outfile, 'write'):
         f = args.outfile  # filename is actually a stream object
     else:
         f = open(args.outfile, 'w')
     try:
         f.write(pprint.pformat(records))
         f.write('\n')
     finally:
         if f != args.outfile:
             f.close()
     if args.verbose > 0:
         pprint.pprint(filesystem)
     walk(filesystem, self._plot_wave_callback)
Пример #6
0
 def _run(self, args):
     self.args = args
     records,filesystem = load(args.infile)
     if hasattr(args.outfile, 'write'):
         f = args.outfile  # filename is actually a stream object
     else:
         f = open(args.outfile, 'w')
     try:
         f.write(pprint.pformat(records))
         f.write('\n')
     finally:
         if f != args.outfile:
             f.close()
     if args.verbose > 0:
         pprint.pprint(filesystem)
     walk(filesystem, self._plot_wave_callback)
Пример #7
0
    def read_segment(self, lazy=False):
        assert not lazy, 'This IO does not support lazy mode'
        segment = Segment(file_origin=str(self.filename))

        if self.extension == 'pxp':
            if not self._filesystem:
                _, self.filesystem = pxp.load(str(self.filename))

            def callback(dirpath, key, value):
                if isinstance(value, WaveRecord):
                    signal = self._wave_to_analogsignal(
                        value.wave['wave'], dirpath)
                    signal.segment = segment
                    segment.analogsignals.append(signal)

            pxp.walk(self.filesystem, callback)
        else:
            segment.analogsignals.append(self.read_analogsignal(lazy=lazy))
            segment.analogsignals[-1].segment = segment
        return segment
Пример #8
0
def update():
    qaqc.clearReport()
    f = data.importedFiles()[0].filePath()
    if not f.endswith('pxp'):
        qaqc.pushHtml(
            'This module must be used after importing an iolite 3 experiment. Aborting.'
        )
        qaqc.finished(qaqc.Error)
        return

    d = packed.load(f)[1]

    int_folder = d['root'][b'Packages'][b'iolite'][b'integration']

    matrix_names = [
        s for s in int_folder.keys()
        if s.decode('utf-8').startswith('m_') and s != b'm_Baseline_1'
    ]

    dfi3 = pd.DataFrame()

    for m in matrix_names:
        print('Processing: %s' % (m))
        aim = int_folder[m].wave['wave']['wData']
        labels = int_folder[m].wave['wave']['labels'][1][2:]
        tim = int_folder[m.decode('utf-8').replace(
            'm_', 't_').encode('utf-8')].wave['wave']['wData']
        sns = np.arange(1, aim.shape[0])

        for sn in sns:
            s = pd.Series(aim[sn, 1:, MEAN_INDEX], index=labels)
            s.name = m.decode('utf-8').replace('m_', '') + str(sn)
            print('   %i %s %s' % (sn, s.name, str(s.shape)))
            dfi3 = dfi3.append(s)

    #print('Final df shape %s'%(str(dfi3.shape)))
    #qaqc.pushHtml(dfi3.to_html(col_space=100))

    dfdiff = pd.DataFrame()

    for sg_name in data.selectionGroupNames():
        if 'Baseline' in sg_name or 'NIST610' in sg_name:
            continue

        sg = data.selectionGroup(sg_name)
        seln = 1
        for sel in sg.selections():
            sel_name = sg_name + str(seln)
            s = pd.Series(index=dfi3.columns)
            s.name = sel_name
            for ch_name in dfi3.columns:
                i4_ch_name = ch_name.decode('utf-8')
                if 'SQ' in i4_ch_name:
                    i4_ch_name = i4_ch_name.split("_")[0] + i4_ch_name.split(
                        "_")[3][1:] + "_ppm"
                elif 'ppm' in i4_ch_name:
                    i4_ch_name = i4_ch_name.split("_")[0] + i4_ch_name.split(
                        "_")[2][1:] + "_ppm"
                elif i4_ch_name == 'Final206_238':
                    i4_ch_name = 'Final Pb206/U238'
                elif i4_ch_name == 'Final207_235':
                    i4_ch_name = 'Final Pb207/U235'
                elif i4_ch_name == 'Final207_206':
                    i4_ch_name = 'Final Pb207/Pb206'
                elif i4_ch_name == 'Raw_206_238':
                    i4_ch_name = 'Pb206/U238'
                elif i4_ch_name == 'Raw_207_235':
                    i4_ch_name = 'Pb207/U235'

                try:
                    ch = data.timeSeries(i4_ch_name)
                except RuntimeError:
                    continue

                s[ch_name] = data.result(sel, ch).value()

            dfdiff = dfdiff.append(100 * (dfi3.loc[sel_name, :] - s) /
                                   dfi3.loc[sel_name, :])
            seln += 1

    qaqc.pushHtml('<h3>Percent difference between iolite 3 and 4:</h3>')
    qaqc.pushHtml(dfdiff.to_html(col_space=100))

    qaqc.finished(qaqc.Success)
Пример #9
0
 def __init__(self,pxpfile):
     #include checking...
     #TODO: load pxp or pickled pxp struct...
     self.pstruct=packed.load(pxpfile)