Exemplo n.º 1
0
    def test_plot_traces(self):
        # Only checking that these do not throw errors
        dat = NoInitRadarData(big=True)
        fig, ax = plot.plot_traces(dat, 0)
        fig, ax = plot.plot_traces(dat, [1, 1])
        fig, ax = plot.plot_traces(dat, [1, 18])
        with self.assertRaises(ValueError):
            fig, ax = plot.plot_traces(dat, np.arange(10))
        with self.assertRaises(IndexError):
            fig, ax = plot.plot_traces(dat, 999)

        # no nmo
        fig, ax = plot.plot_traces(dat, 0, ydat='depth')

        # with nmo
        dat.nmo_depth = np.arange(10)
        fig, ax = plot.plot_traces(dat, 0, ydat='depth')
        with self.assertRaises(ValueError):
            fig, ax = plot.plot_traces(dat, 0, ydat='dum')

        # Make sure we handle axes rescaling ok
        dat.data[:, 0] = 10
        dat.data[:, 1] = -10
        fig, ax = plot.plot_traces(dat, (0, 2))
Exemplo n.º 2
0
    def test_plot_specdense(self):
        # Only checking that these do not throw errors
        dat = NoInitRadarData(big=True)

        dat.picks = Picks(dat)
        dat.picks.samp1 = np.ones((2, len(dat.lat)))
        dat.picks.samp2 = np.ones((2, len(dat.lat)))
        dat.picks.samp3 = np.ones((2, len(dat.lat)))

        fig, ax = plot.plot_specdense(dat, 3.0e-7)
        plot.plot_specdense(dat, 3.0e-7, fig=fig)
        plot.plot_specdense(dat, 3.0e-7, fig=fig, ax=ax)
        plot.plot_specdense(dat, 3.0e-7, window='hamming')
        plot.plot_specdense(dat, 3.0e-7, scaling='density')

        # freq too low
        with self.assertRaises(ValueError):
            plot.plot_specdense(dat, -100)

        with self.assertRaises(ValueError):
            plot.plot_specdense(dat, 3.0e-7, scaling='dummy')

        with self.assertRaises(ValueError):
            plot.plot_specdense(dat, 3.0e-7, window='dummy')
Exemplo n.º 3
0
 def test_Kirchoff_cython(self):
     data = NoInitRadarData(big=True)
     data = mig_cython.migrationKirchhoff(data)
Exemplo n.º 4
0
 def testWriteWithFlags(self):
     rd = NoInitRadarData()
     rd.flags = RadarFlags()
     rd.save(os.path.join(THIS_DIR, 'input_data', 'test_out.mat'))
Exemplo n.º 5
0
 def test_output_shp_nolayers_nogdal(self):
     rd = NoInitRadarData()
     with self.assertRaises(ImportError):
         rd.output_shp(os.path.join(THIS_DIR, 'input_data', 'test.shp'))
Exemplo n.º 6
0
 def test_sustolt(self):
     data = NoInitRadarData(big=True)
     data.dt = 1.0e-9
     data.travel_time = data.travel_time * 1.0e-9
     data.fn = os.path.join(THIS_DIR, 'input_data', 'rectangle_sustolt.mat')
     migrationlib.migrationSeisUnix(data)
Exemplo n.º 7
0
 def test_PhaseShiftConstant(self):
     data = NoInitRadarData(big=True)
     data = migrationlib.migrationPhaseShift(data)
Exemplo n.º 8
0
 def test_Stolt(self):
     data = NoInitRadarData(big=True)
     data = migrationlib.migrationStolt(data)
Exemplo n.º 9
0
    def test_kinematic_gps_control(self):
        dats = [NoInitRadarData(big=True)]
        gpslib.kinematic_gps_control(dats,
                                     np.arange(0, 2.0, 0.1),
                                     np.arange(40, 60., 1.),
                                     np.arange(0., 2000., 100.),
                                     np.arange(0., 20., 1.),
                                     guess_offset=False)
        self.assertTrue(np.allclose(np.arange(0, 2.0, 0.1), dats[0].lat))
        self.assertTrue(np.allclose(np.arange(40, 60, 1), dats[0].long))
        self.assertTrue(np.allclose(np.arange(0, 2000, 100), dats[0].elev))

        with self.assertRaises(ValueError):
            gpslib.kinematic_gps_control(dats,
                                         np.arange(0, 2.0, 0.1),
                                         np.arange(0, 200, 10),
                                         np.arange(0, 2000, 100),
                                         np.arange(0, 20, 1),
                                         guess_offset=True)

        dat = NoInitRadarData(big=True)
        gpslib.kinematic_gps_control(dat,
                                     np.arange(0, 2.0, 0.1),
                                     np.arange(40, 60, 1),
                                     np.arange(0, 2000, 100),
                                     np.arange(0, 20, 1),
                                     guess_offset=False)
        self.assertTrue(np.allclose(np.arange(0, 2.0, 0.1), dat.lat))
        self.assertTrue(np.allclose(np.arange(40, 60, 1), dat.long))
        self.assertTrue(np.allclose(np.arange(0, 2000, 100), dat.elev))

        # We should be allowed to be off by 360 in longitude
        dat = NoInitRadarData(big=True)
        gpslib.kinematic_gps_control(dat,
                                     np.arange(0, 2.0, 0.1),
                                     np.arange(40, 60, 1) - 360.,
                                     np.arange(0, 2000, 100),
                                     np.arange(0, 20, 1),
                                     guess_offset=False)
        self.assertTrue(np.allclose(np.arange(0, 2.0, 0.1), dats[0].lat))
        self.assertTrue(np.allclose(np.arange(40, 60, 1), dats[0].long))
        self.assertTrue(np.allclose(np.arange(0, 2000, 100), dats[0].elev))

        # and off the other way
        dat = NoInitRadarData(big=True)
        dat.long = dat.long - 360.
        gpslib.kinematic_gps_control(dat,
                                     np.arange(0, 2.0, 0.1),
                                     np.arange(40, 60, 1),
                                     np.arange(0, 2000, 100),
                                     np.arange(0, 20, 1),
                                     guess_offset=False)
        self.assertTrue(np.allclose(np.arange(0, 2.0, 0.1), dats[0].lat))
        self.assertTrue(np.allclose(np.arange(40, 60, 1), dats[0].long))
        self.assertTrue(np.allclose(np.arange(0, 2000, 100), dats[0].elev))

        dat = NoInitRadarData(big=True)
        gpslib.kinematic_gps_control(dat,
                                     np.arange(-1.0, 3.0, 0.1),
                                     np.arange(20, 60, 1),
                                     np.arange(-1000, 3000, 100),
                                     np.arange(-10, 30, 1),
                                     guess_offset=True)

        # Multiple inputs
        dats = [NoInitRadarData(big=True), NoInitRadarData(big=True)]
        gpslib.kinematic_gps_control(dats,
                                     np.arange(-1.0, 3.0, 0.1),
                                     np.arange(40, 80, 1),
                                     np.arange(-1000, 3000, 100),
                                     np.arange(-10, 30, 1),
                                     guess_offset=True)

        # Bad timing
        dat = NoInitRadarData(big=True)
        dat.decday = dat.decday + 10
        with self.assertRaises(ValueError):
            gpslib.kinematic_gps_control(dat, np.arange(0, 2.0, 0.1),
                                         np.arange(0, 20, 1),
                                         np.arange(0, 2000, 100),
                                         np.arange(0, 20, 1))
Exemplo n.º 10
0
 def test_HfiltRun(self):
     radardata = NoInitRadarData()
     radardata.horizontalfilt(0, 100)
     # We taper in the hfilt, so this is not just zeros
     self.assertTrue(
         np.all(radardata.data == radardata.hfilt_target_output))
Exemplo n.º 11
0
 def test_AdaptiveRun(self):
     radardata = NoInitRadarData()
     radardata.adaptivehfilt()
     # since we subtract average trace and all traces are identical, we should get zeros out
     self.assertTrue(np.all(radardata.data <= 1.))
Exemplo n.º 12
0
 def test_process_vbp(self):
     radardata = NoInitRadarData()
     process.process([radardata], vbp=(0.1, 100.))
     # The filter is not too good, so we have lots of residual
     self.assertTrue(np.all(np.abs(radardata.data) < 1.0e-4))
Exemplo n.º 13
0
 def test_process_hfilt(self):
     radardata = NoInitRadarData()
     process.process([radardata], hfilt=(0, 100))
     # We taper in the hfilt, so this is not just zeros
     self.assertTrue(
         np.all(radardata.data == radardata.hfilt_target_output))
Exemplo n.º 14
0
 def test_process_ahfilt(self):
     radardata = NoInitRadarData()
     process.process([radardata], ahfilt=True)
     # We taper in the hfilt, so this is not just zeros
     self.assertTrue(np.all(radardata.data <= 1.))
Exemplo n.º 15
0
 def test_vbp_badftype(self):
     radardata = NoInitRadarData()
     with self.assertRaises(ValueError):
         radardata.vertical_band_pass(0.1, 100., filttype='dummy')
Exemplo n.º 16
0
 def test_HighPassNotspaced(self):
     radardata = NoInitRadarData()
     with self.assertRaises(ImpdarError):
         # We have a screwed up filter here because of sampling vs. frequency used
         radardata.highpass(1000.0)
Exemplo n.º 17
0
 def test_WinAvgExp(self):
     radardata = NoInitRadarData()
     radardata.winavg_hfilt(11, taper='full')
     self.assertTrue(
         np.all(radardata.data == radardata.hfilt_target_output))
Exemplo n.º 18
0
 def test_SaveFails(self):
     print(SEGY)
     data = NoInitRadarData()
     with self.assertRaises(ImportError):
         data.save_as_segy(os.path.join(THIS_DIR, 'input_data', 'shots0001_0200_resave.segy'))
Exemplo n.º 19
0
 def test_WinAvgExpBadwinavg(self):
     # Tests the check on whether win_avg < tnum
     radardata = NoInitRadarData()
     radardata.winavg_hfilt(data_dummy.shape[1] + 10, taper='full')
     self.assertTrue(
         np.all(radardata.data == radardata.hfilt_target_output))
Exemplo n.º 20
0
 def test_Kirchhoff(self):
     data = NoInitRadarData(big=True)
     data = migrationlib.migrationKirchhoff(data)
Exemplo n.º 21
0
 def test_WinAvgPexp(self):
     radardata = NoInitRadarData()
     radardata.winavg_hfilt(11, taper='pexp', filtdepth=-1)
     self.assertTrue(np.all(radardata.data == radardata.pexp_target_output))
Exemplo n.º 22
0
 def test_PhaseShiftLateral(self):
     data = NoInitRadarData(big=True)
     data = migrationlib.migrationPhaseShift(data,
                                             vel_fn=os.path.join(
                                                 THIS_DIR, 'input_data',
                                                 'velocity_lateral.txt'))
Exemplo n.º 23
0
 def test_WinAvgbadtaper(self):
     radardata = NoInitRadarData()
     with self.assertRaises(ValueError):
         radardata.winavg_hfilt(11, taper='not_a_taper', filtdepth=-1)
Exemplo n.º 24
0
 def test_output_shp_nolayers(self):
     rd = NoInitRadarData()
     rd.output_shp(os.path.join(THIS_DIR, 'input_data', 'test.shp'))
Exemplo n.º 25
0
 def test_vbp_butter(self):
     radardata = NoInitRadarData()
     radardata.vertical_band_pass(0.1, 100., filttype='butter')
     # The filter is not too good, so we have lots of residual
     self.assertTrue(np.all(np.abs(radardata.data) < 1.0e-4))
Exemplo n.º 26
0
 def test_WriteNoFLags(self):
     rd = NoInitRadarData()
     rd.save(os.path.join(THIS_DIR, 'input_data', 'test_out.mat'))
     os.remove(os.path.join(THIS_DIR, 'input_data', 'test_out.mat'))
Exemplo n.º 27
0
    def test_plot_picks(self, mock_show):
        # Only checking that these do not throw errors
        dat = NoInitRadarData(big=True)

        fig, ax = plot.plot_picks(dat, np.arange(int(dat.tnum)),
                                  dat.travel_time)

        dat.picks = Picks(dat)
        dat.picks.picknums = [2, 10]
        dat.picks.samp1 = np.ones((2, len(dat.lat)))
        dat.picks.samp2 = np.ones((2, len(dat.lat)))
        dat.picks.samp3 = np.ones((2, len(dat.lat)))

        fig, ax = plot.plot_picks(dat, np.arange(int(dat.tnum)),
                                  dat.travel_time)

        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        fig=fig)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors='g',
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors='gmm',
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=['c', 'g'],
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=['cmy', 'brb'],
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=['cm', 'br'],
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=True,
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=False,
                        fig=fig,
                        ax=ax)
        plot.plot_picks(dat,
                        np.arange(int(dat.tnum)),
                        dat.travel_time,
                        colors=['c', 'm', 'b'],
                        just_middle=False,
                        fig=fig,
                        ax=ax)
        with self.assertRaises(ValueError):
            plot.plot_picks(dat,
                            np.arange(int(dat.tnum)),
                            dat.travel_time,
                            colors=['c', 'm', 'b'],
                            just_middle=True,
                            fig=fig,
                            ax=ax)
Exemplo n.º 28
0
 def test_WriteRead(self):
     # We are going to create a really bad file (most info missing) and see if we recover it or get an error
     rd = NoInitRadarData()
     rd.save(os.path.join(THIS_DIR, 'input_data', 'test_out.mat'))
     RadarData(os.path.join(THIS_DIR, 'input_data', 'test_out.mat'))
Exemplo n.º 29
0
 def test_TimeWavenumber(self):
     data = NoInitRadarData(big=True)
     data = mig_python.migrationTimeWavenumber(data)