Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Blockette044(Blockette):
"""
Blockette 044: Response (Coefficients) Dictionary Blockette.
See Response (Coefficients) Dictionary Blockette [54] for more information.
"""
id = 44
name = "Response Coefficients Dictionary"
fields = [
Integer(3, "Response Lookup Key", 4),
VariableString(4, "Response Name", 1, 25, 'UN_'),
FixedString(5, "Response type", 1, 'U'),
Integer(6, "Signal input units", 3, xpath = 34),
Integer(7, "Signal output units", 3, xpath = 34),
Integer(8, "Number of numerators", 4),
# REPEAT fields 9 - 10 for the Number of numerators:
Loop('Numerators', "Number of numerators", [
Float(9, "Numerator coefficient", 12, mask='%+1.5e'),
Float(10, "Numerator error", 12, mask='%+1.5e')
], flat=True),
Integer(11, "Number of denominators", 4),
# REPEAT fields 12 — 13 for the Number of denominators:
Loop('Denominators', "Number of denominators", [
Float(12, "Denominator coefficient", 12, mask='%+1.5e'),
Float(13, "Denominator error", 12, mask='%+1.5e')
], flat=True)
]
# Changes the name of the blockette because of an error in XSEED 1.0
def getXML(self, *args, **kwargs):
xml = Blockette.getXML(self, *args, **kwargs)
class Blockette052(Blockette):
"""
Blockette 052: Channel Identifier Blockette.
Sample:
0520119 BHE0000004~001002+34.946200-106.456700+1740.0100.0090.0+00.0000112
2.000E+01 2.000E-030000CG~1991,042,20:48~~N
"""
id = 52
name = "Channel Identifier"
fields = [
FixedString(3, "Location identifier", 2, 'UN'),
FixedString(4, "Channel identifier", 3, 'UN'),
Integer(5, "Subchannel identifier", 4),
Integer(6, "Instrument identifier", 3, xpath=33),
VariableString(7, "Optional comment", 0, 30, 'UNLPS'),
Integer(8, "Units of signal response", 3, xpath=34),
Integer(9, "Units of calibration input", 3, xpath=34),
Float(10, "Latitude", 10, mask='%+2.6f'),
Float(11, "Longitude", 11, mask='%+3.6f'),
Float(12, "Elevation", 7, mask='%+4.1f'),
Float(13, "Local depth", 5, mask='%3.1f'),
Float(14, "Azimuth", 5, mask='%3.1f'),
Float(15, "Dip", 5, mask='%+2.1f'),
Integer(16, "Data format identifier code", 4, xpath=30),
# The typo is intentional for XSEED 1.0 compatibility.
Integer(17, "Data record length", 2, xseed_version='1.0',
xml_tag="data_recored_length"),
Integer(17, "Data record length", 2, xseed_version='1.1'),
Float(18, "Sample rate", 10, mask='%1.4e'),
name = "Channel Identifier"
fields = [
FixedString(3, "Location identifier", 2, 'UN'),
FixedString(4, "Channel identifier", 3, 'UN'),
Integer(5, "Subchannel identifier", 4),
Integer(6, "Instrument identifier", 3, xpath=33),
VariableString(7, "Optional comment", 0, 30, 'UNLPS'),
Integer(8, "Units of signal response", 3, xpath=34),
Integer(9, "Units of calibration input", 3, xpath=34),
Float(10, "Latitude", 10, mask='%+2.6f'),
Float(11, "Longitude", 11, mask='%+3.6f'),
Float(12, "Elevation", 7, mask='%+4.1f'),
Float(13, "Local depth", 5, mask='%3.1f'),
Float(14, "Azimuth", 5, mask='%3.1f'),
Float(15, "Dip", 5, mask='%+2.1f'),
Integer(16, "Data format identifier code", 4, xpath=30),
# The typo is intentional for XSEED 1.0 compatibility.
Integer(17, "Data record length", 2, xseed_version='1.0',
xml_tag="data_recored_length"),
Integer(17, "Data record length", 2, xseed_version='1.1'),
Float(18, "Sample rate", 10, mask='%1.4e'),
Float(19, "Max clock drift", 10, mask='%1.4e'),
Integer(20, "Number of comments", 4),
VariableString(21, "Channel flags", 0, 26, 'U'),
VariableString(22, "Start date", 1, 22, 'T'),
VariableString(23, "End date", 0, 22, 'T', optional=True,
xseed_version='1.0'),
VariableString(23, "End date", 0, 22, 'T', xseed_version='1.1'),
FixedString(24, "Update flag", 1)
]
Blockette 052: Channel Identifier Blockette.
Sample:
0520119 BHE0000004~001002+34.946200-106.456700+1740.0100.0090.0+00.0000112
2.000E+01 2.000E-030000CG~1991,042,20:48~~N
"""
id = 52
name = "Channel Identifier"
fields = [
FixedString(3, "Location identifier", 2, 'UN'),
FixedString(4, "Channel identifier", 3, 'UN'),
Integer(5, "Subchannel identifier", 4),
Integer(6, "Instrument identifier", 3, xpath=33),
VariableString(7, "Optional comment", 0, 30, 'UNLPS'),
Integer(8, "Units of signal response", 3, xpath=34),
Integer(9, "Units of calibration input", 3, xpath=34),
Float(10, "Latitude", 10, mask='%+2.6f'),
Float(11, "Longitude", 11, mask='%+3.6f'),
Float(12, "Elevation", 7, mask='%+4.1f'),
Float(13, "Local depth", 5, mask='%3.1f'),
Float(14, "Azimuth", 5, mask='%3.1f'),
Float(15, "Dip", 5, mask='%+2.1f'),
Integer(16, "Data format identifier code", 4, xpath=30),
# The typo is intentional for XSEED 1.0 compatibility.
Integer(17, "Data record length", 2, xseed_version='1.0',
xml_tag="data_recored_length"),
Integer(17, "Data record length", 2, xseed_version='1.1'),
Float(18, "Sample rate", 10, mask='%1.4e'),
Float(19, "Max clock drift", 10, mask='%1.4e'),
Integer(20, "Number of comments", 4),
VariableString(21, "Channel flags", 0, 26, 'U'),
from obspy.xseed.blockette import Blockette
from obspy.xseed.fields import Float, Integer, VariableString
from obspy.xseed.utils import formatRESP
class Blockette047(Blockette):
"""
Blockette 047: Decimation Dictionary Blockette.
See Decimation Blockette [57] for more information.
"""
id = 47
name = "Decimation Dictionary"
fields = [
Integer(3, "Response Lookup Key", 4),
VariableString(4, "Response Name", 1, 25, 'UN_'),
Float(5, "Input sample rate", 10, mask='%1.4e'),
Integer(6, "Decimation factor", 5, xseed_version='1.0',
xml_tag="decimiation_factor"),
Integer(6, "Decimation factor", 5, xseed_version='1.1'),
Integer(7, "Decimation offset", 5),
Float(8, "Estimated delay", 11, mask='%+1.4e'),
Float(9, "Correction applied", 11, mask='%+1.4e')
]
def getRESP(self, station, channel, abbreviations):
"""
Returns RESP string.
"""
string = \
'#\t\t+ +------------------------------+' + \
class Blockette059(Blockette):
"""
Blockette 059: Channel Comment Blockette.
Sample:
05900351989,001~1989,004~4410000000
"""
id = 59
name = "Channel Comment"
fields = [
VariableString(3, "Beginning of effective time", 1, 22, 'T'),
VariableString(4, "End effective time", 0, 22, 'T', optional=True),
Integer(5, "Comment code key", 4, xpath=31),
Integer(6, "Comment level", 6, ignore=True)
]
class Blockette044(Blockette):
"""
Blockette 044: Response (Coefficients) Dictionary Blockette.
See Response (Coefficients) Dictionary Blockette [54] for more information.
"""
id = 44
name = "Response Coefficients Dictionary"
fields = [
Integer(3, "Response Lookup Key", 4),
VariableString(4, "Response Name", 1, 25, 'UN_'),
FixedString(5, "Response type", 1, 'U'),
Integer(6, "Signal input units", 3, xpath=34),
Integer(7, "Signal output units", 3, xpath=34),
Integer(8, "Number of numerators", 4),
# REPEAT fields 9 - 10 for the Number of numerators:
Loop('Numerators', "Number of numerators", [
Float(9, "Numerator coefficient", 12, mask='%+1.5e'),
Float(10, "Numerator error", 12, mask='%+1.5e')
], flat=True),
Integer(11, "Number of denominators", 4),
# REPEAT fields 12 — 13 for the Number of denominators:
Loop('Denominators', "Number of denominators", [
Float(12, "Denominator coefficient", 12, mask='%+1.5e'),
Float(13, "Denominator error", 12, mask='%+1.5e')
], flat=True)
]
# Changes the name of the blockette because of an error in XSEED 1.0
0530382B 1007008 7.87395E+00 5.00000E-02 3
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00 0.00000E+00
-1.27000E+01 0.00000E+00 0.00000E+00 0.00000E+00 4
-1.96418E-03 1.96418E-03 0.00000E+00 0.00000E+00
S-1.96418E-03-1.96418E-03 0.00000E+00 0.00000E+00
53-6.23500E+00 7.81823E+00 0.00000E+00 0.00000E+00
-6.23500E+00-7.81823E+00 0.00000E+00 0.00000E+00
"""
id = 53
name = "Response Poles and Zeros"
fields = [
FixedString(3, "Transfer function types", 1, 'U'),
Integer(4, "Stage sequence number", 2),
Integer(5, "Stage signal input units", 3, xpath=34),
Integer(6, "Stage signal output units", 3, xpath=34),
Float(7, "A0 normalization factor", 12, mask='%+1.5e'),
Float(8, "Normalization frequency", 12, mask='%+1.5e'),
Integer(9, "Number of complex zeros", 3),
# REPEAT fields 10 — 13 for the Number of complex zeros:
Loop('Complex zero', "Number of complex zeros", [
Float(10, "Real zero", 12, mask='%+1.5e'),
Float(11, "Imaginary zero", 12, mask='%+1.5e'),
Float(12, "Real zero error", 12, mask='%+1.5e'),
Float(13, "Imaginary zero error", 12, mask='%+1.5e')
]),
Integer(14, "Number of complex poles", 3),
# REPEAT fields 15 — 18 for the Number of complex poles:
Loop('Complex pole', "Number of complex poles", [
Float(15, "Real pole", 12, mask='%+1.5e'),
blockettes in sequence, and be sure that the first few fields of both
records are identical. Reading (and writing) programs have to be able to
work with both blockettes as one after reading (or before writing). In
July 2007, the FDSN adopted a convention that requires the coefficients to
be listed in forward time order. As a reference, minimum-phase filters
(which are asymmetric) should be written with the largest values near the
beginning of the coefficient list.
"""
id = 54
name = "Response Coefficients"
fields = [
FixedString(3, "Response type", 1, 'U'),
Integer(4, "Stage sequence number", 2),
Integer(5, "Signal input units", 3, xpath=34),
Integer(6, "Signal output units", 3, xpath=34),
Integer(7, "Number of numerators", 4),
# REPEAT fields 8 — 9 for the Number of numerators:
Loop('Numerators', "Number of numerators", [
Float(8, "Numerator coefficient", 12, mask='%+1.5e'),
Float(9, "Numerator error", 12, mask='%+1.5e')
], flat=True),
Integer(10, "Number of denominators", 4),
# REPEAT fields 11 — 12 for the Number of denominators:
Loop('Denominators', "Number of denominators", [
Float(11, "Denominator coefficient", 12, mask='%+1.5e'),
Float(12, "Denominator error", 12, mask='%+1.5e')
], flat=True)
]
def getRESP(self, station, channel, abbreviations):
"""
class Blockette031(Blockette):
"""
Blockette 031: Comment Description Blockette.
Station operators, data collection centers, and data management centers
can add descriptive comments to data to indicate problems encountered or
special situations.
Sample:
03100720750Stime correction does not include leap second, (-1000ms).~000
"""
id = 31
name = "Comment Description"
fields = [
Integer(3, "Comment code key", 4),
FixedString(4, "Comment class code", 1),
VariableString(5, "Description of comment", 1, 70, 'UNLPS'),
Integer(6, "Units of comment level", 3, ignore=True)
]