Esempio n. 1
0
def main():
    opts, ifiles = getOptions()
    if opts.s2p:
        print('File conversion: sac --> pkl')
        sac2pkl(ifiles, opts.ofilename, opts.delta, opts.zipmode)
    elif opts.p2s:
        print('File conversion: pkl --> sac')
        filemode, zipmode = fileZipMode(ifiles[0])
        for pkfile in ifiles:
            pkl2sac(pkfile, zipmode)
Esempio n. 2
0
def main():
	opts, ifiles = getOptions()
	if opts.s2p:
		print('File conversion: sac --> pkl')
		sac2pkl(ifiles, opts.ofilename, opts.delta, opts.zipmode)
	elif opts.p2s:
		print('File conversion: pkl --> sac')
		filemode, zipmode = fileZipMode(ifiles[0])
		for pkfile in ifiles:
			pkl2sac(pkfile, zipmode)
Esempio n. 3
0
    def test_pkl2sac(self):
        pkfile = '20120109.04071467.bhz.pkl'
        zipmode = None
        gsac = readPickle(pkfile, zipmode)
        sacdh = gsac.saclist[0]
        dirarr = sacdh.filename.split('/')
        dirname = dirarr[0] + '/' + dirarr[1]

        pkl2sac(pkfile, zipmode)

        #sac is default folder name for sacfiles to be put to
        self.assertTrue(os.path.isdir(dirarr[0]))
        self.assertTrue(os.path.isdir(dirname))
Esempio n. 4
0
    def test_pkl2sac(self):
        pkfile = '20120109.04071467.bhz.pkl'
        zipmode = None
        gsac = readPickle(pkfile, zipmode)
        sacdh = gsac.saclist[0]
        dirarr = sacdh.filename.split('/')
        dirname = dirarr[0]+'/'+dirarr[1]
        
        pkl2sac(pkfile, zipmode)

        #sac is default folder name for sacfiles to be put to
        self.assertTrue(os.path.isdir(dirarr[0]))
        self.assertTrue(os.path.isdir(dirname))
Esempio n. 5
0
class sacpickleModel(unittest.TestCase):

    def test_saveData(self):
        if os.path.isfile('test-save-data.bhz.pkl'):
            os.remove('test-save-data.bhz.pkl')
        self.assertFalse(os.path.isfile('test-save-data.bhz.pkl'))

        opts = Opts('test-save-data.bhz.pkl','pkl',None)
        gsac1 = readPickle('20120124.00520523.bhz.pkl', None)

        saveData(gsac1, opts)
        self.assertTrue(os.path.isfile('test-save-data.bhz.pkl'))

        # load again to make sure its saved properly
        gsac2 = readPickle('test-save-data.bhz.pkl', None)
        self.assertEqual(len(gsac2.selist), len(gsac1.selist))
        self.assertEqual(len(gsac2.delist), len(gsac1.delist))
        self.assertEqual(len(gsac2.saclist), len(gsac1.saclist))
        
    def test_fileZipMode(self):
        filemode1, zipmode1 = fileZipMode('20120115.13401954.bhz.pkl')
        self.assertEqual(filemode1, 'pkl')
        self.assertEqual(zipmode1, None)
        filemode2, zipmode2 = fileZipMode('20120115.13401954.bhz.pkl.gz')
        self.assertEqual(filemode2, 'pkl')
        self.assertEqual(zipmode2, 'gz')

        filemode3, zipmode3 = fileZipMode('TA.SAC')
        self.assertEqual(filemode3, 'sac')
        self.assertEqual(zipmode3, None)

    def test_pkl2sac(self):
    	    pkfile = '20120109.04071467.bhz.pkl'
        zipmode = None
        gsac = readPickle(pkfile, zipmode)
        sacdh = gsac.saclist[0]
        dirarr = sacdh.filename.split('/')
        dirname = dirarr[0]+'/'+dirarr[1]

    	    pkl2sac(pkfile, zipmode)