File: scan_min_max.py

package info (click to toggle)
segyio 1.8.3-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,724 kB
  • sloc: cpp: 17,823; ansic: 4,637; python: 4,326; makefile: 38; sh: 23
file content (31 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import segyio
import numpy as np


def main():
    if len(sys.argv) < 2:
        sys.exit("Usage: {} [segyfile] ".format(sys.argv[0]))

    segyfile = sys.argv[1]

    min_value = sys.float_info.max
    max_value = sys.float_info.min

    with segyio.open(segyfile) as f:
        for trace in f.trace:

            local_min = np.nanmin(trace)
            local_max = np.nanmax(trace)

            if np.isfinite(local_min):
                min_value = min(local_min, min_value)

            if np.isfinite(local_max):
                max_value = max(local_max, max_value)

    print("min: {}".format(min_value))
    print("max: {}".format(max_value))

if __name__ == '__main__':
    main()