Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve metadatatoph5 references in ph5_validate and ph5tostationxml #547

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ ph5.clients.tests.test_ph5toms
ph5.utilities.validation
* keep common validation for both ph5tostationxml and ph5validate
* Check for location errors and warnings
* Add 'deprecated tool' as prefix for metadatatoph5 when checking response
ph5.clients.ph5tostationxml
* Limit number of asynchronous processes
* Remove storage format from the sxml channel level to be compatible with sxml version 1.1
Expand Down
8 changes: 4 additions & 4 deletions ph5/clients/tests/test_ph5tostationxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_get_response_inv(self):
set([("array 003 station 0407, channel 1: Response_t[6]:"
"response_file_das_a 'NoneQ330_NoneCMG3T_100LHN' is "
"inconsistent with Array_t_003:das_model=rt125a. "
"Please check with metadatatoph5 format "
"Please check with deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha]).", 'error')
]))
Expand Down Expand Up @@ -407,7 +407,7 @@ def test_create_obs_network(self):
{"array 002 station 0407, channel 1: Response_t[5]:"
"response_file_das_a 'NoneQ330_NoneCMG3T_200HHN' is "
"inconsistent with Array_t_002:sensor_model=CMG. Please "
"check with metadatatoph5 format "
"check with deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha]).",
"array 008 station 8001, channel 1: Response_t[1]:"
Expand Down Expand Up @@ -452,8 +452,8 @@ def test_read_networks_no_resp_filename(self):
self.assertEqual(
contxt.exception.message,
"Response table does not contain any response file names. "
"Check if resp_load has been run or if metadatatoph5 input "
"contained response information.")
"Check if resp_load has been run or if deprecated tool "
"metadatatoph5 input contained response information.")

def test_read_networks_response_duplication(self):
# response_t_dup_n_i.kef has n_i= 1,3,6 duplicated
Expand Down
8 changes: 4 additions & 4 deletions ph5/utilities/tests/test_ph5validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,13 +637,13 @@ def test_check_response_t(self):
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."])
"Check if resp_load has been run or if deprecated tool "
"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.")
"Check if resp_load has been run or if deprecated tool "
"metadatatoph5 input contained response information.")


class TestPH5Validate_das_t_order(LogTestCase, TempDirTestCase):
Expand Down
20 changes: 11 additions & 9 deletions ph5/utilities/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def test_check_metadatatoph5_format(self):
err = ("array 002, station 0407, channel 1: Response_t[5]:"
"response_file_das_a 'NoneQ330_CMG3T_200HHN' is inconsistent "
"with Array_t_002:sensor_model=None CMG-3T. Please check with "
"metadatatoph5 format [das_model]_[sensor_model]_[sr][cha] "
"deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha]).")
with LogCapture() as log:
log.setLevel(logging.ERROR)
Expand Down Expand Up @@ -185,7 +186,7 @@ def test_check_metadatatoph5_format(self):
'/Experiment_g/Responses_g/NoneQ330_NoneCMG3T'
err = ("array 002, station 0407, channel 1: Response_t[5]:"
"response_file_das_a 'NoneQ330_NoneCMG3T' is incomplete. "
"Please check with metadatatoph5 format "
"Please check with deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha])."
)
Expand Down Expand Up @@ -259,8 +260,8 @@ def test_check_das_resp_load_format(self):
"inconsistent with "
"Array_t_002:sr=200 Array_t_002:sensor_model=None CMG-3T "
"Array_t_002:srm=1. Please check with resp_load format "
"[das_model]_[sr]_[srm]_[gain] or metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"[das_model]_[sr]_[srm]_[gain] or deprecated tool metadatatoph5"
" format [das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha]).")
with LogCapture() as log:
log.setLevel(logging.ERROR)
Expand All @@ -282,8 +283,8 @@ def test_check_das_resp_load_format(self):
"incomplete or inconsistent with Array_t_002:sr=200 "
"Array_t_002:sensor_model=None CMG-3T. "
"Please check with resp_load format "
"[das_model]_[sr]_[srm]_[gain] or metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"[das_model]_[sr]_[srm]_[gain] or deprecated tool metadatatoph5"
" format [das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha]).")
with LogCapture() as log:
log.setLevel(logging.ERROR)
Expand Down Expand Up @@ -420,8 +421,8 @@ def test_check_response_info(self):
chckerrors = set(
["array 002 station 0407, channel 1: Response_t[5]:"
"response_file_das_a 'NoneQ330_NoneCMG3T_200HHN' is inconsistent "
"with Array_t_002:das_model=Q330. Please check with "
"metadatatoph5 format [das_model]_[sensor_model]_[sr][cha] "
"with Array_t_002:das_model=Q330. Please check with deprecated "
"tool metadatatoph5 format [das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha])."])
with LogCapture() as log:
log.setLevel(logging.WARNING)
Expand Down Expand Up @@ -491,7 +492,8 @@ def test_check_has_response_filename(self):
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.")
"deprecated tool metadatatoph5 input contained "
"response information.")


class TestValidation_location(unittest.TestCase):
Expand Down
20 changes: 11 additions & 9 deletions ph5/utilities/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def check_metadatatoph5_format(Response_t, info, header, errors, logger):
:return:
if there are more than 3 parts return False
if all (3) parts pass checks return True
if 2 parts pass checks, decide that this is created from metadatatoph5
return True and log as error
if 2 parts pass checks, decide that this is created from deprecated
tool metadatatoph5 return True and log as error.
if less than 2 parts pass checks return incomplete_errmsg, m_check_fail
to be included if check for resp_load format also failed.
"""
Expand Down Expand Up @@ -113,7 +113,7 @@ def check_metadatatoph5_format(Response_t, info, header, errors, logger):
if m_check_fail != set([]) or incomplete_errmsg != '':
errmsg = combine_errors(m_check_fail, incomplete_errmsg, info)
errmsg = ("{0}Response_t[{1}]:response_file_das_a '{2}' is {3}. "
"Please check with metadatatoph5 format "
"Please check with deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha])."
).format(header,
Expand Down Expand Up @@ -148,8 +148,9 @@ def check_das_resp_load_format(Response_t, info, header, errors, logger,
+ if 3 parts corrects, decide this is created from resp_load so
errmsg only includes resp_load's checks and format
+ if less than 3 parts corrects, cannot decide this is created from
resp_load or metadatatoph5, so errmsg includes resp_load's
checks and formats and metadatatoph5's if m_check_ret!=True
resp_load or deprecated tool metadatatoph5, so errmsg includes
resp_load's checks and formats and deprecated tool metadatatoph5's
if m_check_ret!=True
"""
if Response_t['response_file_das_a'] == '':
# blank response_file_das_a return False in check_response_info
Expand All @@ -158,7 +159,8 @@ def check_das_resp_load_format(Response_t, info, header, errors, logger,
info['gain'] = Response_t['gain/value_i']
response_fname = Response_t['response_file_das_a'].split('/')[-1]
r_format = "resp_load format [das_model]_[sr]_[srm]_[gain]"
m_format = ("metadatatoph5 format [das_model]_[sensor_model]_[sr][cha] "
m_format = ("deprecated tool metadatatoph5 format "
"[das_model]_[sensor_model]_[sr][cha] "
"(check doesn't include [cha])")
parts = response_fname.split('_')
if len(parts) > 4:
Expand Down Expand Up @@ -205,7 +207,7 @@ def check_das_resp_load_format(Response_t, info, header, errors, logger,
r_format)
else:
# if less than 3 parts correct, include the check and format
# of checking metadatatoph5 format to error message
# of checking deprecated tool metadatatoph5 format to error message
if incomplete_errmsg != 'incomplete':
incomplete_errmsg = m_check_ret[0]
for c in m_check_ret[1]:
Expand Down Expand Up @@ -342,8 +344,8 @@ def check_has_response_filename(Response_t, errors, logger):
if entry['response_file_das_a'] != '':
return True
errmsg = ("Response table does not contain any response file names. "
"Check if resp_load has been run or if metadatatoph5 input "
"contained response information.")
"Check if resp_load has been run or if deprecated tool "
"metadatatoph5 input contained response information.")
addLog(errmsg, errors, logger)
return errmsg

Expand Down
Loading