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

added ability to read SEGY file version 0.0 #483

Merged
merged 3 commits into from
Jan 10, 2025
Merged

added ability to read SEGY file version 0.0 #483

merged 3 commits into from
Jan 10, 2025

Conversation

aaronjgirard
Copy link
Collaborator

@aaronjgirard aaronjgirard commented Jan 9, 2025

Description

Added ability to read a segy file if version is set to 0.0
Tested on file from:
https://ddfe.curtin.edu.au/7h0e-d392/2020_GeoLab_WVSP_Geophone_wgm.sgy

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes.
  • documented the new feature with docstrings or appropriate doc page.
  • included a test. See testing guidelines.
  • your name has been added to the contributors page (docs/contributors.md).
  • added the "ready_for_review" tag once the PR is ready to be reviewed.

Summary by CodeRabbit

  • New Features
    • Added support for SEGY version 0.0 format in the data processing library.

Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Walkthrough

A new class SegyV0_0 has been added to the SEGY file handling module within the core SEGY I/O implementation. This class inherits from SegyV1_0 and is specifically designed to support version 0.0 of the SEGY format, with its version attribute explicitly set to "0.0". No other classes or methods have been modified in this change.

Changes

File Change Summary
dascore/io/segy/core.py Added SegyV0_0 class inheriting from SegyV1_0 with version set to "0.0"

Poem

🐰 A new SEGY version hops to life,
Version zero-point-zero joins the strife,
Inheriting traits from its parent so wise,
A digital rabbit with format surprise!
In data's vast landscape, it finds its place 🗂️


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0c7b4e and b171e62.

📒 Files selected for processing (1)
  • dascore/io/segy/core.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dascore/io/segy/core.py
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: test_code (windows-latest, 3.12)
  • GitHub Check: test_code (windows-latest, 3.11)
  • GitHub Check: test_code (windows-latest, 3.10)
  • GitHub Check: test_code (macos-latest, 3.12)
  • GitHub Check: test_code (macos-latest, 3.11)
  • GitHub Check: test_code (macos-latest, 3.10)
  • GitHub Check: test_code (ubuntu-latest, 3.12)
  • GitHub Check: test_code (ubuntu-latest, 3.11)
  • GitHub Check: test_code (ubuntu-latest, 3.10)
  • GitHub Check: test_code_min_deps (windows-latest, 3.13)
  • GitHub Check: test_code_min_deps (windows-latest, 3.12)
  • GitHub Check: test_code_min_deps (macos-latest, 3.13)
  • GitHub Check: test_code_min_deps (macos-latest, 3.12)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.13)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.12)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
dascore/io/segy/core.py (1)

90-94: Consider refactoring the SEGY version class hierarchy.

The current design has all version classes inheriting from SegyV1_0, including both older (V0_0) and newer (V2_x) versions. This might make it difficult to implement version-specific behavior in the future.

Consider introducing a base SegyBase class that contains common functionality, allowing each version to implement its specific behavior independently.

Would you like me to propose a refactored class hierarchy that better supports version-specific implementations?

🧰 Tools
🪛 Ruff (0.8.2)

91-91: No whitespaces allowed surrounding docstring text

Trim surrounding whitespace

(D210)


91-91: Line too long (95 > 88)

(E501)

🪛 GitHub Actions: LintCode

[error] 91-91: Line too long (94 > 88 characters)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc1a02f and bf8a85f.

📒 Files selected for processing (1)
  • dascore/io/segy/core.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
dascore/io/segy/core.py

91-91: No whitespaces allowed surrounding docstring text

Trim surrounding whitespace

(D210)


91-91: Line too long (95 > 88)

(E501)

🪛 GitHub Actions: LintCode
dascore/io/segy/core.py

[error] 91-91: Line too long (94 > 88 characters)

⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: test_code (windows-latest, 3.12)
  • GitHub Check: test_code (windows-latest, 3.11)
  • GitHub Check: test_code (windows-latest, 3.10)
  • GitHub Check: test_code (macos-latest, 3.12)
  • GitHub Check: test_code_min_deps (windows-latest, 3.13)
  • GitHub Check: test_code (macos-latest, 3.11)
  • GitHub Check: test_code_min_deps (windows-latest, 3.12)
  • GitHub Check: test_code (macos-latest, 3.10)
  • GitHub Check: test_code_min_deps (macos-latest, 3.13)
  • GitHub Check: test_code (ubuntu-latest, 3.12)
  • GitHub Check: test_code_min_deps (macos-latest, 3.12)
  • GitHub Check: test_code (ubuntu-latest, 3.11)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.13)
  • GitHub Check: test_code (ubuntu-latest, 3.10)
  • GitHub Check: test_code_min_deps (ubuntu-latest, 3.12)
🔇 Additional comments (1)
dascore/io/segy/core.py (1)

90-94: Verify version detection logic.

Since this class handles both version 0.0 and unset versions, we should verify the version detection logic in _get_segy_version.

Let's check the version detection implementation:

✅ Verification successful

Version detection implementation is correct and robust

The version detection logic in _get_segy_version properly handles both version 0.0 and unset versions by:

  • Reading version numbers from the standard SEGY binary header (bytes 300-302)
  • Validating major version numbers against allowed values (0,1,2,3)
  • Falling back to SegyV0_0 for both version 0.0 and invalid/unset versions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check how version detection is implemented

# Search for version detection function
ast-grep --pattern 'def _get_segy_version($$$)'

# Search for any version-related constants or patterns
rg -A 5 'version.*0\.0|unset.*version' --type py

Length of output: 2806


Script:

#!/bin/bash
# Search for SegyV1_0 class and its methods
ast-grep --pattern 'class SegyV1_0($$$)'

# Look for version-related methods in SEGY files
rg -A 10 'def.*version' dascore/io/segy/

# Search for format reading code
rg -A 5 'read.*format|parse.*format|detect.*format' dascore/io/segy/

Length of output: 1710


Script:

#!/bin/bash
# Get the complete implementation of _get_segy_version
rg -A 30 '^def _get_segy_version' dascore/io/segy/utils.py

Length of output: 1281

🧰 Tools
🪛 Ruff (0.8.2)

91-91: No whitespaces allowed surrounding docstring text

Trim surrounding whitespace

(D210)


91-91: Line too long (95 > 88)

(E501)

🪛 GitHub Actions: LintCode

[error] 91-91: Line too long (94 > 88 characters)

Comment on lines 90 to 94
class SegyV0_0(SegyV1_0): # noqa
"""An IO class supporting version 0.0 of the SEGY format. Or if the version is not set. """

version = "0.0"

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix docstring formatting and line length.

The docstring has formatting issues and exceeds the line length limit. Additionally, consider documenting how unset versions are detected.

Apply this diff to fix the formatting:

-class SegyV0_0(SegyV1_0):  # noqa
-    """An IO class supporting version 0.0 of the SEGY format. Or if the version is not set. """
+class SegyV0_0(SegyV1_0):  # noqa
+    """An IO class supporting version 0.0 of the SEGY format.
+
+    This class handles both explicit version 0.0 and cases where the version is not set.
+    """
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class SegyV0_0(SegyV1_0): # noqa
"""An IO class supporting version 0.0 of the SEGY format. Or if the version is not set. """
version = "0.0"
class SegyV0_0(SegyV1_0): # noqa
"""An IO class supporting version 0.0 of the SEGY format.
This class handles both explicit version 0.0 and cases where the version is not set.
"""
version = "0.0"
🧰 Tools
🪛 Ruff (0.8.2)

91-91: No whitespaces allowed surrounding docstring text

Trim surrounding whitespace

(D210)


91-91: Line too long (95 > 88)

(E501)

🪛 GitHub Actions: LintCode

[error] 91-91: Line too long (94 > 88 characters)

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (bc1a02f) to head (b171e62).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #483   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files         118      118           
  Lines        9700     9702    +2     
=======================================
+ Hits         9686     9688    +2     
  Misses         14       14           
Flag Coverage Δ
unittests 99.85% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@d-chambers d-chambers merged commit f359c8c into master Jan 10, 2025
19 checks passed
@d-chambers d-chambers deleted the segyv0 branch January 10, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants