Esempio n. 1
0
        def test_sortButtonWorks(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            # get files before sorting
            unsortedFiles = []
            for sacdh in gsac.selist:
                unsortedFiles.append(sacdh.filename)

            # click the sort button
            event_clickSortBtn = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.axstk.figure.canvas, 62, 295)
            ppmm.sorting(event_clickSortBtn)

            # click sort filename button
            event_clickSortFilenameBtn = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.figsort.canvas, 151, 700)
            ppmm.sort_file(event_clickSortFilenameBtn)

            # get files after sorting
            sortedFiles = []
            for sacdh in gsac.selist:
                sortedFiles.append(sacdh.filename)
            
            self.assertNotEqual(unsortedFiles, sortedFiles)
Esempio n. 2
0
        def test_sortButtonWorks(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            # get files before sorting
            unsortedFiles = []
            for sacdh in gsac.selist:
                unsortedFiles.append(sacdh.filename)

            # click the sort button
            event_clickSortBtn = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.axstk.figure.canvas, 62, 295)
            ppmm.sorting(event_clickSortBtn)

            # click sort filename button
            event_clickSortFilenameBtn = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.figsort.canvas, 151, 700)
            ppmm.sort_file(event_clickSortFilenameBtn)

            # get files after sorting
            sortedFiles = []
            for sacdh in gsac.selist:
                sortedFiles.append(sacdh.filename)

            self.assertNotEqual(unsortedFiles, sortedFiles)
Esempio n. 3
0
    def test__save_headers_filterParams(self):
    	# copy the file each time so we can destroy it
    	shutil.copy2('20120124.00520523.bhz.pkl', 'temp-test-bhz.pkl')

    	sys.argv[1:] = ['temp-test-bhz.pkl']
    	gsac1, opts1 = getDataOpts()
    	axs1 = getAxes(opts1)
    	setattr(opts1,'labelqual',True)
    	ppm1 = PickPhaseMenu(gsac1, opts1, axs1)

    	originalSaclist = gsac1.saclist

    	# click the save button
    	click_save_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppm1.axpp.figure.canvas, 63, 481)
    	ppm1.save(click_save_event)

    	#click the save parameters chosen event
    	click_params_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppm1.axpp.figure.canvas, 415, 54)
    	ppm1.save_headers_filterParams(click_params_event)

    	# reload to make sure data has been overwritten
    	sys.argv[1:] = ['temp-test-bhz.pkl']
    	gsac2, opts2 = getDataOpts()

    	for i in xrange(len(gsac2.saclist)):
    		self.assertNotEqual(gsac1.saclist[i], gsac2.saclist[i])
Esempio n. 4
0
    def test__save_headers_filterParams(self):
    	# copy the file each time so we can destroy it
    	shutil.copy2('20120124.00520523.bhz.pkl', 'temp-test-bhz.pkl')

    	sys.argv[1:] = ['temp-test-bhz.pkl']
    	gsac1, opts1 = getDataOpts()
    	axs1 = getAxes(opts1)
    	setattr(opts1,'labelqual',True)
    	ppm1 = PickPhaseMenu(gsac1, opts1, axs1)

    	# randomly get stuff
    	rand_order = random.randint(1, 4) 
    	rand_lowFreq = random.uniform(0.1,0.2)
    	rand_highFreq = random.uniform(0.8,1.2)

    	opts1.filterParameters['lowFreq'] = rand_lowFreq
    	opts1.filterParameters['highFreq'] = rand_highFreq
    	opts1.filterParameters['order'] = rand_order

    	# click the save button
    	click_save_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppm1.axpp.figure.canvas, 63, 481)
    	ppm1.save(click_save_event)

    	#click the save parameters chosen event
    	click_params_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppm1.axpp.figure.canvas, 256, 48)
    	ppm1.save_headers_filterParams(click_params_event)

    	# reload to make sure parameters exist now
    	sys.argv[1:] = ['temp-test-bhz.pkl']
    	gsac2, opts2 = getDataOpts()

    	self.assertEqual(rand_lowFreq, opts2.filterParameters['lowFreq'])
    	self.assertEqual(rand_highFreq, opts2.filterParameters['highFreq'])
    	self.assertEqual(rand_order, opts2.filterParameters['order'])
Esempio n. 5
0
    def test__save_headers_filterParams(self):
        # copy the file each time so we can destroy it
        shutil.copy2('20120124.00520523.bhz.pkl', 'temp-test-bhz.pkl')

        sys.argv[1:] = ['temp-test-bhz.pkl']
        gsac1, opts1 = getDataOpts()
        axs1 = getAxes(opts1)
        setattr(opts1, 'labelqual', True)
        ppm1 = PickPhaseMenu(gsac1, opts1, axs1)

        originalSaclist = gsac1.saclist

        # click the save button
        click_save_event = matplotlib.backend_bases.MouseEvent(
            'button_press_event', ppm1.axpp.figure.canvas, 63, 481)
        ppm1.save(click_save_event)

        #click the save parameters chosen event
        click_params_event = matplotlib.backend_bases.MouseEvent(
            'button_press_event', ppm1.axpp.figure.canvas, 415, 54)
        ppm1.save_headers_filterParams(click_params_event)

        # reload to make sure data has been overwritten
        sys.argv[1:] = ['temp-test-bhz.pkl']
        gsac2, opts2 = getDataOpts()

        for i in xrange(len(gsac2.saclist)):
            self.assertNotEqual(gsac1.saclist[i], gsac2.saclist[i])
Esempio n. 6
0
        def runBefore(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            fake_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.axstk.figure.canvas, 56, 224)
            ppmm.filtering(fake_event)
            return ppmm
Esempio n. 7
0
    def test_timeSelector_ignore(self):
        sys.argv[1:] = [test_filename]
        gsac, opts = getDataOpts()
        opts.labelqual = True
        axs = getAxes(opts)
        ppm = PickPhaseMenu(gsac, opts, axs)

        ppm.on_select(-3,4.3)
        self.assertEqual(ppm.axpp.get_xlim(),(-3,4.3))
Esempio n. 8
0
        def runBefore(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            fake_event = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.axstk.figure.canvas, 56, 224)
            ppmm.filtering(fake_event)
            return ppmm
Esempio n. 9
0
        def test_sortFigExists(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            self.assertFalse(hasattr(ppmm,'figsort'))

            fake_event = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.axstk.figure.canvas, 62, 295)
            ppmm.sorting(fake_event)

            self.assertIsNotNone(ppmm.figsort)
            self.assertIsNotNone(ppmm.sortAxs)
Esempio n. 10
0
        def test_filter_spreadButter(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            # click the filter button
            event_clickFilterBtn = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.axstk.figure.canvas, 71,223)
            ppmm.filtering(event_clickFilterBtn)
   
            # click apply filter button
            event_clickApplyFilterBtn = matplotlib.backend_bases.MouseEvent('button_press_event', ppmm.figfilter.canvas, 646,829)
            ppmm.applyFilter(event_clickApplyFilterBtn)
Esempio n. 11
0
def main():
	gsac, opts = getDataOpts()
	axs = getAxes(opts)
	ppmm = PickPhaseMenuMore(gsac, opts, axs)
	fmt = 'png'
	fmt = 'pdf'
	if opts.savefig:
		if opts.pklfile is None:
			fignm = 'ttpick.' + fmt
		else:
			fignm = opts.pklfile + '.' + fmt
		plt.savefig(fignm, format=fmt)
	else:
		plt.show()
Esempio n. 12
0
        def test_sortFigExists(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            self.assertFalse(hasattr(ppmm, 'figsort'))

            fake_event = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.axstk.figure.canvas, 62, 295)
            ppmm.sorting(fake_event)

            self.assertIsNotNone(ppmm.figsort)
            self.assertIsNotNone(ppmm.sortAxs)
Esempio n. 13
0
def main():
    gsac, opts = getDataOpts()
    axs = getAxes(opts)
    ppmm = PickPhaseMenuMore(gsac, opts, axs)
    fmt = 'png'
    fmt = 'pdf'
    if opts.savefig:
        if opts.pklfile is None:
            fignm = 'ttpick.' + fmt
        else:
            fignm = opts.pklfile + '.' + fmt
        plt.savefig(fignm, format=fmt)
    else:
        plt.show()
Esempio n. 14
0
        def test_filter_spreadButter(self):
            sys.argv[1:] = [test_filename]
            gsac, opts = getDataOpts()
            axs = getAxes(opts)
            ppmm = PickPhaseMenuMore(gsac, opts, axs)

            # click the filter button
            event_clickFilterBtn = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.axstk.figure.canvas, 71, 223)
            ppmm.filtering(event_clickFilterBtn)

            # click apply filter button
            event_clickApplyFilterBtn = matplotlib.backend_bases.MouseEvent(
                'button_press_event', ppmm.figfilter.canvas, 646, 829)
            ppmm.applyFilter(event_clickApplyFilterBtn)
Esempio n. 15
0
    def test__save_headers_filterParams(self):
        # copy the file each time so we can destroy it
        shutil.copy2('20120124.00520523.bhz.pkl', 'temp-test-bhz.pkl')

        sys.argv[1:] = ['temp-test-bhz.pkl']
        gsac1, opts1 = getDataOpts()
        axs1 = getAxes(opts1)
        setattr(opts1, 'labelqual', True)
        ppm1 = PickPhaseMenu(gsac1, opts1, axs1)

        # randomly get stuff
        rand_order = random.randint(1, 4)
        rand_lowFreq = random.uniform(0.1, 0.2)
        rand_highFreq = random.uniform(0.8, 1.2)

        opts1.filterParameters['lowFreq'] = rand_lowFreq
        opts1.filterParameters['highFreq'] = rand_highFreq
        opts1.filterParameters['order'] = rand_order

        # click the save button
        click_save_event = matplotlib.backend_bases.MouseEvent(
            'button_press_event', ppm1.axpp.figure.canvas, 63, 481)
        ppm1.save(click_save_event)

        #click the save parameters chosen event
        click_params_event = matplotlib.backend_bases.MouseEvent(
            'button_press_event', ppm1.axpp.figure.canvas, 256, 48)
        ppm1.save_headers_filterParams(click_params_event)

        # reload to make sure parameters exist now
        sys.argv[1:] = ['temp-test-bhz.pkl']
        gsac2, opts2 = getDataOpts()

        self.assertEqual(rand_lowFreq, opts2.filterParameters['lowFreq'])
        self.assertEqual(rand_highFreq, opts2.filterParameters['highFreq'])
        self.assertEqual(rand_order, opts2.filterParameters['order'])