# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
datacube, suds, css, gse2)
'seisan.l', 'seisan.b', 'kan', 'yaff', 'gse1', 'gse2', 'gcf', 'datacube', 'suds', 'css']
for fmt in lst)
else:
'''Load traces from file.
:param format: format of the file (%s) :param getdata: if ``True`` (the default), read data, otherwise only read traces metadata :param substitutions: dict with substitutions to be applied to the traces metadata
:returns: list of loaded traces
When *format* is set to ``'detect'``, the file type is guessed from the first 512 bytes of the file. Only Mini-SEED, SAC, GSE1, and YAFF format are detected. When *format* is set to ``'from_extension'``, the filename extension is used to decide what format should be assumed. The filename extensions considered are (matching is case insensitive): ``'.sac'``, ``'.kan'``, ``'.sgy'``, ``'.segy'``, ``'.yaff'``, everything else is assumed to be in Mini-SEED format.
This function calls :py:func:`iload` and aggregates the loaded traces in a list. '''
filename, format=format, getdata=getdata, substitutions=substitutions))
except OSError as e: raise FileLoadError(e) finally:
(yaff, 'yaff'), (mseed, 'mseed'), (sac, 'sac'), (gse1, 'gse1'), (gse2, 'gse2'), (datacube, 'datacube'), (suds, 'suds')]:
raise FileLoadError(UnknownFormat(filename))
'''Load traces from file (iterator version).
This function works like :py:func:`load`, but returns an iterator which yields the loaded traces. '''
format, subformat = toks else:
except OSError as e: raise FileLoadError(e)
'.yaff': 'yaff', '.sac': 'sac', '.kan': 'kan', '.segy': 'segy', '.sgy': 'segy', '.gse': 'gse2', '.wfdisc': 'css'}
format = 'mseed' extension = os.path.splitext(filename)[1] format = extension_to_format.get(extension.lower(), 'mseed')
'kan': kan, 'segy': segy, 'yaff': yaff, 'sac': sac, 'mseed': mseed, 'seisan': seisan_waveform, 'gse1': gse1, 'gse2': gse2, 'gcf': gcf, 'datacube': datacube, 'suds': suds, 'css': css, }
'seisan': {'subformat': subformat}, }
raise UnsupportedFormat(format)
filename, load_data=load_data, **add_args.get(format, {})):
stations=None, overwrite=True, **kwargs): '''Save traces to file(s).
:param traces: a trace or an iterable of traces to store :param filename_template: filename template with placeholders for trace metadata. Uses normal python '%%(placeholder)s' string templates. The following placeholders are considered: ``network``, ``station``, ``location``, ``channel``, ``tmin`` (time of first sample), ``tmax`` (time of last sample), ``tmin_ms``, ``tmax_ms``, ``tmin_us``, ``tmax_us``. The versions with '_ms' include milliseconds, the versions with '_us' include microseconds. :param format: %s :param additional: dict with custom template placeholder fillins. :param overwrite': if ``False``, raise an exception if file exists :returns: list of generated filenames
.. note:: Network, station, location, and channel codes may be silently truncated to file format specific maximum lengthes. '''
format = os.path.splitext(filename_template)[1][1:]
overwrite=overwrite, **kwargs)
overwrite=overwrite, **kwargs)
raise FileSaveError('file exists: %s' % fn)
raise FileSaveError('file just created would be overwritten: ' '%s (multiple traces map to same filename)' % fn)
raise FileSaveError('file exists: %s' % fn)
raise FileSaveError('file just created would be overwritten: ' '%s (multiple traces map to same filename)' % fn)
overwrite=overwrite, **kwargs) else: raise UnsupportedFormat(format)
Exception.__init__(self, 'Unknown file format: %s' % filename)
Exception.__init__(self, 'Unsupported file format: %s' % format)
tr.set_codes(**substitutions) |