Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement interactive selector of trace headers specs #12

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

alexanderkuvaev
Copy link
Contributor

This PR adds a number of utils to perform interactive selection and validation of trace header specs:

  • TraceHeaderSpecSelector - a base class that defines a widget which allows specifying custom start bytes, dtypes and endiannesses of trace headers and displays loaded values for a subset of traces. It also prints textual headers of the file since they usually contain information about headers' locations.
  • select_pre_stack_header_specs and select_post_stack_header_specs - thin wrappers around TraceHeaderSpecSelector with predefined sets of headers to validate for pre-stack and post-stack SEG-Y files respectively.
image

The resulting header specs can be accessed via headers attribute of the returned object:

specs = select_pre_stack_header_specs("./path/to/segy")
# Select and validate specs
print(specs.headers)

Other changes:

  • Added extras_require block in setup.py with optional interactive dependencies
  • Copy-pasted DelayedImport from batchflow next to as well copy-pasted ForPoolExecutor 😢
  • Fixed a small bug in TraceHeaderSpec.is_standard check

@alexanderkuvaev alexanderkuvaev added the enhancement New feature or request label Feb 21, 2024
@alexanderkuvaev alexanderkuvaev self-assigned this Feb 21, 2024
@alexanderkuvaev alexanderkuvaev marked this pull request as ready for review February 22, 2024 09:39
self.file_n_traces = self.loader.n_traces
self.n_traces = min(n_traces, self.file_n_traces)

self.dtype_str_to_np = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a class attribute?

Anchor for resolving the package name. Used only for relative imports.
attribute : str, optional
Name of attribute to get from loaded module.
help : str, optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a use-case as an example


WIDGET_HEIGHT = "30px"
BUTTON_WIDTH = "35px"
title_layout = widgets.Layout(height=WIDGET_HEIGHT, width="auto", flex="1 1 auto")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about put all layout kwargs to some default config to have an ability to change them?

TEXT_HEADER_LINE_LENGTH = 80
text_header_list = []
for text_header in self.loader.text:
text_header = text_header.decode(errors="replace")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really can use system encoding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants