def test_check_has_response_filename(self): testargs = ['segdtoph5', '-n', 'master.ph5', '-U', '13N', '-r', os.path.join(self.home, 'ph5/test_data/segd/3ch.fcnt')] with patch.object(sys, 'argv', testargs): segd2ph5.main() self.ph5 = ph5api.PH5(path=self.tmpdir, nickname='master.ph5') self.ph5.read_response_t() has_response_file = validation.check_has_response_filename( self.ph5.Response_t, set(), None) self.assertEqual(has_response_file, "Response table does not contain any response file " "names. Check if resp_load has been run or if " "metadatatoph5 input contained response information.")
def setUp(self): super(TestPH5toStationXMLParser_gen_resp_issue, self).setUp() testargs = ['initialize_ph5', '-n', 'master.ph5'] with patch.object(sys, 'argv', testargs): initialize_ph5.main() testargs = ['keftoph5', '-n', 'master.ph5', '-k', os.path.join(self.home, 'ph5/test_data/metadata/experiment.kef')] with patch.object(sys, 'argv', testargs): kef2ph5.main() testargs = ['segdtoph5', '-n', 'master.ph5', '-U', '13N', '-r', os.path.join(self.home, 'ph5/test_data/segd/3ch.fcnt')] with patch.object(sys, 'argv', testargs): segd2ph5.main()
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'])
def test_main(self): # add fcnt data of the same das in the same array but with different # deploytime segd_dir = os.path.join(self.home, "ph5/test_data/segd/") # create list file list_file = open('fcnt_list', "w") fileList = os.listdir(segd_dir) s = "" for f in fileList: if f.endswith(".fcnt") and f.startswith("1111"): s += segd_dir + f + "\n" list_file.write(s) list_file.close() # add segD to ph5 testargs = ['segdtoph5', '-n', 'master', '-f', 'fcnt_list'] with patch.object(sys, 'argv', testargs): segd2ph5.main() # check that all deploy times are in array_t self.EX = tabletokef.EX = initialize_ex('master.ph5', '.', False) tabletokef.ARRAY_T = {} tabletokef.read_sort_table() tabletokef.read_sort_arrays() self.assertEqual(len(tabletokef.ARRAY_T), 1) self.assertEqual(tabletokef.ARRAY_T.keys()[0], "Array_t_001") self.assertEqual(len(tabletokef.ARRAY_T['Array_t_001'].rows), 9) # id_s 1111 SHOULD have 3 different times, # each has 3 rows for 3 channels time_count = {} for s in tabletokef.ARRAY_T['Array_t_001'].rows: if s['id_s'] == '1111': d = s['deploy_time/epoch_l'] if d not in time_count.keys(): time_count[d] = 0 time_count[d] += 1 self.assertDictEqual(time_count, { 1561831393: 3, 1563634018: 3, 1567269236: 3 })
def test_main(self): 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() testargs = [ 'resp_load', '-n', 'master.ph5', '-a', '1', '-i', os.path.join(self.home, 'ph5/test_data/metadata/input.csv') ] with patch.object(sys, 'argv', testargs): resp_load.main() self.ph5API_object = ph5api.PH5(path='.', nickname='master.ph5') # check array_t self.ph5API_object.read_array_t('Array_t_001') entries = self.ph5API_object.Array_t['Array_t_001']['byid']['500'][1] self.assertEqual(entries[0]['response_table_n_i'], 0) self.assertEqual(entries[0]['receiver_table_n_i'], 1) # check response_t response_t = self.ph5API_object.get_response_t_by_n_i(0) self.assertEqual(response_t['response_file_das_a'], '/Experiment_g/Responses_g/ZLAND3C_500_1_24') # check response data loaded for all response files listed in input.csv try: self.ph5API_object.ph5.get_node('/Experiment_g/Responses_g/', 'ZLAND3C_500_1_24') self.ph5API_object.ph5.get_node('/Experiment_g/Responses_g/', 'cmg3t') self.ph5API_object.ph5.get_node('/Experiment_g/Responses_g/', 'gs11v') self.ph5API_object.ph5.get_node('/Experiment_g/Responses_g/', 'rt125a_500_1_32') self.ph5API_object.ph5.get_node('/Experiment_g/Responses_g/', 'rt130_100_1_1') except tables.NoSuchNodeError as e: raise AssertionError(e)
def test_check_response_t(self): testargs = [ 'segdtoph5', '-n', 'master.ph5', '-U', '13N', '-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=self.tmpdir, nickname='master.ph5') self.ph5validate = ph5validate.PH5Validate(self.ph5API_object, '.') with LogCapture() as log: log.setLevel(logging.ERROR) ret = self.ph5validate.check_response_t() self.assertEqual(ret[0].error, [ "Response table does not contain any response file names. " "Check if resp_load has been run or if metadatatoph5 input " "contained response information." ]) self.assertEqual( log.records[0].msg, "Response table does not contain any response file names. " "Check if resp_load has been run or if metadatatoph5 input " "contained response information.")