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])
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))
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'])
# axs = {} # axs['Seis'] = axpp # dx = 0.07 # x0 = rectseis[0] + rectseis[2] + 0.01 # xf = x0 - dx*1 # xq = x0 - dx*2 # xs = x0 - dx*3 # xn = x0 - dx*4 # xz = x0 - dx*5 # xp = x0 - dx*6 # rectfron = [xf, 0.93, 0.06, 0.04] # rectprev = [xp, 0.93, 0.06, 0.04] # rectnext = [xn, 0.93, 0.06, 0.04] # rectzoba = [xz, 0.93, 0.06, 0.04] # rectsave = [xs, 0.93, 0.06, 0.04] # rectquit = [xq, 0.93, 0.06, 0.04] # axs['Fron'] = fig.add_axes(rectfron) # axs['Prev'] = fig.add_axes(rectprev) # axs['Next'] = fig.add_axes(rectnext) # axs['Zoba'] = fig.add_axes(rectzoba) # axs['Save'] = fig.add_axes(rectsave) # axs['Quit'] = fig.add_axes(rectquit) # return axs if __name__ == "__main__": gsac, opts = getDataOpts() axs = getAxes(opts) ppm = PickPhaseMenu(gsac, opts, axs) show()