def readGSE1(filename, headonly=False, verify_chksum=True, **kwargs): # @UnusedVariable """ Reads a GSE1 file and returns a Stream object. GSE1 files containing multiple WID1 entries/traces are supported. .. warning:: This function should NOT be called directly, it registers via the ObsPy :func:`~obspy.core.stream.read` function, call this instead. :type filename: string :type param: GSE2 file to be read. :type headonly: boolean, optional :param headonly: If True read only header of GSE1 file. :type verify_chksum: boolean, optional :param verify_chksum: If True verify Checksum and raise Exception if it is not correct. :rtype: :class:`~obspy.core.stream.Stream` :returns: Stream object containing header and data. .. rubric:: Example >>> from obspy.core import read >>> st = read("/path/to/y2000.gse") """ traces = [] # read GSE1 file fh = open(filename, 'rb') while True: try: if headonly: header = libgse1.readHeader(fh) traces.append(Trace(header=header)) else: header, data = libgse1.read(fh, verify_chksum=verify_chksum) traces.append(Trace(header=header, data=data)) except EOFError: break fh.close() return Stream(traces=traces)
def test_verifyChecksums(self): """ Tests verifying checksums for CM6 encoded GSE1 files. """ # 1 fh = open(os.path.join(self.path, "acc.gse"), "rb") libgse1.read(fh, verify_chksum=True) fh.close() # 2 fh = open(os.path.join(self.path, "y2000.gse"), "rb") libgse1.read(fh, verify_chksum=True) fh.close() # 3 fh = open(os.path.join(self.path, "loc_STAU20031119011659.z"), "rb") libgse1.read(fh, verify_chksum=True) fh.close() # 4 - second checksum is wrong fh = open(os.path.join(self.path, "GRF_031102_0225.GSE.wrong_chksum"), "rb") libgse1.read(fh, verify_chksum=True) # correct self.assertRaises(ChksumError, libgse1.read, fh, verify_chksum=True) fh.close()
def test_verifyChecksums(self): """ Tests verifying checksums for CM6 encoded GSE1 files. """ #1 fh = open(os.path.join(self.path, 'acc.gse'), 'rb') libgse1.read(fh, verify_chksum=True) fh.close() #2 fh = open(os.path.join(self.path, 'y2000.gse'), 'rb') libgse1.read(fh, verify_chksum=True) fh.close() #3 fh = open(os.path.join(self.path, 'loc_STAU20031119011659.z'), 'rb') libgse1.read(fh, verify_chksum=True) fh.close() #4 - second checksum is wrong fh = open(os.path.join(self.path, 'GRF_031102_0225.GSE.wrong_chksum'), 'rb') libgse1.read(fh, verify_chksum=True) # correct self.assertRaises(ChksumError, libgse1.read, fh, verify_chksum=True) fh.close()