def test_isMSEED(self): """ This tests the isMSEED method by just validating that each file in the data directory is a Mini-SEED file and each file in the working directory is not a Mini-SEED file. The filenames are hard coded so the test will not fail with future changes in the structure of the package. """ # Mini-SEED filenames. mseed_filenames = ['BW.BGLD.__.EHE.D.2008.001.first_10_records', 'gaps.mseed', 'qualityflags.mseed', 'test.mseed', 'timingquality.mseed'] # Non Mini-SEED filenames. non_mseed_filenames = ['test_mseed_reading_and_writing.py', '__init__.py'] # Loop over Mini-SEED files for _i in mseed_filenames: filename = os.path.join(self.path, 'data', _i) is_mseed = isMSEED(filename) self.assertTrue(is_mseed) # Loop over non Mini-SEED files for _i in non_mseed_filenames: filename = os.path.join(self.path, _i) is_mseed = isMSEED(filename) self.assertFalse(is_mseed)
def test_isValidMSEED(self): """ Tests isMSEED functionality. """ # fullseed starting with blockette 010 file = os.path.join(self.path, 'data', 'fullseed.mseed') self.assertTrue(isMSEED(file)) # fullseed starting with blockette 008 file = os.path.join(self.path, 'data', 'blockette008.mseed') self.assertTrue(isMSEED(file)) # fullseed not starting with blockette 010 or 008 file = os.path.join(self.path, 'data', 'fullseed.mseed') self.assertTrue(isMSEED(file))
def test_isInvalidMSEED(self): """ Tests isMSEED functionality. """ # invalid blockette length in first blockette file = os.path.join(self.path, 'data', 'not.mseed') self.assertFalse(isMSEED(file)) # just "000001V" file = os.path.join(self.path, 'data', 'not2.mseed') self.assertFalse(isMSEED(file)) # just "000001V011" file = os.path.join(self.path, 'data', 'not3.mseed') self.assertFalse(isMSEED(file)) # found blockette 010 but invalid record length file = os.path.join(self.path, 'data', 'not4.mseed') self.assertFalse(isMSEED(file))
def make_irisrequest(station, begin, end, channel, loc): print 'IRISREQUEST FOR STATION ', station net, sta = station.split('_') url = 'http://service.iris.edu/fdsnws/dataselect/1/query?' st = Stream() for i in channel: parameter = urllib.urlencode({ 'net': net, 'sta': sta, 'loc': loc, #'cha': i, #hs v2 'starttime': begin, 'endtime': end, 'nodata': '404', }) u = ('%s%s') % (url, parameter) saveUrl(station, u) #data = urllib.urlopen(u).read() #hs try: data = urllib.urlopen(u).read() #hs except: continue #tf = NamedTemporaryFile() #hs tf = NamedTemporaryFile(suffix='xtmp') #hs tf.write(data) tf.seek(0) t = isMSEED(tf.name) if t == True: st += read(tf.name, 'MSEED') tf.close() os.remove(tf.name) break #hs v2 # if t == True: size = proof_file_v3 (st,channel) #hs if len(st) > 0: size = proof_file_v3(st, channel) #hs else: size = 0 print 'SIZE: ----> ', size return size