[segyio] 125/376: pydoc/help for Line.offset
Jørgen Kvalsvik
jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
jokva-guest pushed a commit to branch debian
in repository segyio.
commit fd524a002316b2a20ef1f92f4cbc09f99076305c
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date: Tue Nov 15 09:33:11 2016 +0100
pydoc/help for Line.offset
---
python/segyio/segy.py | 111 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 109 insertions(+), 2 deletions(-)
diff --git a/python/segyio/segy.py b/python/segyio/segy.py
index 5f1d853..90218bc 100644
--- a/python/segyio/segy.py
+++ b/python/segyio/segy.py
@@ -160,8 +160,7 @@ class SegyFile(object):
both in individual (trace) mode and line mode. Individual headers are
accessed via generators and are not read from or written to disk until
the generator is realised and the header in question is used. Supports
- python slicing (yields a generator), as well as direct lookup.
-
+ python slicing (which yields a generator), as well as direct lookup.
Examples:
Reading a field in a trace::
@@ -237,6 +236,20 @@ class SegyFile(object):
False
>>> f.header[2] == g.header[24]
True
+
+ The header mode can also be accessed with line addressing, which
+ supports all of iline and xline's indexing features.
+
+ Rename the iline 3 to 4::
+ >>> f.header.iline[3][TraceField.INLINE_3D] = 4
+ >>> # please note that rewriting the header won't update the
+ >>> # file's interpretation of the file until you reload it, so
+ >>> # the new iline 4 will be considered iline 3 until the file
+ >>> # is reloaded
+
+ Set offset line 3 offset 3 to 5::
+ >>> f.header.iline[3, 3] = { TraceField.offset: 5 }
+
:rtype: segyio._header.Header
"""
return Header(self)
@@ -393,6 +406,15 @@ class SegyFile(object):
an error. Note that each line is returned as a numpy array, meaning
accessing the intersections of the inline and crossline is 0-indexed.
+ Additionally, the iline mode has a concept of offsets, which is useful
+ when dealing with prestack files. Offsets are accessed via so-called
+ sub indexing, meaning iline[10, 4] will give you line 10 at offset 4.
+ Please note that offset, like lines, are accessed via their numbers,
+ not their indices. If your file has the offsets [150, 250, 350, 450]
+ and the lines [2400..2500], you can access the third offset with
+ [2403,350]. Please refer to the examples for more details. If no offset
+ is specified, segyio will give you the first.
+
Examples:
Read an inline::
>>> il = f.iline[2400]
@@ -438,6 +460,44 @@ class SegyFile(object):
Copy every other inline from a different file::
>>> f.iline = g.iline[::2]
+
+ Accessing offsets work the same way as accessing lines, and slicing
+ is supported as well. When doing range-based offset access, the
+ lines will be generated offsets-first, i.e equivalent to:
+ [(line1 off1), (line1 off2), (line1 off3), (line2 off1), ...]
+ or the double for loop::
+ >>> for line in lines:
+ ... for off in offsets:
+ ... yield (line, off)
+ ...
+
+ Copy all lines at all offsets::
+ >>> [np.copy(x) for x in f.iline[:,:]]
+
+ Print all line 10's offsets::
+ >>> print(f.iline[10,:])
+
+ Numpy operations at every line at offset 120::
+ >>> for line in f.iline[:, 120]:
+ ... line = line * 2
+ ... print(np.average(line))
+
+ Copy every other line and offset::
+ >>> map(np.copy, f.iline[::2, ::2])
+
+ Print offsets in reverse::
+ >>> for line in f.iline[:, ::-1]:
+ ... print(line)
+
+ Copy all offsets [200, 250, 300, 350, ...] in the range [200, 800)
+ for all ilines [2420,2460)::
+ >>> [np.copy(x) for x in f.iline[2420:2460, 200:800:50]]
+
+ Copy every third offset from f to g::
+ >>> g.iline[:,:] = f.iline[:,::3]
+
+ Copy an iline from f to g at g's offset 200::
+ >>> g.iline[12, 200] = f.iline[21]
"""
il_len, il_stride = self._iline_length, self._iline_stride
lines = self.ilines
@@ -474,6 +534,15 @@ class SegyFile(object):
an error. Note that each line is returned as a numpy array, meaning
accessing the intersections of the inline and crossline is 0-indexed.
+ Additionally, the xline mode has a concept of offsets, which is useful
+ when dealing with prestack files. Offsets are accessed via so-called
+ sub indexing, meaning xline[10, 4] will give you line 10 at offset 4.
+ Please note that offset, like lines, are accessed via their numbers,
+ not their indices. If your file has the offsets [100, 200, 300, 400]
+ and the lines [1400..1450], you can access the second offset with
+ [1421,300]. Please refer to the examples for more details. If no offset
+ is specified, segyio will give you the first.
+
Examples:
Read an crossline::
>>> il = f.xline[1400]
@@ -520,6 +589,44 @@ class SegyFile(object):
Copy every other crossline from a different file::
>>> f.xline = g.xline[::2]
+
+ Accessing offsets work the same way as accessing lines, and slicing
+ is supported as well. When doing range-based offset access, the
+ lines will be generated offsets-first, i.e equivalent to:
+ [(line1 off1), (line1 off2), (line1 off3), (line2 off1), ...]
+ or the double for loop::
+ >>> for line in lines:
+ ... for off in offsets:
+ ... yield (line, off)
+ ...
+
+ Copy all lines at all offsets::
+ >>> [np.copy(x) for x in f.xline[:,:]]
+
+ Print all line 10's offsets::
+ >>> print(f.xline[10,:])
+
+ Numpy operations at every line at offset 120::
+ >>> for line in f.xline[:, 120]:
+ ... line = line * 2
+ ... print(np.average(line))
+
+ Copy every other line and offset::
+ >>> map(np.copy, f.xline[::2, ::2])
+
+ Print offsets in reverse::
+ >>> for line in f.xline[:, ::-1]:
+ ... print(line)
+
+ Copy all offsets [200, 250, 300, 350, ...] in the range [200, 800)
+ for all xlines [2420,2460)::
+ >>> [np.copy(x) for x in f.xline[2420:2460, 200:800:50]]
+
+ Copy every third offset from f to g::
+ >>> g.xline[:,:] = f.xline[:,::3]
+
+ Copy an xline from f to g at g's offset 200::
+ >>> g.xline[12, 200] = f.xline[21]
"""
xl_len, xl_stride = self._xline_length, self._xline_stride
lines = self.xlines
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git
More information about the debian-science-commits
mailing list