Beispiel #1
0
    def getTrace(self):

        if self.trace is not None:
            return self.trace

        msrecord_py = self.getMSRecord()
        #print "DEBUG: msrecord_py:", msrecord_py
        header = _convertMSRToDict(msrecord_py)
        # 20111201 AJL - bug fix?
        header['starttime'] = header['starttime'] / HPTMODULUS
        # 20111205 AJL - bug fix?
        if 'samprate' in header:
            header['sampling_rate'] = header['samprate']
            del header['samprate']
        # Access data directly as NumPy array.
        data = _ctypesArray2NumpyArray(msrecord_py.datasamples,
                                       msrecord_py.numsamples,
                                       msrecord_py.sampletype)
        self.trace = Trace(data, header)
        return self.trace
Beispiel #2
0
    def getTrace(self):

        if self.trace is not None:
            return self.trace

        msrecord_py = self.getMSRecord()
        # print "DEBUG: msrecord_py:", msrecord_py
        header = _convertMSRToDict(msrecord_py)

        # XXX Workaround: the fields in the returned struct of type
        # obspy.mseed.header.MSRecord_s have byte values in Python 3, while
        # the rest of the code still expects them to be string (see #770)
        # -> convert
        convert = ('network', 'station', 'location', 'channel',
                   'dataquality', 'sampletype')
        for key, value in header.items():
            if key in convert and not isinstance(value, str):
                header[key] = value.decode()

        # 20111201 AJL - bug fix?
        header['starttime'] = header['starttime'] / HPTMODULUS
        # 20111205 AJL - bug fix?
        if 'samprate' in header:
            header['sampling_rate'] = header['samprate']
            del header['samprate']
        # Access data directly as NumPy array.

        # XXX Workaround: in Python 3 msrecord_py.sampletype is a byte
        # (e.g. b'i'), while keys of mseed.headers.SAMPLESIZES are
        # unicode ('i') (see above)
        sampletype = msrecord_py.sampletype
        if not isinstance(sampletype, str):
            sampletype = sampletype.decode()

        data = _ctypesArray2NumpyArray(msrecord_py.datasamples,
                                       msrecord_py.numsamples,
                                       sampletype)
        self.trace = Trace(data, header)
        return self.trace