Repository: obspy/obspy

Issue:
Type Error while reading .resp file with read_inventory
Dear all, 

this is my first issue, i'll do my best to give all the information needed.
I try to read a response file in RESP format using obspy.read_inventory, basically like this:

`import obspy 
inv = obspy.read_inventory('/run/media/felixw/workdisc_1/6D6-Trillium-250sps.resp', format='RESP')`

This leads to the following error message: 

File "/home/felixw/anaconda3/lib/python3.6/site-packages/obspy/io/xseed/parser.py", line 1127, in get_response_for_channel
stages[b.stage_sequence_number].append(b)

TypeError: unhashable type: 'list'

I tried converting the .resp file into a dataless seed and read that one - converting works, read_inventory gives the same error. You can find the .resp file here: https://www.dropbox.com/s/644r9lsdqv0larx/6D6-Trillium-250sps.resp?dl=0 (couldn't upload it directly to this issue).

Do you have any idea, what i could do to solve that? That would be a great help to me, thanks a lot!

Some information on my ObsPy and Python: i installed both via anaconda3, using Python 3.6 and ObsPy 1.1 on a Fedora 27 computer.

Best wishes and again, thanks for helping,
Felix



Discussion:
I can confirm the problem and it indeed seems like a bug to me..
Good to hear that you can recreate the error...
Nevertheless, i just now managed to create a workaround:
convert the .resp file to a dataless seed (I used PDCC) and then do the following:

```python
from obspy.io.xseed import Parser
from obspy.core import UTCDateTime

dataless = Parser('/run/media/felixw/workdisc_1/6D6-Trillium-250sps.seed')
seed_id = 'BHZ'  # channel identifier
inv = dataless.get_paz(seed_id, UTCDateTime("2018-06-13")) # this collects all information needed as metadata for PPSD
```

This is a bit crude to do but now I can create the ppsd-plots I aimed for


Resolving patch:
diff --git a/obspy/io/xseed/parser.py b/obspy/io/xseed/parser.py
--- a/obspy/io/xseed/parser.py
+++ b/obspy/io/xseed/parser.py
@@ -688,6 +688,8 @@ def record_type_from_blocketteid(bid):
         comment_pattern = re.compile(r"^#.*\+")
 
         last_blockette_id = None
+        # No fields with number 0 exist.
+        last_field_number = 0
         for line in data.splitlines():
             m = re.match(pattern, line)
             if m:
@@ -700,12 +702,25 @@ def record_type_from_blocketteid(bid):
                 # g[3]: Everything afterwards.
                 g = m.groups()
                 blockette_number = g[0]
+                field_number = int(g[1])
                 # A new blockette is starting.
-                if blockette_number != last_blockette_id:
+                # Either
+                # * when the blockette number increases or
+                # * (for blockette 58) when the field number suddenly decreases
+                # to 3 again.
+                # This catches a rare issue where blockette 58 is repeated
+                # twice (gain for a channel + total sensitivity) and the
+                # comments don't contain any `+` which would alternatively
+                # trigger a new blockette to be created.
+                if (blockette_number != last_blockette_id) or \
+                        ((blockette_number == "058") and
+                         (field_number == 3) and
+                         (field_number < last_field_number)):
                     if len(blockettefieldlist) > 0:
                         blockettelist.append(blockettefieldlist)
                         blockettefieldlist = list()
                     last_blockette_id = blockette_number
+                    last_field_number = 0
                 # Single field lines.
                 if not g[2]:
                     # Units of blkts 41 and 61 are normal.
@@ -717,7 +732,8 @@ def record_type_from_blocketteid(bid):
                     else:
                         value = g[3].strip().split()[-1]
                     blockettefieldlist.append((blockette_number, g[1], value))
-                # Multiple field liens.
+                    last_field_number = field_number
+                # Multiple field lines.
                 else:
                     first_field = int(g[1])
                     last_field = int(g[2])
@@ -726,12 +742,15 @@ def record_type_from_blocketteid(bid):
                     for i, value in enumerate(values):
                         blockettefieldlist.append(
                             (blockette_number, first_field + i, value))
+                    last_field_number = field_number
             elif re.match(comment_pattern, line):
                 # Comment line with a + in it means blockette is
                 # finished start a new one
                 if len(blockettefieldlist) > 0:
                     blockettelist.append(blockettefieldlist)
                     blockettefieldlist = list()
+                    last_blockette_id = blockette_number
+                    last_field_number = 0
         # Add last blockette
         if len(blockettefieldlist) > 0:
             blockettelist.append(blockettefieldlist)


Test patch:
diff --git a/obspy/io/xseed/tests/data/6D6-Trillium-250sps.resp b/obspy/io/xseed/tests/data/6D6-Trillium-250sps.resp
new file mode 100644
--- /dev/null
+++ b/obspy/io/xseed/tests/data/6D6-Trillium-250sps.resp
@@ -0,0 +1,668 @@
+B050F03     Station:                                ST001
+B050F16     Network:                                XX
+B052F03     Location:                               ??
+B052F04     Channel:                                BHZ
+B052F08     Response in units lookup:               M/S - Velocity in Meters per Second
+B052F22     Start date:                             2015,001,00:00:00.0000
+B052F23     End date:                               No Ending Time
+#
+# Stage 1
+# =======
+#
+# Response (Poles & Zeros)
+# ------------------------
+#
+B053F03     Transfer function type:                 A
+B053F04     Stage sequence number:                  1
+B053F05     Response in units lookup:               M/S - Velocity in Meters per Second
+B053F06     Response out units lookup:              V - Volts
+B053F07     A0 normalization factor:                8.184000E+11
+B053F08     Normalization frequency:                1.000000E+00
+B053F09     Number of zeroes:                       3
+B053F14     Number of poles:                        7
+#            Complex zeroes:
+#             i  real          imag          real_error    imag_error
+B053F10-13    0  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
+B053F10-13    1  0.000000E+00  0.000000E+00  0.000000E+00  0.000000E+00
+B053F10-13    2 -4.341000E+02  0.000000E+00  0.000000E+00  0.000000E+00
+#            Complex poles:
+#             i  real          imag          real_error    imag_error
+B053F15-18    0 -3.691000E-02  3.712000E-02  0.000000E+00  0.000000E+00
+B053F15-18    1 -3.691000E-02 -3.712000E-02  0.000000E+00  0.000000E+00
+B053F15-18    2 -3.712000E+02  0.000000E+00  0.000000E+00  0.000000E+00
+B053F15-18    3 -3.739000E+02  4.755000E+02  0.000000E+00  0.000000E+00
+B053F15-18    4 -3.739000E+02 -4.755000E+02  0.000000E+00  0.000000E+00
+B053F15-18    5 -5.884000E+02  1.508000E+03  0.000000E+00  0.000000E+00
+B053F15-18    6 -5.884000E+02 -1.508000E+03  0.000000E+00  0.000000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  1
+B058F04     Gain:                                   7.491000E+02
+B058F05     Frequency of gain:                      1.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 2
+# =======
+#
+# Response (Coefficients)
+# -----------------------
+#
+B054F03     Response type:                          D
+B054F04     Stage sequence number:                  2
+B054F05     Response in units lookup:               V - Volts
+B054F06     Response out units lookup:              COUNTS - Digital Counts
+B054F07     Number of numerators:                   0
+#            Numerators:
+#             i  value         error
+B054F10     Number of denominators:                 0
+#            Denominators:
+#             i  value         error
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  2
+B057F04     Input sample rate (Hz):                 1.0240E+06
+B057F05     Decimation factor:                      1
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              0.0000E+00
+B057F08     Correction applied (seconds):           0.0000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  2
+B058F04     Gain:                                   1.073742E+08
+B058F05     Frequency of gain:                      1.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 3
+# =======
+#
+# FIR Response
+# ------------
+#
+B061F03     Stage sequence number:                  3
+B061F04     Response Name:                          Sinc Filter~
+B061F05     Symmetry Code:                          C
+B061F06     Response in units lookup:               COUNTS - Digital Counts
+B061F07     Response out units lookup:              COUNTS - Digital Counts
+B061F08     Number of Coefficients:                 318
+#            Coefficients:
+#             i  value
+B061F09       0  2.9103830E-11
+B061F09       1  1.4551915E-10
+B061F09       2  4.3655746E-10
+B061F09       3  1.0186341E-09
+B061F09       4  2.0372681E-09
+B061F09       5  3.6670826E-09
+B061F09       6  6.1118044E-09
+B061F09       7  9.6042641E-09
+B061F09       8  1.4406396E-08
+B061F09       9  2.0809239E-08
+B061F09      10  2.9132934E-08
+B061F09      11  3.9726729E-08
+B061F09      12  5.2968971E-08
+B061F09      13  6.9267116E-08
+B061F09      14  8.9057721E-08
+B061F09      15  1.1280645E-07
+B061F09      16  1.4100806E-07
+B061F09      17  1.7418643E-07
+B061F09      18  2.1289452E-07
+B061F09      19  2.5771442E-07
+B061F09      20  3.0925730E-07
+B061F09      21  3.6816346E-07
+B061F09      22  4.3510227E-07
+B061F09      23  5.1077222E-07
+B061F09      24  5.9590093E-07
+B061F09      25  6.9124508E-07
+B061F09      26  7.9759047E-07
+B061F09      27  9.1575203E-07
+B061F09      28  1.0465737E-06
+B061F09      29  1.1909287E-06
+B061F09      30  1.3497192E-06
+B061F09      31  1.5238766E-06
+B061F09      32  1.7143611E-06
+B061F09      33  1.9221625E-06
+B061F09      34  2.1482992E-06
+B061F09      35  2.3938192E-06
+B061F09      36  2.6597991E-06
+B061F09      37  2.9473449E-06
+B061F09      38  3.2575917E-06
+B061F09      39  3.5917037E-06
+B061F09      40  3.9508741E-06
+B061F09      41  4.3363252E-06
+B061F09      42  4.7493086E-06
+B061F09      43  5.1911047E-06
+B061F09      44  5.6630233E-06
+B061F09      45  6.1664032E-06
+B061F09      46  6.7026122E-06
+B061F09      47  7.2730472E-06
+B061F09      48  7.8791345E-06
+B061F09      49  8.5223292E-06
+B061F09      50  9.2041155E-06
+B061F09      51  9.9260069E-06
+B061F09      52  1.0689546E-05
+B061F09      53  1.1496304E-05
+B061F09      54  1.2347882E-05
+B061F09      55  1.3245910E-05
+B061F09      56  1.4192046E-05
+B061F09      57  1.5187979E-05
+B061F09      58  1.6235426E-05
+B061F09      59  1.7336133E-05
+B061F09      60  1.8491875E-05
+B061F09      61  1.9704457E-05
+B061F09      62  2.0975713E-05
+B061F09      63  2.2307504E-05
+B061F09      64  2.3701723E-05
+B061F09      65  2.5160291E-05
+B061F09      66  2.6685157E-05
+B061F09      67  2.8278300E-05
+B061F09      68  2.9941730E-05
+B061F09      69  3.1677482E-05
+B061F09      70  3.3487624E-05
+B061F09      71  3.5374251E-05
+B061F09      72  3.7339487E-05
+B061F09      73  3.9385486E-05
+B061F09      74  4.1514431E-05
+B061F09      75  4.3728534E-05
+B061F09      76  4.6030036E-05
+B061F09      77  4.8421207E-05
+B061F09      78  5.0904346E-05
+B061F09      79  5.3481781E-05
+B061F09      80  5.6155870E-05
+B061F09      81  5.8928999E-05
+B061F09      82  6.1803585E-05
+B061F09      83  6.4782071E-05
+B061F09      84  6.7866931E-05
+B061F09      85  7.1060669E-05
+B061F09      86  7.4365817E-05
+B061F09      87  7.7784935E-05
+B061F09      88  8.1320613E-05
+B061F09      89  8.4975472E-05
+B061F09      90  8.8752160E-05
+B061F09      91  9.2653354E-05
+B061F09      92  9.6681761E-05
+B061F09      93  1.0084012E-04
+B061F09      94  1.0513118E-04
+B061F09      95  1.0955776E-04
+B061F09      96  1.1412267E-04
+B061F09      97  1.1882876E-04
+B061F09      98  1.2367891E-04
+B061F09      99  1.2867604E-04
+B061F09     100  1.3382308E-04
+B061F09     101  1.3912300E-04
+B061F09     102  1.4457881E-04
+B061F09     103  1.5019352E-04
+B061F09     104  1.5597019E-04
+B061F09     105  1.6191191E-04
+B061F09     106  1.6802180E-04
+B061F09     107  1.7430299E-04
+B061F09     108  1.8075865E-04
+B061F09     109  1.8739200E-04
+B061F09     110  1.9420625E-04
+B061F09     111  2.0120468E-04
+B061F09     112  2.0839056E-04
+B061F09     113  2.1576721E-04
+B061F09     114  2.2333799E-04
+B061F09     115  2.3110627E-04
+B061F09     116  2.3907545E-04
+B061F09     117  2.4724897E-04
+B061F09     118  2.5563029E-04
+B061F09     119  2.6422291E-04
+B061F09     120  2.7303034E-04
+B061F09     121  2.8205613E-04
+B061F09     122  2.9130388E-04
+B061F09     123  3.0077717E-04
+B061F09     124  3.1047966E-04
+B061F09     125  3.2041501E-04
+B061F09     126  3.3058692E-04
+B061F09     127  3.4099910E-04
+B061F09     128  3.5165518E-04
+B061F09     129  3.6255864E-04
+B061F09     130  3.7371286E-04
+B061F09     131  3.8512109E-04
+B061F09     132  3.9678649E-04
+B061F09     133  4.0871208E-04
+B061F09     134  4.2090076E-04
+B061F09     135  4.3335534E-04
+B061F09     136  4.4607848E-04
+B061F09     137  4.5907276E-04
+B061F09     138  4.7234062E-04
+B061F09     139  4.8588437E-04
+B061F09     140  4.9970625E-04
+B061F09     141  5.1380834E-04
+B061F09     142  5.2819261E-04
+B061F09     143  5.4286094E-04
+B061F09     144  5.5781507E-04
+B061F09     145  5.7305663E-04
+B061F09     146  5.8858714E-04
+B061F09     147  6.0440798E-04
+B061F09     148  6.2052044E-04
+B061F09     149  6.3692569E-04
+B061F09     150  6.5362477E-04
+B061F09     151  6.7061861E-04
+B061F09     152  6.8790803E-04
+B061F09     153  7.0549373E-04
+B061F09     154  7.2337629E-04
+B061F09     155  7.4155617E-04
+B061F09     156  7.6003373E-04
+B061F09     157  7.7880919E-04
+B061F09     158  7.9788268E-04
+B061F09     159  8.1725419E-04
+B061F09     160  8.3692360E-04
+B061F09     161  8.5689069E-04
+B061F09     162  8.7715511E-04
+B061F09     163  8.9771638E-04
+B061F09     164  9.1857393E-04
+B061F09     165  9.3972706E-04
+B061F09     166  9.6117496E-04
+B061F09     167  9.8291668E-04
+B061F09     168  1.0049512E-03
+B061F09     169  1.0272773E-03
+B061F09     170  1.0498938E-03
+B061F09     171  1.0727992E-03
+B061F09     172  1.0959920E-03
+B061F09     173  1.1194707E-03
+B061F09     174  1.1432334E-03
+B061F09     175  1.1672783E-03
+B061F09     176  1.1916034E-03
+B061F09     177  1.2162066E-03
+B061F09     178  1.2410857E-03
+B061F09     179  1.2662384E-03
+B061F09     180  1.2916622E-03
+B061F09     181  1.3173546E-03
+B061F09     182  1.3433129E-03
+B061F09     183  1.3695343E-03
+B061F09     184  1.3960159E-03
+B061F09     185  1.4227546E-03
+B061F09     186  1.4497474E-03
+B061F09     187  1.4769909E-03
+B061F09     188  1.5044818E-03
+B061F09     189  1.5322166E-03
+B061F09     190  1.5601916E-03
+B061F09     191  1.5884032E-03
+B061F09     192  1.6168476E-03
+B061F09     193  1.6455207E-03
+B061F09     194  1.6744185E-03
+B061F09     195  1.7035367E-03
+B061F09     196  1.7328712E-03
+B061F09     197  1.7624174E-03
+B061F09     198  1.7921708E-03
+B061F09     199  1.8221268E-03
+B061F09     200  1.8522806E-03
+B061F09     201  1.8826273E-03
+B061F09     202  1.9131618E-03
+B061F09     203  1.9438792E-03
+B061F09     204  1.9747741E-03
+B061F09     205  2.0058411E-03
+B061F09     206  2.0370749E-03
+B061F09     207  2.0684698E-03
+B061F09     208  2.1000201E-03
+B061F09     209  2.1317200E-03
+B061F09     210  2.1635635E-03
+B061F09     211  2.1955447E-03
+B061F09     212  2.2276572E-03
+B061F09     213  2.2598950E-03
+B061F09     214  2.2922514E-03
+B061F09     215  2.3247201E-03
+B061F09     216  2.3572944E-03
+B061F09     217  2.3899676E-03
+B061F09     218  2.4227327E-03
+B061F09     219  2.4555827E-03
+B061F09     220  2.4885107E-03
+B061F09     221  2.5215093E-03
+B061F09     222  2.5545713E-03
+B061F09     223  2.5876891E-03
+B061F09     224  2.6208552E-03
+B061F09     225  2.6540620E-03
+B061F09     226  2.6873016E-03
+B061F09     227  2.7205661E-03
+B061F09     228  2.7538475E-03
+B061F09     229  2.7871376E-03
+B061F09     230  2.8204282E-03
+B061F09     231  2.8537109E-03
+B061F09     232  2.8869772E-03
+B061F09     233  2.9202184E-03
+B061F09     234  2.9534259E-03
+B061F09     235  2.9865907E-03
+B061F09     236  3.0197040E-03
+B061F09     237  3.0527567E-03
+B061F09     238  3.0857394E-03
+B061F09     239  3.1186431E-03
+B061F09     240  3.1514581E-03
+B061F09     241  3.1841750E-03
+B061F09     242  3.2167841E-03
+B061F09     243  3.2492756E-03
+B061F09     244  3.2816397E-03
+B061F09     245  3.3138662E-03
+B061F09     246  3.3459452E-03
+B061F09     247  3.3778662E-03
+B061F09     248  3.4096191E-03
+B061F09     249  3.4411933E-03
+B061F09     250  3.4725781E-03
+B061F09     251  3.5037630E-03
+B061F09     252  3.5347370E-03
+B061F09     253  3.5654893E-03
+B061F09     254  3.5960088E-03
+B061F09     255  3.6262842E-03
+B061F09     256  3.6563046E-03
+B061F09     257  3.6860592E-03
+B061F09     258  3.7155373E-03
+B061F09     259  3.7447285E-03
+B061F09     260  3.7736223E-03
+B061F09     261  3.8022088E-03
+B061F09     262  3.8304779E-03
+B061F09     263  3.8584200E-03
+B061F09     264  3.8860252E-03
+B061F09     265  3.9132843E-03
+B061F09     266  3.9401880E-03
+B061F09     267  3.9667272E-03
+B061F09     268  3.9928930E-03
+B061F09     269  4.0186767E-03
+B061F09     270  4.0440697E-03
+B061F09     271  4.0690636E-03
+B061F09     272  4.0936502E-03
+B061F09     273  4.1178215E-03
+B061F09     274  4.1415697E-03
+B061F09     275  4.1648870E-03
+B061F09     276  4.1877659E-03
+B061F09     277  4.2101991E-03
+B061F09     278  4.2321795E-03
+B061F09     279  4.2537000E-03
+B061F09     280  4.2747539E-03
+B061F09     281  4.2953345E-03
+B061F09     282  4.3154354E-03
+B061F09     283  4.3350502E-03
+B061F09     284  4.3541729E-03
+B061F09     285  4.3727974E-03
+B061F09     286  4.3909182E-03
+B061F09     287  4.4085295E-03
+B061F09     288  4.4256260E-03
+B061F09     289  4.4422023E-03
+B061F09     290  4.4582536E-03
+B061F09     291  4.4737748E-03
+B061F09     292  4.4887612E-03
+B061F09     293  4.5032083E-03
+B061F09     294  4.5171118E-03
+B061F09     295  4.5304674E-03
+B061F09     296  4.5432712E-03
+B061F09     297  4.5555193E-03
+B061F09     298  4.5672079E-03
+B061F09     299  4.5783338E-03
+B061F09     300  4.5888934E-03
+B061F09     301  4.5988837E-03
+B061F09     302  4.6083017E-03
+B061F09     303  4.6171446E-03
+B061F09     304  4.6254098E-03
+B061F09     305  4.6330948E-03
+B061F09     306  4.6401974E-03
+B061F09     307  4.6467155E-03
+B061F09     308  4.6526472E-03
+B061F09     309  4.6579906E-03
+B061F09     310  4.6627444E-03
+B061F09     311  4.6669069E-03
+B061F09     312  4.6704771E-03
+B061F09     313  4.6734538E-03
+B061F09     314  4.6758362E-03
+B061F09     315  4.6776237E-03
+B061F09     316  4.6788156E-03
+B061F09     317  4.6794116E-03
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  3
+B057F04     Input sample rate (Hz):                 1.0240E+06
+B057F05     Decimation factor:                      128
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              3.1006E-04
+B057F08     Correction applied (seconds):           0.0000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  3
+B058F04     Gain:                                   1.000000E+00
+B058F05     Frequency of gain:                      0.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 4
+# =======
+#
+# FIR Response
+# ------------
+#
+B061F03     Stage sequence number:                  4
+B061F04     Response Name:                          FIR Stage 1~
+B061F05     Symmetry Code:                          B
+B061F06     Response in units lookup:               COUNTS - Digital Counts
+B061F07     Response out units lookup:              COUNTS - Digital Counts
+B061F08     Number of Coefficients:                 6
+#            Coefficients:
+#             i  value
+B061F09       0  5.8593750E-03
+B061F09       1  0.0000000E+00
+B061F09       2 -4.8828125E-02
+B061F09       3  0.0000000E+00
+B061F09       4  2.9296875E-01
+B061F09       5  5.0000000E-01
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  4
+B057F04     Input sample rate (Hz):                 8.0000E+03
+B057F05     Decimation factor:                      2
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              6.2500E-04
+B057F08     Correction applied (seconds):           0.0000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  4
+B058F04     Gain:                                   1.000000E+00
+B058F05     Frequency of gain:                      0.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 5
+# =======
+#
+# FIR Response
+# ------------
+#
+B061F03     Stage sequence number:                  5
+B061F04     Response Name:                          FIR Stage 2~
+B061F05     Symmetry Code:                          B
+B061F06     Response in units lookup:               COUNTS - Digital Counts
+B061F07     Response out units lookup:              COUNTS - Digital Counts
+B061F08     Number of Coefficients:                 8
+#            Coefficients:
+#             i  value
+B061F09       0 -1.3046265E-03
+B061F09       1  0.0000000E+00
+B061F09       2  1.2374759E-02
+B061F09       3  0.0000000E+00
+B061F09       4 -6.0546756E-02
+B061F09       5  0.0000000E+00
+B061F09       6  2.9947662E-01
+B061F09       7  5.0000000E-01
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  5
+B057F04     Input sample rate (Hz):                 4.0000E+03
+B057F05     Decimation factor:                      2
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              1.7500E-03
+B057F08     Correction applied (seconds):           0.0000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  5
+B058F04     Gain:                                   1.000000E+00
+B058F05     Frequency of gain:                      0.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 6
+# =======
+#
+# FIR Response
+# ------------
+#
+B061F03     Stage sequence number:                  6
+B061F04     Response Name:                          FIR Stage 3~
+B061F05     Symmetry Code:                          B
+B061F06     Response in units lookup:               COUNTS - Digital Counts
+B061F07     Response out units lookup:              COUNTS - Digital Counts
+B061F08     Number of Coefficients:                 26
+#            Coefficients:
+#             i  value
+B061F09       0  0.0000000E+00
+B061F09       1  0.0000000E+00
+B061F09       2 -5.4389238E-07
+B061F09       3 -6.5118074E-06
+B061F09       4 -3.4630299E-05
+B061F09       5 -1.2030452E-04
+B061F09       6 -3.0755997E-04
+B061F09       7 -6.0300529E-04
+B061F09       8 -8.9454651E-04
+B061F09       9 -8.8430941E-04
+B061F09      10 -1.3562292E-04
+B061F09      11  1.6745254E-03
+B061F09      12  4.3227971E-03
+B061F09      13  6.6553280E-03
+B061F09      14  6.6414177E-03
+B061F09      15  2.1874756E-03
+B061F09      16 -7.3556080E-03
+B061F09      17 -1.9638084E-02
+B061F09      18 -2.8761640E-02
+B061F09      19 -2.6617289E-02
+B061F09      20 -6.1286464E-03
+B061F09      21  3.4787163E-02
+B061F09      22  9.0552106E-02
+B061F09      23  1.4834926E-01
+B061F09      24  1.9207142E-01
+B061F09      25  2.0836936E-01
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  6
+B057F04     Input sample rate (Hz):                 2.0000E+03
+B057F05     Decimation factor:                      4
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              1.2500E-02
+B057F08     Correction applied (seconds):           0.0000E+00
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  6
+B058F04     Gain:                                   1.000000E+00
+B058F05     Frequency of gain:                      0.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Stage 7
+# =======
+#
+# FIR Response
+# ------------
+#
+B061F03     Stage sequence number:                  7
+B061F04     Response Name:                          FIR Stage 4~
+B061F05     Symmetry Code:                          B
+B061F06     Response in units lookup:               COUNTS - Digital Counts
+B061F07     Response out units lookup:              COUNTS - Digital Counts
+B061F08     Number of Coefficients:                 55
+#            Coefficients:
+#             i  value
+B061F09       0 -9.8347664E-07
+B061F09       1 -3.2186508E-06
+B061F09       2 -5.5879354E-07
+B061F09       3  1.8484890E-05
+B061F09       4  4.9859285E-05
+B061F09       5  5.5275857E-05
+B061F09       6 -1.9818544E-06
+B061F09       7 -7.9445541E-05
+B061F09       8 -6.1690807E-05
+B061F09       9  7.9125166E-05
+B061F09      10  1.6397238E-04
+B061F09      11  2.5928020E-06
+B061F09      12 -2.5423616E-04
+B061F09      13 -1.9035488E-04
+B061F09      14  2.4929643E-04
+B061F09      15  4.5736879E-04
+B061F09      16 -5.6222081E-05
+B061F09      17 -7.0178509E-04
+B061F09      18 -3.7721545E-04
+B061F09      19  7.5351447E-04
+B061F09      20  1.0045320E-03
+B061F09      21 -4.2189658E-04
+B061F09      22 -1.6399026E-03
+B061F09      23 -4.1784346E-04
+B061F09      24  1.9651502E-03
+B061F09      25  1.7228052E-03
+B061F09      26 -1.6035959E-03
+B061F09      27 -3.2050759E-03
+B061F09      28  2.5864691E-04
+B061F09      29  4.3244958E-03
+B061F09      30  2.1150559E-03
+B061F09      31 -4.3837875E-03
+B061F09      32 -5.1648095E-03
+B061F09      33  2.7277917E-03
+B061F09      34  8.0822855E-03
+B061F09      35  9.9013001E-04
+B061F09      36 -9.6864030E-03
+B061F09      37 -6.5463930E-03
+B061F09      38  8.6589828E-03
+B061F09      39  1.2975670E-02
+B061F09      40 -3.8931742E-03
+B061F09      41 -1.8554889E-02
+B061F09      42 -5.1330402E-03
+B061F09      43  2.0949081E-02
+B061F09      44  1.8071339E-02
+B061F09      45 -1.7420165E-02
+B061F09      46 -3.3610433E-02
+B061F09      47  4.7799572E-03
+B061F09      48  4.9633756E-02
+B061F09      49  2.1985255E-02
+B061F09      50 -6.3613482E-02
+B061F09      51 -7.8508988E-02
+B061F09      52  7.3153354E-02
+B061F09      53  3.0865054E-01
+B061F09      54  4.2345953E-01
+#
+# Decimation
+# ----------
+#
+B057F03     Stage sequence number:                  7
+B057F04     Input sample rate (Hz):                 5.0000E+02
+B057F05     Decimation factor:                      2
+B057F06     Decimation offset:                      0
+B057F07     Estimated delay (seconds):              1.0800E-01
+B057F08     Correction applied (seconds):           1.2400E-01
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  7
+B058F04     Gain:                                   1.000000E+00
+B058F05     Frequency of gain:                      0.000000E+00
+B058F06     Number of calibrations:                 0
+#
+# Total Gain
+# ==========
+#
+# Channel Gain
+# ------------
+#
+B058F03     Stage sequence number:                  0
+B058F04     Gain:                                   8.043400E+10
+B058F05     Frequency of gain:                      1.000000E+00
+B058F06     Number of calibrations:                 0
diff --git a/obspy/io/xseed/tests/test_parser.py b/obspy/io/xseed/tests/test_parser.py
--- a/obspy/io/xseed/tests/test_parser.py
+++ b/obspy/io/xseed/tests/test_parser.py
@@ -12,6 +12,7 @@
 import numpy as np
 from lxml import etree
 
+import obspy
 from obspy import UTCDateTime, read
 from obspy.core.util import NamedTemporaryFile
 from obspy.io.xseed.blockette.blockette010 import Blockette010
@@ -21,6 +22,7 @@
 import obspy.io.xseed.parser
 from obspy.io.xseed.parser import Parser
 from obspy.io.xseed.utils import SEEDParserException, compare_seed
+from obspy.signal.invsim import evalresp_for_frequencies
 
 
 class ParserTestCase(unittest.TestCase):
@@ -814,10 +816,33 @@ def test_underline_in_site_name(self):
         filename = os.path.join(self.path, 'UP_BACU_HH.dataless')
         parser = Parser()
         parser.read(filename)
-        # value given by pdcc
+        # value given by pdccgg
         self.assertEqual(parser.blockettes[50][0].site_name,
                          'T3930_b A6689 3930')
 
+    def test_parsing_resp_file_without_clear_blkt_separation(self):
+        """
+        This is a slightly malformed RESP file that has two blockettes 58 at
+        the end. Most RESP files separate blockettes with comments of which
+        at least one contains a plus sign. This one does not so additional
+        heuristics are needed.
+        """
+        filename = os.path.join(self.path, '6D6-Trillium-250sps.resp')
+        parser = Parser()
+        parser.read(filename)
+        b = parser.blockettes[58][-1]
+        self.assertEqual(b.stage_sequence_number, 0)
+        self.assertEqual(b.number_of_history_values, 0)
+        np.testing.assert_allclose(b.sensitivity_gain, 8.043400E+10)
+        np.testing.assert_allclose(b.frequency, 1.0)
+
+        # Also compare directly against what evalresp would do.
+        obs_r = obspy.read_inventory(filename)[0][0][0].response\
+            .get_evalresp_response_for_frequencies([0.0, 1.0, 10.0])
+        evresp = evalresp_for_frequencies(0.01, [0.0, 1.0, 10.0], filename,
+                                          obspy.UTCDateTime(2015, 1, 2))
+        np.testing.assert_allclose(obs_r, evresp)
+
 
 def suite():
     return unittest.makeSuite(ParserTestCase, 'test')