コード例 #1
0
ファイル: ttincid.py プロジェクト: ehparker/pysmo
def getDelayDict(opts):
	'Get dtdict'	
	if not opts.multinet:
		dtdict = readPickle(opts.ifilename)
		print('Read delay time dict from '+opts.ifilename)
	else:
		nets = opts.nets
		print('Read delay time dicts for nets: {:s} {:s} {:s}'.format(nets[0], nets[1], nets[2]))
		dtdict = {}
		for net in nets:
			ddict = readPickle(net+'-'+opts.ifilename)
			for evid in ddict.keys():
				dtdict[evid] = ddict[evid]
	return dtdict
コード例 #2
0
ファイル: sacpickle_tests.py プロジェクト: xiaolongma/aimbat
    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))
コード例 #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))
コード例 #4
0
ファイル: sacpickle_tests.py プロジェクト: pysmo/aimbat
    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))
コード例 #5
0
ファイル: ttpred.py プロジェクト: ehparker/pysmo
def getDicts(opts):
	'Get dtdicts'
	dtdicts = {}
	if opts.ofilename:
		for tfile in ifiles:
			dtag = tfile.split('/')[-1].split('.')[-1]
			dtdicts[dtag] = readFile(tfile, opts.arrtime)
		writePickle(dtdicts, opts.ofilename)
		print('Write to file :'+ opts.ofilename)
	else:
		print('Read file: '+opts.ifilename)
		dtdicts = readPickle(opts.ifilename)
	return dtdicts
コード例 #6
0
ファイル: ttincid.py プロジェクト: ehparker/pysmo
def getIncDict(opts):
	'Calculate incidence/take-off angles and save to dict'
	if opts.ofilename:
		stadict = readStation(opts.locsta)
		dtdict = getDelayDict(opts)
		getModel(opts)
		if opts.taup:
			dtidict = getIncTauP(dtdict, stadict, opts)
		else:
			dtidict = getIncTTimes(dtdict, stadict, opts)
	else:
		print('Read file: '+opts.ifilename)
		dtidict = readPickle(opts.ifilename)
	return dtidict
コード例 #7
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)
コード例 #8
0
ファイル: ttincid.py プロジェクト: ehparker/pysmo
		opts.tbins = [linspace(pmin,pmax,21), linspace(smin,smax,21)]
		#opts.ticks = [linspace(pmin,pmax,11), linspace(smin,smax,11)]
		opts.majorLocators = MultipleLocator(1), MultipleLocator(3)
		opts.minorLocators = MultipleLocator(.5), MultipleLocator(1)
	if nbin == 2:
		opts.figsize = (12, 10)
	#os.system('rm -rf '+hfile)
	if opts.incstats:
		dtidict = getIncDict(opts)
		incStats(dtidict)

	opts.figsize = (12, 12)
	if opts.histogram:
		if not os.path.isfile(hfile):
			dtidict = getIncDict(opts)	# calculate incidences
			stawest = readStation(fwest)
			staeast = readStation(feast)
			stadicts = [stawest, staeast]
			ewdicts = incBinDelay(dtidict, stadicts, opts)
			writePickle(ewdicts, hfile)
		else:
			print('Read file: '+hfile)
			ewdicts = readPickle(hfile)

		# 2-column
		#opts.bins = linspace(-8,8,81)
		#plotHist2(ewdicts, opts)
		plotHist1(ewdicts, opts)