def write_event(catalog):
f = open('<STR_LIT>', '<STR_LIT:w>')<EOL>for i, event in enumerate(catalog):<EOL><INDENT>try:<EOL><INDENT>evinfo = event.origins[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise IOError('<STR_LIT>')<EOL><DEDENT>try:<EOL><INDENT>Mag_1 = event.magnitudes[<NUM_LIT:0>].mag<EOL><DEDENT>except IndexError:<EOL><INDENT>Mag_1 = <NUM_LIT:0.0><EOL><DEDENT>try:<EOL><INDENT>t_RMS = event.origins[<NUM_LIT:0>].quality['<STR_LIT>']<EOL><DEDENT>except AttributeError:<EOL><INDENT>print('<STR_LIT>')<EOL>t_RMS = <NUM_LIT:0.0><EOL><DEDENT>f.write(str(evinfo.time.year) + str(evinfo.time.month).zfill(<NUM_LIT:2>) +<EOL>str(evinfo.time.day).zfill(<NUM_LIT:2>) + '<STR_LIT:U+0020>' +<EOL>str(evinfo.time.hour).rjust(<NUM_LIT:2>) +<EOL>str(evinfo.time.minute).zfill(<NUM_LIT:2>) +<EOL>str(evinfo.time.second).zfill(<NUM_LIT:2>) +<EOL>str(evinfo.time.microsecond)[<NUM_LIT:0>:<NUM_LIT:2>].zfill(<NUM_LIT:2>) + '<STR_LIT:U+0020>' +<EOL>str(evinfo.latitude).ljust(<NUM_LIT:8>, str('<STR_LIT:0>')) + '<STR_LIT:U+0020>' +<EOL>str(evinfo.longitude).ljust(<NUM_LIT:8>, str('<STR_LIT:0>')) + '<STR_LIT:U+0020>' +<EOL>str(evinfo.depth / <NUM_LIT:1000>).rjust(<NUM_LIT:7>).ljust(<NUM_LIT:9>, str('<STR_LIT:0>')) + '<STR_LIT:U+0020>' +<EOL>str(Mag_1) + '<STR_LIT>' +<EOL>str(t_RMS).ljust(<NUM_LIT:4>, str('<STR_LIT:0>')) +<EOL>str(i).rjust(<NUM_LIT:11>) + '<STR_LIT:\n>')<EOL><DEDENT>f.close()<EOL>return<EOL>
Write obspy.core.event.Catalog to a hypoDD format event.dat file.

:type catalog: obspy.core.event.Catalog
:param catalog: A catalog of obspy events.