def read_phase(ph_file):
ph_catalog = Catalog()<EOL>f = open(ph_file, '<STR_LIT:r>')<EOL>for line in f:<EOL><INDENT>if line[<NUM_LIT:0>] == '<STR_LIT:#>':<EOL><INDENT>if '<STR_LIT>' not in locals():<EOL><INDENT>event_text = {'<STR_LIT>': line.rstrip(),<EOL>'<STR_LIT>': []}<EOL><DEDENT>else:<EOL><INDENT>ph_catalog.append(_phase_to_event(event_text))<EOL>event_text = {'<STR_LIT>': line.rstrip(),<EOL>'<STR_LIT>': []}<EOL><DEDENT><DEDENT>else:<EOL><INDENT>event_text['<STR_LIT>'].append(line.rstrip())<EOL><DEDENT><DEDENT>ph_catalog.append(_phase_to_event(event_text))<EOL>return ph_catalog<EOL>
Read hypoDD phase files into Obspy catalog class.

:type ph_file: str
:param ph_file: Phase file to read event info from.

:returns: Catalog of events from file.
:rtype: :class:`obspy.core.event.Catalog`

>>> from obspy.core.event.catalog import Catalog
>>> # Get the path to the test data
>>> import eqcorrscan
>>> import os
>>> TEST_PATH = os.path.dirname(eqcorrscan.__file__) + '/tests/test_data'
>>> catalog = read_phase(TEST_PATH + '/tunnel.phase')
>>> isinstance(catalog, Catalog)
True