Coverage for /opt/obspy/update-docs/src/obspy/obspy/xseed/utils : 76%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- Various additional utilities for ObsPy xseed.
:copyright: The ObsPy Development Team (devs@obspy.org) :license: GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html) """
# Ignore Attributes of Blockettes 'seed_version', 'strict', 'xseed_version', 'length_of_blockette', 'blockette_type']
""" Creates a XML tag from a given string. """
""" Creates a pretty string from any given XML tag. """ temp = tag.replace('_', ' ').title() temp = temp.replace('Fir', 'FIR') return temp
""" Generates a valid SEED time string from a UTCDateTime object. """ except: raise Exception("Invalid datetime %s: %s" % (type(dt), str(dt)))
""" Compares two SEED files.
Only works with a record length of 4096 bytes. """ # Each SEED string should be a multiple of the record length. msg = "Length of first SEED string should be a multiple of 4096 bytes" raise Exception(msg) msg = "Length of second SEED string should be a multiple of 4096 bytes" raise Exception(msg) # Loop over each record and remove empty ones. obspy.xseed doesn't write # empty records. Redundant code to ease coding... continue continue # length should be the same msg = "Length of SEED strings differ! (%d != %d)" % (len(seed1), len(seed2)) raise Exception(msg) # version string is always ' 2.4' for output seed1 = seed1.replace(' 2.3', ' 2.4', 1) # check for missing '~' in blockette 10 (faulty dataless from BW network) # added a '~' and remove a space before the next record # record length for now 4096 seed1[(l + 8):4095] + seed1[4096:] # check each byte # -056.996398+0031.0 # -56.996398 +31.0 continue
lookup_code_number): """ Loops over a list of blockettes until it finds the blockette with the right number and lookup code. """ # List of all possible names for lookup return None
""" Formats a number according to the RESP format. """
""" Gets certain values from blockette 34. Needed for RESP output. """ lookup) except: msg = '\nWarning: Abbreviation reference not found.' sys.stdout.write(msg) return 'No Abbreviation Referenced'
""" Returns an X-Path String to a blockette with the correct identifier. """ except: msg = 'X-Path identifier needs to be an integer.' raise TypeError(msg) 'data_format_dictionary/data_format_identifier_code' + \ end_of_path % identifier 'comment_description/comment_code_key' + \ end_of_path % identifier 'generic_abbreviation/abbreviation_lookup_code' + \ end_of_path % identifier 'units_abbreviations/unit_lookup_code' + \ end_of_path % identifier # All dictionary blockettes. '*/response_lookup_key' + \ end_of_path % identifier msg = 'XPath for blockette %d not implemented yet.' % blockette raise NotImplementedError(msg)
""" Returns lookup key of XPath expression on abbreviation dictionary. """
# Not order preserving keys = {} for e in seq: keys[e] = 1 return keys.keys() |