first-breaks-picking 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. first-breaks-picking-0.0.1/LICENSE +201 -0
  2. first-breaks-picking-0.0.1/PKG-INFO +247 -0
  3. first-breaks-picking-0.0.1/README.md +220 -0
  4. first-breaks-picking-0.0.1/first_breaks/__init__.py +0 -0
  5. first-breaks-picking-0.0.1/first_breaks/const.py +32 -0
  6. first-breaks-picking-0.0.1/first_breaks/desktop/__init__.py +0 -0
  7. first-breaks-picking-0.0.1/first_breaks/desktop/graph.py +398 -0
  8. first-breaks-picking-0.0.1/first_breaks/desktop/main_gui.py +378 -0
  9. first-breaks-picking-0.0.1/first_breaks/desktop/picking_widget.py +143 -0
  10. first-breaks-picking-0.0.1/first_breaks/desktop/threads.py +70 -0
  11. first-breaks-picking-0.0.1/first_breaks/desktop/warn_widget.py +27 -0
  12. first-breaks-picking-0.0.1/first_breaks/picking/__init__.py +0 -0
  13. first-breaks-picking-0.0.1/first_breaks/picking/picker.py +74 -0
  14. first-breaks-picking-0.0.1/first_breaks/picking/task.py +133 -0
  15. first-breaks-picking-0.0.1/first_breaks/picking/utils.py +18 -0
  16. first-breaks-picking-0.0.1/first_breaks/sgy/__init__.py +0 -0
  17. first-breaks-picking-0.0.1/first_breaks/sgy/headers.py +213 -0
  18. first-breaks-picking-0.0.1/first_breaks/sgy/reader.py +341 -0
  19. first-breaks-picking-0.0.1/first_breaks/utils/__init__.py +0 -0
  20. first-breaks-picking-0.0.1/first_breaks/utils/debug.py +19 -0
  21. first-breaks-picking-0.0.1/first_breaks/utils/utils.py +94 -0
  22. first-breaks-picking-0.0.1/first_breaks/utils/visualizations.py +122 -0
  23. first-breaks-picking-0.0.1/first_breaks_picking.egg-info/PKG-INFO +247 -0
  24. first-breaks-picking-0.0.1/first_breaks_picking.egg-info/SOURCES.txt +28 -0
  25. first-breaks-picking-0.0.1/first_breaks_picking.egg-info/dependency_links.txt +1 -0
  26. first-breaks-picking-0.0.1/first_breaks_picking.egg-info/requires.txt +7 -0
  27. first-breaks-picking-0.0.1/first_breaks_picking.egg-info/top_level.txt +1 -0
  28. first-breaks-picking-0.0.1/setup.cfg +19 -0
  29. first-breaks-picking-0.0.1/setup.py +52 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.1
2
+ Name: first-breaks-picking
3
+ Version: 0.0.1
4
+ Summary: Tool for picking first breaks in seismic gather
5
+ Home-page: https://github.com/DaloroAT/first_breaks_picking
6
+ Author: Aleksei Tarasov
7
+ Author-email: aleksei.v.tarasov@gmail.com
8
+ License: Apache License 2.0
9
+ Project-URL: Homepage, https://github.com/DaloroAT/first_breaks_picking
10
+ Keywords: seismic,first-breaks,computer-vision,deep-learning,segmentation,data-science
11
+ Classifier: Environment :: Console
12
+ Classifier: Environment :: X11 Applications :: Qt
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3.7
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Requires-Python: >=3.7,<4.0
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+
28
+ # First breaks picking
29
+ This project is devoted to pick waves that are the first to be detected on a seismogram (first breaks, first arrivals).
30
+ Traditionally, this procedure is performed manually. When processing field data, the number of picks reaches hundreds of
31
+ thousands. Existing analytical methods allow you to automate picking only on high-quality data with a high
32
+ signal / noise ratio.
33
+
34
+ As a more robust algorithm, it is proposed to use a neural network to pick the first breaks. Since the data on adjacent
35
+ seismic traces have similarities in the features of the wave field, **we pick first breaks on 2D seismic gather**, not
36
+ individual traces.
37
+
38
+ ![](docs/images/intro_small.PNG)
39
+
40
+ # Installation
41
+
42
+ Library is available in PyPI:
43
+ ```shell
44
+ pip install -U first-breaks-picking
45
+ ```
46
+
47
+ ### Extra data
48
+
49
+ - To pick first breaks you need
50
+ to [download model](https://oml.daloroserver.com/download/seis/fb.onnx).
51
+
52
+ - If you have no seismic data, you can also
53
+ [download small SGY file](https://raw.githubusercontent.com/DaloroAT/first_breaks_picking/main/data/real_gather.sgy).
54
+
55
+ It's also possible to download them with Python using the following snippet:
56
+
57
+ ```python
58
+ from first_breaks.utils.utils import (download_demo_sgy,
59
+ download_model_onnx)
60
+
61
+ sgy_filename = 'data.sgy'
62
+ model_filename = 'model.onnx'
63
+
64
+ download_demo_sgy(sgy_filename)
65
+ download_model_onnx(model_filename)
66
+ ```
67
+
68
+ # How to use it
69
+
70
+ The library can be used in Python, or you can use the desktop application. The former has more flexibility for
71
+ building your own picking scenario and processing multiple files. The difference between the latter is that it
72
+ allows you to work interactively with only one file and has better performance in visualization.
73
+
74
+
75
+ ### Create SGY
76
+ We provide several ways to create `SGY` object: from file, `bytes` or `numpy` array.
77
+
78
+ From file:
79
+ ```python
80
+ from first_breaks.sgy.reader import SGY
81
+
82
+ sgy_filename = ... # put path to your file.
83
+ sgy = SGY(sgy_filename)
84
+ ```
85
+
86
+ From `bytes`:
87
+ ```python
88
+ from first_breaks.sgy.reader import SGY
89
+
90
+ sgy_filename = ... # put path to your file.
91
+
92
+ with open(sgy_filename, 'rb') as fin:
93
+ sgy_bytes = fin.read()
94
+
95
+ sgy = SGY(sgy_bytes)
96
+ ```
97
+
98
+ From `numpy` array:
99
+ ```python
100
+ import numpy as np
101
+ from first_breaks.sgy.reader import SGY
102
+
103
+ num_samples = 1000
104
+ num_traces = 48
105
+ dt_mcs = 1e3
106
+
107
+ traces = np.random.random((num_samples, num_traces))
108
+ sgy = SGY(traces, dt_mcs=dt_mcs)
109
+ ```
110
+
111
+ #### Content of SGY
112
+
113
+ Created `SGY` allows you to read traces, get observation parameters and view headers (empty if created from `numpy`)
114
+
115
+ ```python
116
+ from first_breaks.sgy.reader import SGY
117
+
118
+ sgy: SGY = ... # put here previously created SGY
119
+
120
+ # get all traces or specific traces limited by time
121
+ all_traces = sgy.read()
122
+ block_of_data = sgy.read_traces_by_ids(ids=[1, 2, 3, 10],
123
+ min_sample=100,
124
+ max_sample=500)
125
+
126
+ # number of traces, values are the same
127
+ print(sgy.num_traces, sgy.ntr)
128
+ # number of time samples, values are the same
129
+ print(sgy.num_samples, sgy.ns)
130
+ # = (ns, ntr)
131
+ print(sgy.shape)
132
+ # time discretization, in mcs, in mcs, in ms
133
+ print(sgy.dt, sgy.dt_mcs, sgy.dt_ms)
134
+
135
+ # dict with headers in the first 3600 bytes of the file
136
+ print(sgy.general_headers)
137
+ # pandas DataFrame with headers for each trace
138
+ print(sgy.traces_headers.head())
139
+ ```
140
+
141
+ ### Create task for picking
142
+
143
+ Next, we create a task for picking and pass the picking parameters to it. They have default values, but for the
144
+ best quality, they must be matched to specific data. You can use the desktop application to evaluate the parameters.
145
+ A detailed description of the parameters can be found in the following chapters.
146
+
147
+ ```python
148
+ from first_breaks.sgy.reader import SGY
149
+ from first_breaks.picking.task import Task
150
+
151
+ sgy: SGY = ... # put here previously created SGY
152
+ task = Task(sgy,
153
+ traces_per_gather=24,
154
+ maximum_time=200)
155
+ ```
156
+
157
+ ### Pick first breaks
158
+
159
+ In this step, we use the neural network for picking. If you downloaded the model according to the installation section,
160
+ then pass the path to it. Or leave the path to the model empty so that we can download it automatically.
161
+
162
+ ```python
163
+ from first_breaks.picking.task import Task
164
+ from first_breaks.picking.picker import PickerONNX
165
+
166
+ task: Task = ... # put here previously created task
167
+ picker = PickerONNX()
168
+ task = picker.process_task(task)
169
+
170
+ # we can see results of picking
171
+ print(task.picks_in_samples)
172
+ print(task.picks_in_ms)
173
+ print(task.confidence)
174
+ ```
175
+
176
+
177
+
178
+
179
+
180
+
181
+ [//]: # (- We can create it from `numpy` array.)
182
+
183
+ # Picking process
184
+
185
+ Neural network process file as series of **images**. There is why **the traces should not be random**,
186
+ since we are using information about adjacent traces.
187
+
188
+
189
+ To obtain the first breaks we do the following steps:
190
+ 1) Read all traces in the file.
191
+ ![All traces](docs/images/full.png)
192
+ 2) Limit time range by `Maximum time`.
193
+ ![Limited by time](docs/images/tm_100.png)
194
+ 3) Split the sequence of traces into independent gathers of lengths `Traces per gather` each.
195
+ ![Splitted file](docs/images/tm_100_tr_24_24_24_24.png)
196
+ 4) Apply trace modification on the gathers level if necessary (`Gain`, `Clip`, etc).
197
+ 5) Calculate first breaks for individual gathers independently.
198
+ ![Picked shots](docs/images/tm_100_tr_24_24_24_24_picks.png)
199
+ 6) Join the first breaks of individual gathers.
200
+ ![Picked file](docs/images/tm_100_picks.png)
201
+
202
+ To achieve the best result, you need to modify the picking parameters.
203
+
204
+ ### Traces per gather
205
+
206
+ `Traces per gather` is the most important parameter for picking. The parameter defines how we split the sequence of
207
+ traces into individual gathers.
208
+
209
+ Suppose we need to process a file with 96 traces. Depending on the value of `Traces per gather` parameter, we will
210
+ process it as follows:
211
+ - `Traces per gather` = 24. We will process 4 gathers with 24 traces each.
212
+ ![4 full shots](docs/images/tm_100_tr_24_24_24_24.png)
213
+ - `Traces per gather` = 48. We will process 2 gathers with 48 traces each.
214
+ ![2 full shots](docs/images/tm_100_tr_48_48.png)
215
+ - `Traces per gather` = 40. We will process 2 gathers with 40 traces each and 1 gather with the remaining 16 traces.
216
+ The last gather will be interpolated from 16 to 40 traces.
217
+ ![2 full + 1 interpolated shots](docs/images/tm_100_tr_40_40_16.png)
218
+
219
+ ### Maximum time
220
+
221
+ You can localize the area for finding first breaks. Specify `Maximum time` if you have long records but the first breaks
222
+ located at the start of the traces. Keep it `0` if you don't want to limit traces.
223
+
224
+ ### List of traces to inverse
225
+
226
+ Some receivers may have the wrong polarity, so you can specify which traces should be inversed. Note, that inversion
227
+ will be applied on the gathers level. For example, if you have 96 traces, `Traces per gather` = 48 and
228
+ `List of traces to inverse` = (2, 30, 48), then traces (2, 3, 48, 50, 78, 96) will be inversed.
229
+
230
+ Notes:
231
+ - Trace indexing starts at 1.
232
+ - Option is not available on desktop app.
233
+
234
+
235
+ ## Recommendations
236
+ You can receive predictions for any file with any parameters, but to get a better result, you should comply with the
237
+ following guidelines:
238
+ - Your file should contain one or more gathers. By a gather, we mean that traces within a single gather can be
239
+ geophysically interpreted. **The traces within the same gather should not be random**, since we are using information
240
+ about adjacent traces.
241
+ - All gathers in the file must contain the same number of traces.
242
+ - The number of traces in gather must be equal to `Traces per gather` or divisible by it without a remainder.
243
+ For example, if you have CSP gathers and the number of receivers is 48, then you can set the parameter
244
+ value to 48, 24, or 12.
245
+ - We don't sort your file (CMP, CRP, CSP, etc), so you should send us files with traces sorted by yourself.
246
+ - You can process a file with independent seismograms obtained from different polygons, under different conditions, etc.,
247
+ but the requirements listed above must be met.
@@ -0,0 +1,220 @@
1
+ # First breaks picking
2
+ This project is devoted to pick waves that are the first to be detected on a seismogram (first breaks, first arrivals).
3
+ Traditionally, this procedure is performed manually. When processing field data, the number of picks reaches hundreds of
4
+ thousands. Existing analytical methods allow you to automate picking only on high-quality data with a high
5
+ signal / noise ratio.
6
+
7
+ As a more robust algorithm, it is proposed to use a neural network to pick the first breaks. Since the data on adjacent
8
+ seismic traces have similarities in the features of the wave field, **we pick first breaks on 2D seismic gather**, not
9
+ individual traces.
10
+
11
+ ![](docs/images/intro_small.PNG)
12
+
13
+ # Installation
14
+
15
+ Library is available in PyPI:
16
+ ```shell
17
+ pip install -U first-breaks-picking
18
+ ```
19
+
20
+ ### Extra data
21
+
22
+ - To pick first breaks you need
23
+ to [download model](https://oml.daloroserver.com/download/seis/fb.onnx).
24
+
25
+ - If you have no seismic data, you can also
26
+ [download small SGY file](https://raw.githubusercontent.com/DaloroAT/first_breaks_picking/main/data/real_gather.sgy).
27
+
28
+ It's also possible to download them with Python using the following snippet:
29
+
30
+ ```python
31
+ from first_breaks.utils.utils import (download_demo_sgy,
32
+ download_model_onnx)
33
+
34
+ sgy_filename = 'data.sgy'
35
+ model_filename = 'model.onnx'
36
+
37
+ download_demo_sgy(sgy_filename)
38
+ download_model_onnx(model_filename)
39
+ ```
40
+
41
+ # How to use it
42
+
43
+ The library can be used in Python, or you can use the desktop application. The former has more flexibility for
44
+ building your own picking scenario and processing multiple files. The difference between the latter is that it
45
+ allows you to work interactively with only one file and has better performance in visualization.
46
+
47
+
48
+ ### Create SGY
49
+ We provide several ways to create `SGY` object: from file, `bytes` or `numpy` array.
50
+
51
+ From file:
52
+ ```python
53
+ from first_breaks.sgy.reader import SGY
54
+
55
+ sgy_filename = ... # put path to your file.
56
+ sgy = SGY(sgy_filename)
57
+ ```
58
+
59
+ From `bytes`:
60
+ ```python
61
+ from first_breaks.sgy.reader import SGY
62
+
63
+ sgy_filename = ... # put path to your file.
64
+
65
+ with open(sgy_filename, 'rb') as fin:
66
+ sgy_bytes = fin.read()
67
+
68
+ sgy = SGY(sgy_bytes)
69
+ ```
70
+
71
+ From `numpy` array:
72
+ ```python
73
+ import numpy as np
74
+ from first_breaks.sgy.reader import SGY
75
+
76
+ num_samples = 1000
77
+ num_traces = 48
78
+ dt_mcs = 1e3
79
+
80
+ traces = np.random.random((num_samples, num_traces))
81
+ sgy = SGY(traces, dt_mcs=dt_mcs)
82
+ ```
83
+
84
+ #### Content of SGY
85
+
86
+ Created `SGY` allows you to read traces, get observation parameters and view headers (empty if created from `numpy`)
87
+
88
+ ```python
89
+ from first_breaks.sgy.reader import SGY
90
+
91
+ sgy: SGY = ... # put here previously created SGY
92
+
93
+ # get all traces or specific traces limited by time
94
+ all_traces = sgy.read()
95
+ block_of_data = sgy.read_traces_by_ids(ids=[1, 2, 3, 10],
96
+ min_sample=100,
97
+ max_sample=500)
98
+
99
+ # number of traces, values are the same
100
+ print(sgy.num_traces, sgy.ntr)
101
+ # number of time samples, values are the same
102
+ print(sgy.num_samples, sgy.ns)
103
+ # = (ns, ntr)
104
+ print(sgy.shape)
105
+ # time discretization, in mcs, in mcs, in ms
106
+ print(sgy.dt, sgy.dt_mcs, sgy.dt_ms)
107
+
108
+ # dict with headers in the first 3600 bytes of the file
109
+ print(sgy.general_headers)
110
+ # pandas DataFrame with headers for each trace
111
+ print(sgy.traces_headers.head())
112
+ ```
113
+
114
+ ### Create task for picking
115
+
116
+ Next, we create a task for picking and pass the picking parameters to it. They have default values, but for the
117
+ best quality, they must be matched to specific data. You can use the desktop application to evaluate the parameters.
118
+ A detailed description of the parameters can be found in the following chapters.
119
+
120
+ ```python
121
+ from first_breaks.sgy.reader import SGY
122
+ from first_breaks.picking.task import Task
123
+
124
+ sgy: SGY = ... # put here previously created SGY
125
+ task = Task(sgy,
126
+ traces_per_gather=24,
127
+ maximum_time=200)
128
+ ```
129
+
130
+ ### Pick first breaks
131
+
132
+ In this step, we use the neural network for picking. If you downloaded the model according to the installation section,
133
+ then pass the path to it. Or leave the path to the model empty so that we can download it automatically.
134
+
135
+ ```python
136
+ from first_breaks.picking.task import Task
137
+ from first_breaks.picking.picker import PickerONNX
138
+
139
+ task: Task = ... # put here previously created task
140
+ picker = PickerONNX()
141
+ task = picker.process_task(task)
142
+
143
+ # we can see results of picking
144
+ print(task.picks_in_samples)
145
+ print(task.picks_in_ms)
146
+ print(task.confidence)
147
+ ```
148
+
149
+
150
+
151
+
152
+
153
+
154
+ [//]: # (- We can create it from `numpy` array.)
155
+
156
+ # Picking process
157
+
158
+ Neural network process file as series of **images**. There is why **the traces should not be random**,
159
+ since we are using information about adjacent traces.
160
+
161
+
162
+ To obtain the first breaks we do the following steps:
163
+ 1) Read all traces in the file.
164
+ ![All traces](docs/images/full.png)
165
+ 2) Limit time range by `Maximum time`.
166
+ ![Limited by time](docs/images/tm_100.png)
167
+ 3) Split the sequence of traces into independent gathers of lengths `Traces per gather` each.
168
+ ![Splitted file](docs/images/tm_100_tr_24_24_24_24.png)
169
+ 4) Apply trace modification on the gathers level if necessary (`Gain`, `Clip`, etc).
170
+ 5) Calculate first breaks for individual gathers independently.
171
+ ![Picked shots](docs/images/tm_100_tr_24_24_24_24_picks.png)
172
+ 6) Join the first breaks of individual gathers.
173
+ ![Picked file](docs/images/tm_100_picks.png)
174
+
175
+ To achieve the best result, you need to modify the picking parameters.
176
+
177
+ ### Traces per gather
178
+
179
+ `Traces per gather` is the most important parameter for picking. The parameter defines how we split the sequence of
180
+ traces into individual gathers.
181
+
182
+ Suppose we need to process a file with 96 traces. Depending on the value of `Traces per gather` parameter, we will
183
+ process it as follows:
184
+ - `Traces per gather` = 24. We will process 4 gathers with 24 traces each.
185
+ ![4 full shots](docs/images/tm_100_tr_24_24_24_24.png)
186
+ - `Traces per gather` = 48. We will process 2 gathers with 48 traces each.
187
+ ![2 full shots](docs/images/tm_100_tr_48_48.png)
188
+ - `Traces per gather` = 40. We will process 2 gathers with 40 traces each and 1 gather with the remaining 16 traces.
189
+ The last gather will be interpolated from 16 to 40 traces.
190
+ ![2 full + 1 interpolated shots](docs/images/tm_100_tr_40_40_16.png)
191
+
192
+ ### Maximum time
193
+
194
+ You can localize the area for finding first breaks. Specify `Maximum time` if you have long records but the first breaks
195
+ located at the start of the traces. Keep it `0` if you don't want to limit traces.
196
+
197
+ ### List of traces to inverse
198
+
199
+ Some receivers may have the wrong polarity, so you can specify which traces should be inversed. Note, that inversion
200
+ will be applied on the gathers level. For example, if you have 96 traces, `Traces per gather` = 48 and
201
+ `List of traces to inverse` = (2, 30, 48), then traces (2, 3, 48, 50, 78, 96) will be inversed.
202
+
203
+ Notes:
204
+ - Trace indexing starts at 1.
205
+ - Option is not available on desktop app.
206
+
207
+
208
+ ## Recommendations
209
+ You can receive predictions for any file with any parameters, but to get a better result, you should comply with the
210
+ following guidelines:
211
+ - Your file should contain one or more gathers. By a gather, we mean that traces within a single gather can be
212
+ geophysically interpreted. **The traces within the same gather should not be random**, since we are using information
213
+ about adjacent traces.
214
+ - All gathers in the file must contain the same number of traces.
215
+ - The number of traces in gather must be equal to `Traces per gather` or divisible by it without a remainder.
216
+ For example, if you have CSP gathers and the number of receivers is 48, then you can set the parameter
217
+ value to 48, 24, or 12.
218
+ - We don't sort your file (CMP, CRP, CSP, etc), so you should send us files with traces sorted by yourself.
219
+ - You can process a file with independent seismograms obtained from different polygons, under different conditions, etc.,
220
+ but the requirements listed above must be met.
File without changes