# Problems with a segy file

Dear all,

I am really struggling with a problem in reading and plotting a SEGY section. I have a file, which is the concatenation of 8 segy files. This operation went well, and I can read a stream of 288 traces in total (8 files * 12 geophones * 3 comp (h1,h2,z)).

Therefore in the streams, traces are: (z,h1,h2) first geoph , (z,h1,h2) second geoph.,… I file,
,(z,h1,h2) first geoph, (z,h1,h2) second geoph,… II file…and so on
What I want to do: is to plot for instance the z section but in a temporal order; this means I want to recreate a plot with 12 subplots (one for each geophone), and for each of this, the correct Z time series

Below you can find my current code lines. Please, can anybody help me? This code, once working, would be very powerful to me.

I thank you.

import os, sys
import glob

filesegy = input("Filesegy name: ")
Ngeo = input("Number of geophones: ")
Nfile1 = int(Ngeo) * 3;
Nfiles = len(st)/Nfile1;
print(“This file contains”,str(Nfiles),“segy files”)

compname = input("Select the component to plot z, h1, h2: ")
print(“Component”, compname)
comp = Stream()

i = 0
ii = 0

# z
if compname == “z”:

while i < int(Ngeo):
while ii < int(Nfiles):
comp += st[i * 3 + ii * Nfile1]
comp[i:i+int(Ngeo)].merge()
ii += 1
i += 1

for j in range(len(comp)):
comp[j].stats.channel = compname + " " + str(j + 1)

comp.plot()

Hey Enrico,

sorry for the late answer. The following should work:

# Sort by channel and then the start time.

st.sort(keys=[“channel”, “starttime”])

# Get all vertical channels.

st_z = obspy.Stream(traces=[tr for tr in st if tr.stats.channel[-1] == “Z”])

Cheers!

Lion