Exemple #1
0
    def test_main3(self):

        with open("test_list", "w") as f:
            # need to use relative path '../miniseed/0407HHN.ms' because
            # das_t's 'raw_file_name_s will be chopped off if the path's
            # length is greater than 32
            f.write("../miniseed/0407HHN.ms")
        # first need to run obspytoph5
        testargs = ['obspytoph5', '-n', 'master.ph5', '-f', 'test_list']
        with patch.object(sys, 'argv', testargs):
            obspytoph5.main()
        self.assertTrue(os.path.isfile('master.ph5'))
        self.assertTrue(os.path.isfile('miniPH5_00001.ph5'))

        self.ph5_object = initialize_ex('master.ph5', '.', False)
        node = self.ph5_object.ph5_g_receivers.getdas_g('5553')
        self.ph5_object.ph5_g_receivers.setcurrent(node)
        ret, das_keys = self.ph5_object.ph5_g_receivers.read_das()
        keys = [
            'array_name_SOH_a', 'array_name_data_a', 'array_name_event_a',
            'array_name_log_a', 'channel_number_i', 'event_number_i',
            'raw_file_name_s', 'receiver_table_n_i', 'response_table_n_i',
            'sample_count_i', 'sample_rate_i', 'sample_rate_multiplier_i',
            'stream_number_i', 'time/ascii_s', 'time/epoch_l',
            'time/micro_seconds_i', 'time/type_s', 'time_table_n_i'
        ]
        self.assertEqual(keys, das_keys)
        self.assertEqual('../miniseed/0407HHN.ms', ret[0]['raw_file_name_s'])
Exemple #2
0
 def test_main(self):
     testargs = [
         'mstoph5', '-n', 'master.ph5', '-r',
         os.path.join(self.datapath, '05743.SS..GHZ.148')
     ]
     with patch.object(sys, 'argv', testargs):
         obspytoph5.main()
     self.ph5_object = initialize_ex('master.ph5', self.tmpdir, False)
     data_node = self.ph5_object.ph5.get_node(
         '/Experiment_g/Receivers_g/Das_g_05743', 'Data_a_00001', 'Array')
     data = data_node.read()
     self.assertIsInstance(data[0], numpy.float32)
Exemple #3
0
    def test_main(self):
        testargs = ['initialize_ph5', '-n', 'master']
        with patch.object(sys, 'argv', testargs):
            initialize_ph5.main()

        # check using flag -f for miniseed file
        testargs = [
            'mstoph5', '-n', 'master', '-f',
            os.path.join(self.home, 'ph5/test_data/miniseed/0407HHN.ms')
        ]
        with patch.object(sys, 'argv', testargs):
            with LogCapture() as log:
                with self.assertRaises(SystemExit):
                    obspytoph5.main()
                self.assertEqual(
                    log.records[0].msg,
                    "The given list file is a miniseed file. "
                    "You have been confused between two option -r and -f.")
Exemple #4
0
    def setUp(self):
        super(Test_n_i_fix, self).setUp()
        """
        use metadata to add metadata info
         array_002-st0407 - das5553 - response_n_i=0
         array_003-st0407 - das5553 - response_n_i=1
         array_004-st0407 - das5553 - response_n_i=-1
         response_t: n_i=0 response_file_das_a= NoneQ330_NoneCMG3T_200HHN
         response_t: n_i=1 response_file_das_a= NoneQ330_NoneCMG3T_100LHN
         response_t: n_i=-1
        """
        testargs = [
            'metadatatoph5', '-n', 'master.ph5', '-f',
            os.path.join(self.home, "ph5/test_data/metadata/station.xml")
        ]
        with patch.object(sys, 'argv', testargs):
            metadatatoph5.main()
        """
        add das_t 5553's
        """
        testargs = [
            'mstoph5', '-n', 'master.ph5', '-d',
            os.path.join(self.home, "ph5/test_data/miniseed")
        ]
        with patch.object(sys, 'argv', testargs):
            obspytoph5.main()
        """
        add create master.ph5 with the following tables:
         array_001-sta500-cha1,2,3-das3x500-modelZLAND_sr500-response_n_i0
         das_3x500
         response_t: n_i=0 bit_weight=1.88e-05
        """
        testargs = [
            'segdtoph5', '-n', 'master.ph5', '-r',
            os.path.join(self.home, "ph5/test_data/segd/3ch.fcnt")
        ]
        with patch.object(sys, 'argv', testargs):
            segd2ph5.main()

        self.ph5API_object = ph5api.PH5(path='.',
                                        nickname='master.ph5',
                                        editmode=True)
        self.n_i_fix = resp_load.n_i_fix(self.ph5API_object, False, True,
                                         ['1', '2', '3', '4'])
Exemple #5
0
    def test_main(self):
        """
        test main
        """
        # first need to run metadatatoph5
        testargs = ['metadatatoph5', '-n', 'master.ph5', '-f',
                    'ph5/test_data/metadata/station.xml']
        with patch.object(sys, 'argv', testargs):
            metadatatoph5.main()

        # first need to run obspytoph5
        testargs = ['obspytoph5', '-n', 'master.ph5', '-d',
                    'ph5/test_data/miniseed/']
        with patch.object(sys, 'argv', testargs):
            obspytoph5.main()
        self.assertTrue(os.path.isfile('master.ph5'))
        self.assertTrue(os.path.isfile('miniPH5_00001.ph5'))
        ph5_object = experiment.ExperimentGroup(
            nickname='master.ph5')
        ph5_object.ph5open(True)
        ph5_object.initgroup()
        node = ph5_object.ph5_g_receivers.getdas_g('5553')
        ph5_object.ph5_g_receivers.setcurrent(node)
        ret, das_keys = ph5_object.ph5_g_receivers.read_das()
        keys = ['array_name_SOH_a', 'array_name_data_a', 'array_name_event_a',
                'array_name_log_a', 'channel_number_i', 'event_number_i',
                'raw_file_name_s', 'receiver_table_n_i', 'response_table_n_i',
                'sample_count_i', 'sample_rate_i', 'sample_rate_multiplier_i',
                'stream_number_i', 'time/ascii_s', 'time/epoch_l',
                'time/micro_seconds_i', 'time/type_s', 'time_table_n_i']
        self.assertEqual(keys, das_keys)
        self.assertEqual(
            'ph5/test_data/miniseed/0407HHN.m',
            ret[0]['raw_file_name_s'])
        self.assertEqual(
            'ph5/test_data/miniseed/0407LHN.m',
            ret[1]['raw_file_name_s'])
        ph5_object.ph5close()
        os.remove('master.ph5')
        os.remove('miniPH5_00001.ph5')
        os.remove('metadatatoph5.log')
        os.remove('datatoph5.log')

        # first need to run metadatatoph5
        testargs = ['metadatatoph5', '-n', 'master.ph5', '-f',
                    'ph5/test_data/metadata/station.xml']
        with patch.object(sys, 'argv', testargs):
            metadatatoph5.main()
        # first need to run obspytoph5
        testargs = ['obspytoph5', '-n', 'master.ph5', '-f',
                    'ph5/test_data/miniseed/0407HHN.ms']
        with patch.object(sys, 'argv', testargs):
            obspytoph5.main()
        self.assertTrue(os.path.isfile('master.ph5'))
        self.assertTrue(os.path.isfile('miniPH5_00001.ph5'))
        ph5_object = experiment.ExperimentGroup(
            nickname='master.ph5')
        ph5_object.ph5open(True)
        ph5_object.initgroup()
        node = ph5_object.ph5_g_receivers.getdas_g('5553')
        ph5_object.ph5_g_receivers.setcurrent(node)
        ret, das_keys = ph5_object.ph5_g_receivers.read_das()
        keys = ['array_name_SOH_a', 'array_name_data_a', 'array_name_event_a',
                'array_name_log_a', 'channel_number_i', 'event_number_i',
                'raw_file_name_s', 'receiver_table_n_i', 'response_table_n_i',
                'sample_count_i', 'sample_rate_i', 'sample_rate_multiplier_i',
                'stream_number_i', 'time/ascii_s', 'time/epoch_l',
                'time/micro_seconds_i', 'time/type_s', 'time_table_n_i']
        self.assertEqual(keys, das_keys)
        self.assertEqual(
            'ph5/test_data/miniseed/0407HHN.m',
            ret[0]['raw_file_name_s'])
        ph5_object.ph5close()
        os.remove('master.ph5')
        os.remove('miniPH5_00001.ph5')
        os.remove('metadatatoph5.log')
        os.remove('datatoph5.log')

        # first need to run metadatatoph5
        testargs = ['metadatatoph5', '-n', 'master.ph5', '-f',
                    'ph5/test_data/metadata/station.xml']
        with patch.object(sys, 'argv', testargs):
            metadatatoph5.main()

        # now make a list for obspytoph5
        f = open("test_list", "w")
        f.write("ph5/test_data/miniseed/0407HHN.ms")
        f.close()
        # first need to run obspytoph5
        testargs = ['obspytoph5', '-n', 'master.ph5', '-l',
                    'test_list']
        with patch.object(sys, 'argv', testargs):
            obspytoph5.main()
        self.assertTrue(os.path.isfile('master.ph5'))
        self.assertTrue(os.path.isfile('miniPH5_00001.ph5'))
        ph5_object = experiment.ExperimentGroup(
            nickname='master.ph5')
        ph5_object.ph5open(True)
        ph5_object.initgroup()
        node = ph5_object.ph5_g_receivers.getdas_g('5553')
        ph5_object.ph5_g_receivers.setcurrent(node)
        ret, das_keys = ph5_object.ph5_g_receivers.read_das()
        keys = ['array_name_SOH_a', 'array_name_data_a', 'array_name_event_a',
                'array_name_log_a', 'channel_number_i', 'event_number_i',
                'raw_file_name_s', 'receiver_table_n_i', 'response_table_n_i',
                'sample_count_i', 'sample_rate_i', 'sample_rate_multiplier_i',
                'stream_number_i', 'time/ascii_s', 'time/epoch_l',
                'time/micro_seconds_i', 'time/type_s', 'time_table_n_i']
        self.assertEqual(keys, das_keys)
        self.assertEqual(
            'ph5/test_data/miniseed/0407HHN.m',
            ret[0]['raw_file_name_s'])
        ph5_object.ph5close()
        os.remove('master.ph5')
        os.remove('miniPH5_00001.ph5')
        os.remove('metadatatoph5.log')
        os.remove('datatoph5.log')
        os.remove('test_list')