コード例 #1
0
ファイル: test_obspytoph5.py プロジェクト: mbriggs134/PH5
    def test_main3(self):
        testargs = [
            'metadatatoph5', '-n', 'master.ph5', '-f', self.station_xml_path
        ]
        with patch.object(sys, 'argv', testargs):
            metadatatoph5.main()

        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', '-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'))

        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'])
コード例 #2
0
 def setUp(self):
     super(TestObspytoPH5_main, self).setUp()
     self.station_xml_path = os.path.join(
         self.home, 'ph5/test_data/metadata/station.xml')
     testargs = [
         'metadatatoph5', '-n', 'master.ph5', '-f', self.station_xml_path
     ]
     with patch.object(sys, 'argv', testargs):
         metadatatoph5.main()
コード例 #3
0
 def setUp(self):
     super(TestObspytoPH5_float32, self).setUp()
     self.datapath = os.path.join(self.home,
                                  'ph5/test_data/miniseed_float32')
     testargs = [
         'metadatatoph5', '-n', 'master.ph5', '-f',
         os.path.join(self.datapath, 'SmartSolo_05473.xml')
     ]
     with patch.object(sys, 'argv', testargs):
         metadatatoph5.main()
コード例 #4
0
 def test_main(self):
     """
     test main function
     """
     testargs = [
         'metadatatoph5', '-n', 'master.ph5', '-f',
         'ph5/test_data/metadata/station.xml'
     ]
     with patch.object(sys, 'argv', testargs):
         metadatatoph5.main()
     self.assertTrue(os.path.isfile('master.ph5'))
     ph5_object = experiment.ExperimentGroup(nickname='master.ph5')
     ph5_object.ph5open(True)
     ph5_object.initgroup()
     array_names = ph5_object.ph5_g_sorts.names()
     self.assertEqual(['Array_t_001', 'Array_t_002', 'Array_t_003'],
                      array_names)
     ret, keys = ph5_object.ph5_g_sorts.read_arrays('Array_t_001')
     key = [
         'id_s', 'location/X/value_d', 'location/X/units_s',
         'location/Y/value_d', 'location/Y/units_s', 'location/Z/value_d',
         'location/Z/units_s', 'location/coordinate_system_s',
         'location/projection_s', 'location/ellipsoid_s',
         'location/description_s', 'deploy_time/ascii_s',
         'deploy_time/epoch_l', 'deploy_time/micro_seconds_i',
         'deploy_time/type_s', 'pickup_time/ascii_s', 'pickup_time/epoch_l',
         'pickup_time/micro_seconds_i', 'pickup_time/type_s',
         'das/serial_number_s', 'das/model_s', 'das/manufacturer_s',
         'das/notes_s', 'sensor/serial_number_s', 'sensor/model_s',
         'sensor/manufacturer_s', 'sensor/notes_s', 'description_s',
         'seed_band_code_s', 'sample_rate_i', 'sample_rate_multiplier_i',
         'seed_instrument_code_s', 'seed_orientation_code_s',
         'seed_location_code_s', 'seed_station_name_s', 'channel_number_i',
         'receiver_table_n_i', 'response_table_n_i'
     ]
     self.assertEqual(key, keys)
     self.assertEqual(1, len(ret))
     self.assertEqual('5553', ret[0]['das/serial_number_s'])
     self.assertEqual('H', ret[0]['seed_instrument_code_s'])
     self.assertEqual('H', ret[0]['seed_band_code_s'])
     self.assertEqual('N', ret[0]['seed_orientation_code_s'])
     ph5_object.ph5close()
     os.remove('master.ph5')
     os.remove('metadatatoph5.log')
コード例 #5
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'])
コード例 #6
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')