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.
513668
def write_event(catalog):
    
    f = open('event.dat', 'w')
    for i, event in enumerate(catalog):
        try:
            evinfo = event.origins[0]
        except IndexError:
            raise IOError('No origin')
        try:
            Mag_1 = event.magnitudes[0].mag
        except IndexError:
            Mag_1 = 0.0
        try:
            t_RMS = event.origins[0].quality['standard_error']

        except AttributeError:
            print('No time residual in header')
            t_RMS = 0.0
        f.write(str(evinfo.time.year) + str(evinfo.time.month).zfill(2) +
                str(evinfo.time.day).zfill(2) + '  ' +
                str(evinfo.time.hour).rjust(2) +
                str(evinfo.time.minute).zfill(2) +
                str(evinfo.time.second).zfill(2) +
                str(evinfo.time.microsecond)[0:2].zfill(2) + '  ' +
                str(evinfo.latitude).ljust(8, str('0')) + '   ' +
                str(evinfo.longitude).ljust(8, str('0')) + '  ' +
                str(evinfo.depth / 1000).rjust(7).ljust(9, str('0')) + '   ' +
                str(Mag_1) + '    0.00    0.00   ' +
                str(t_RMS).ljust(4, str('0')) +
                str(i).rjust(11) + '\n')
    f.close()
    return
1085463
def add_dirrecord(self, rec):
        # type: (Union[dr.DirectoryRecord, udfmod.UDFFileEntry]) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('El Torito Boot Catalog not yet initialized')

        self.dirrecords.append(rec)
443914
def install_catalogs(self):
        
        cmd_obj = self.distribution.get_command_obj('catalogs')
        cmd_obj.force = self.force
        if self.ugali_dir: cmd_obj.ugali_dir = self.ugali_dir
        self.run_command('catalogs')
1316126
public static <T> void writeListTo(OutputStream out, List<T> messages, 
            Schema<T> schema, boolean numeric) throws IOException
    {
        final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), 
                out, false);
        
        final JsonGenerator generator = newJsonGenerator(out, 
                context.allocWriteEncodingBuffer(), 0, true, context);
        /*final JsonGenerator generator = DEFAULT_JSON_FACTORY.createJsonGenerator(out, 
                JsonEncoding.UTF8);*/
        try
        {
            writeListTo(generator, messages, schema, numeric);
        }
        finally
        {
            generator.close();
        }
    }
678076
def _make_xml_files(catalog_info_dict, comp_info_dict):
        
        for val in catalog_info_dict.values():
            val.roi_model.write_xml(val.srcmdl_name)

        for val in comp_info_dict.values():
            for val2 in val.values():
                val2.roi_model.write_xml(val2.srcmdl_name)
351840
void write(String prefix, File catalog) throws IOException {
		File backup = File.createTempFile(prefix, null, catalog.getParentFile());
		if (catalog.exists()) {
			// Create a copy of the current state
			Files.copy(catalog.toPath(), backup.toPath(), StandardCopyOption.REPLACE_EXISTING);
		}

		// Update the file
		try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(catalog))) {
			oos.writeObject(this);
			backup.delete();
		} catch (IOException e) {
			try {
				Files.move(backup.toPath(), catalog.toPath(), StandardCopyOption.ATOMIC_MOVE);
			} catch (IOException e2) {
				logger.log(Level.INFO, "A backup has been saved at: " + backup, e2);
			}
			throw new IOException("Failed to update file: " + catalog, e);
		}
	}
968673
def WriteEvent(self, event):
    
    self.WriteEventStart()

    try:
      self.WriteEventBody(event)

    except errors.NoFormatterFound as exception:
      error_message = 'unable to retrieve formatter with error: {0!s}'.format(
          exception)
      self._ReportEventError(event, error_message)

    except errors.WrongFormatter as exception:
      error_message = 'wrong formatter with error: {0!s}'.format(exception)
      self._ReportEventError(event, error_message)

    self.WriteEventEnd()
1340832
def generateXY(self, **kwargs):
        
        self.num_objects = 0
        xycols = self._readCatalog()

        if xycols is not None:
            # convert the catalog into attribute
            self.xypos = xycols[:3]
            # convert optional columns if they are present
            if self.numcols > 3:
                self.xypos.append(np.asarray(xycols[3], dtype=int)) # source ID
            if self.numcols > 4:
                self.sharp = xycols[4]
            if self.numcols > 5:
                self.round1 = xycols[5]
            if self.numcols > 6:
                self.round2 = xycols[6]
            self.num_objects = len(xycols[0])

        if self.numcols < 3: # account for flux column
            self.xypos.append(np.zeros(self.num_objects, dtype=float))
            self.flux_col = False

        if self.numcols < 4: # add source ID column
            self.xypos.append(np.arange(self.num_objects)+self.start_id)

        if self.use_sharp_round:
            for i in range(len(self.xypos), 7):
                self.xypos.append(np.zeros(self.num_objects, dtype=float))
            self.sharp_col = False

        if self.pars['xyunits'] == 'degrees':
            self.radec = [x.copy() for x in self.xypos]
            if self.wcs is not None:
                self.xypos[:2] = list(self.wcs.all_world2pix(np.array(self.xypos[:2]).T, self.origin).T)
375117
def write_loom(self, filename: PathLike, write_obsm_varm: bool = False):
        
        from .readwrite.write import write_loom
        write_loom(filename, self, write_obsm_varm = write_obsm_varm)
1089732
def get_catalogue_header_value(cls, catalog, key):
        """"""
        header_value = None
        if '' in catalog:
            for line in catalog[''].split('\n'):
                if line.startswith('%s:' % key):
                    header_value = line.split(':', 1)[1].strip()

        return header_value
566886
def sfiles_to_event(sfile_list):
    
    event_list = []
    sort_list = [(readheader(sfile).origins[0].time, sfile)
                 for sfile in sfile_list]
    sort_list.sort(key=lambda tup: tup[0])
    sfile_list = [sfile[1] for sfile in sort_list]
    catalog = Catalog()
    for i, sfile in enumerate(sfile_list):
        event_list.append((i, sfile))
        catalog.append(readheader(sfile))
    # Hand off to sister function
    write_event(catalog)
    return event_list
95483
def make_header(self, locale, catalog):
        """"""
        return {
            "po-revision-date": self.get_catalogue_header_value(catalog, 'PO-Revision-Date'),
            "mime-version": self.get_catalogue_header_value(catalog, 'MIME-Version'),
            "last-translator": 'Automatic <hi@thorgate.eu>',
            "x-generator": "Python",
            "language": self.get_catalogue_header_value(catalog, 'Language') or locale,
            "lang": locale,
            "content-transfer-encoding": self.get_catalogue_header_value(catalog, 'Content-Transfer-Encoding'),
            "project-id-version": self.get_catalogue_header_value(catalog, 'Project-Id-Version'),
            "pot-creation-date": self.get_catalogue_header_value(catalog, 'POT-Creation-Date'),
            "domain": self.domain,
            "report-msgid-bugs-to": self.get_catalogue_header_value(catalog, 'Report-Msgid-Bugs-To'),
            "content-type": self.get_catalogue_header_value(catalog, 'Content-Type'),
            "plural-forms": self.get_plural(catalog),
            "language-team": self.get_catalogue_header_value(catalog, 'Language-Team')
        }
1004036
public static void write(ClassificationDataSet data, OutputStream os)
    {
        PrintWriter writer = new PrintWriter(os);
        for(int i = 0; i < data.size(); i++)
        {
            int pred = data.getDataPointCategory(i);
            Vec vals = data.getDataPoint(i).getNumericalValues();
            writer.write(pred + " ");
            for(IndexValue iv : vals)
            {
                double val = iv.getValue();
                if(Math.rint(val) == val)//cast to long before writting to save space
                    writer.write((iv.getIndex()+1) + ":" + (long)val + " ");//+1 b/c 1 based indexing
                else
                    writer.write((iv.getIndex()+1) + ":" + val + " ");//+1 b/c 1 based indexing
            }
            writer.write("\n");
        }
        writer.flush();
        writer.close();
    }
11674
def Write(self, outpath):
    ""
    out = zipfile.ZipFile(outpath, mode="w", compression=zipfile.ZIP_DEFLATED)
    for filename, func in [('agency.txt', self.WriteAgency),
                           ('calendar.txt', self.WriteCalendar),
                           ('calendar_dates.txt', self.WriteCalendarDates),
                           ('routes.txt', self.WriteRoutes),
                           ('trips.txt', self.WriteTrips),
                           ('stops.txt', self.WriteStations),
                           ('stop_times.txt', self.WriteStopTimes)]:
      s = cStringIO.StringIO()
      func(s)
      out.writestr(filename, s.getvalue())
    out.close()
557771
def write(self, symbol, data, prune_previous_version=True, metadata=None, **kwargs):
        
        if data is not None:
            # We only write data if existing data is None or the Timeseries data has changed or metadata has changed
            if self.base_ts.data is None or not are_equals(data, self.base_ts.data) or metadata != self.base_ts.metadata:
                self._do_write = True
        self._write = partial(self._version_store.write, symbol, data, prune_previous_version=prune_previous_version,
                              metadata=metadata, **kwargs)
1329205
function writeManifest (archive, manifest, cb) {
  manifest = generateManifest(manifest)
  return writeFile(archive, DAT_MANIFEST_FILENAME, JSON.stringify(manifest, null, 2), cb)
}
1345046
def load_global_catalog():
    """"""
    cat_dir = global_data_dir()
    if not os.path.isdir(cat_dir):
        return Catalog()
    else:
        return YAMLFilesCatalog(cat_dir)