Coverage for /opt/obspy/update-docs/src/obspy/obspy/mseed/msstruct : 83%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- Convenience class for handling MSRecord and MSFileparam. """
""" Takes a Mini-SEED filename as an argument and returns a dictionary with some basic information about the file. Also suitable for Full SEED.
This is an exact copy of a method of the same name in utils. Due to circular imports this method cannot be import from utils. XXX: Figure out a better way!
:param f: File pointer of opened file in binary format :param real_name: Realname of the file, needed for calculating size """ # get size of file # Calculate Number of Records info['record_length'])
""" Class for handling MSRecord and MSFileparam.
It consists of a MSRecord and MSFileparam and an attached python file pointer.
:ivar msr: MSRecord :ivar msf: MSFileparam :ivar file: filename :ivar offset: Current offset
:param filename: file to attach to :param init_msrmsf: initialize msr and msf structure by a first pass of read. Setting this option to false will result in errors when setting e.g. the offset before a call to read """ # Initialize MSRecord structure # dummy read once, to avoid null pointer in ms.msf for e.g. # ms.offset
""" Return endtime """ self.read(-1, 0, 1, 0) dtime = clibmseed.msr_endtime(self.msr) return UTCDateTime(dtime / HPTMODULUS)
""" Return starttime """ self.read(-1, 0, 1, 0) dtime = clibmseed.msr_starttime(self.msr) return UTCDateTime(dtime / HPTMODULUS)
""" For details see util._getMSFileInfo """
""" Return byte position of file given a certain record_number.
The byte position can be used to seek to certain points in the file """ # Calculate offset of the record to be read. record_number >= self.info['number_of_records']: raise ValueError('Please enter a valid record_number')
raise_flag=True): """ Read MSRecord using the ms_readmsr_r function. The following parameters are directly passed to ms_readmsr_r.
:param ms: _MSStruct (actually consists of a LP_MSRecord, LP_MSFileParam and an attached file pointer). Given an existing ms the function is much faster. :param reclen: If reclen is 0 the length of the first record is auto- detected. All subsequent records are then expected to have the same record length. If reclen is negative the length of every record is automatically detected. Defaults to -1. :param dataflag: Controls whether data samples are unpacked, defaults to 1. :param skipnotdata: If true (not zero) any data chunks read that to do not have valid data record indicators will be skipped. Defaults to True (1). :param verbose: Controls verbosity from 0 to 2. Defaults to None (0). :param record_number: Number of the record to be read. The first record has the number 0. Negative numbers will start counting from the end of the file, e.g. -1 is the last complete record. """ C.pointer(self.msr), self.file, reclen, None, None, skipnotdata, dataflag, verbose) raise Exception("Error %d in ms_readmsr_r" % errcode)
""" Method for deallocating MSFileParam and MSRecord structure. """ C.pointer(self.msr), None, -1, None, None, 0, 0, 0) raise Exception("Error %d in ms_readmsr_r" % errcode)
return int(self.msf.contents.readoffset)
|