obspy.io.xseed.parser.Parser

class Parser(data=None, debug=False, strict=False, compact=False)[source]

Bases: object

Class parsing dataless and full SEED, X-SEED, and RESP files.

See also

The SEED file format description can be found at https://www.fdsn.org/seed_manual/SEEDManual_V2.4.pdf .

The XML-SEED format was proposed in [Tsuboi2004].

The IRIS RESP format can be found at http://ds.iris.edu/ds/nodes/dmc/data/formats/resp/

Public Methods

get_coordinates

Return coordinates (from blockette 52) of a channel.

get_inventory

Function returning a dictionary about whats actually in the Parser object.

get_paz

Return PAZ.

get_resp

Returns a RESP representation of the current Parser object.

get_response_for_channel

Create an ObsPy response object from all blockettes of a channel.

get_seed

Returns a SEED representation of the current Parser object.

get_xseed

Returns a XSEED representation of the current Parser object.

read

General parser method for XML-SEED, Dataless SEED, and RESP files.

resolve_abbreviation

rotate_to_zne

Rotates the three components of a Stream to ZNE.

write_resp

Writes for each channel a RESP file within a given folder.

write_seed

Writes a dataless SEED file with given name.

write_xseed

Writes a XML-SEED file with given name.

Private Methods

Warning

Private methods are mainly for internal/developer use and their API might change without notice.

Parser._check_blockettes()[source]

Checks if all blockettes necessary for creating a SEED String are available.

Parser._compare_blockettes(blkt1, blkt2)[source]

Compares two blockettes.

Parser._create_blockettes_11_and_12(blockette12=False)[source]

Creates blockettes 11 and 12 for SEED writing and XSEED version 1.1 writing.

Parser._create_cut_and_flush_record(blockettes, record_type)[source]

Takes all blockettes of a record and return a list of finished records.

If necessary it will cut the record and return two or more flushed records.

The returned records also include the control header type code and the record continuation code. Therefore the returned record will have the length self.record_length - 6. Other methods are responsible for writing the sequence number.

It will always return a list with records.

Parser._delete_blockettes_11_and_12()[source]

Deletes blockette 11 and 12.

Parser._get_abbreviation(identifier_code)[source]

Helper function returning the abbreviation for the given identifier code.

Parser._get_resp_string(resp, blockettes, station)[source]

Takes a file like object and a list of blockettes containing all blockettes for one channel and writes them RESP like to the BytesIO.

Parser._parse_merged_data(data, record_type)[source]

This method takes any merged SEED record and writes its blockettes in the corresponding dictionary entry of self.temp.

Parser._parse_resp(data)[source]

Reads RESP files.

Reads IRIS RESP formatted data as produced with ‘rdseed -f seed.test -R’.

Parser._parse_seed(data)[source]

Parses through a whole SEED volume.

It will always parse the whole file and skip any time span data.

Parser._parse_xml_blockette(xml_blockette, record_type, xseed_version)[source]

Takes the lxml tree of any blockette and returns a blockette object.

Parser._parse_xseed(data)[source]

Parse a XML-SEED string.

Parser._repr_pretty_(p, cycle)[source]
Parser._select(seed_id, datetime=None)[source]

Selects all blockettes related to given SEED id and datetime.

Parser._update_internal_seed_structure()[source]

Takes everything in the self.temp dictionary and writes it into the volume, abbreviations and stations attributes of the class.

The self.temp dictionary can only contain one seed volume with a correct structure.

This method will try to merge everything, discard double entries and adjust abbreviations.

It will also discard unnecessary blockettes that will be created again when writing SEED or XSEED.

Parser._update_temporary_stations(blkt_id, index_nr)[source]

Loops over all stations, finds the corresponding blockettes and changes all abbreviation lookup codes.

Special Methods

Parser.__delattr__(name, /)

Implement delattr(self, name).

Parser.__dir__()

Default dir() implementation.

Parser.__eq__(value, /)

Return self==value.

Parser.__format__(format_spec, /)

Default object formatter.

Parser.__ge__(value, /)

Return self>=value.

Parser.__getattribute__(name, /)

Return getattr(self, name).

Parser.__gt__(value, /)

Return self>value.

Parser.__hash__()

Return hash(self).

Parser.__init__(data=None, debug=False, strict=False, compact=False)[source]

Initializes the SEED parser.

Parameters:
  • data (str, bytes, io.BytesIO or file) – Filename, URL, XSEED/SEED/RESP string, file pointer or BytesIO.

  • debug (bool) – Enables a verbose debug log during parsing of SEED file.

  • strict (bool) – Parser will raise an exception if SEED files does not stay within the SEED specifications.

  • compact (bool) – SEED volume will contain compact data strings. Missing time strings will be filled with 00:00:00.0000 if this option is disabled.

Parser.__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

Parser.__le__(value, /)

Return self<=value.

Parser.__lt__(value, /)

Return self<value.

Parser.__ne__(value, /)

Return self!=value.

Parser.__new__(**kwargs)
Parser.__reduce__()

Helper for pickle.

Parser.__reduce_ex__(protocol, /)

Helper for pickle.

Parser.__repr__()

Return repr(self).

Parser.__setattr__(name, value, /)

Implement setattr(self, name, value).

Parser.__sizeof__()

Size of object in memory, in bytes.

Parser.__str__()[source]
Parser.__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).