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

Add tropo_local_texture.py for tropo correction (Yang et al., 2024) #1291

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

Conversation

Yohcy
Copy link

@Yohcy Yohcy commented Nov 11, 2024

Description of proposed changes

This code is based on this work:

  • Yang, Q., Yunjun, Z., Wang, R. Y. (2024). Heterogeneous InSAR Tropospheric Correction Based on Local Texture Correlation, IEEE Transactions on Geoscience and Remote Sensing, 62, doi:10.1109/TGRS.2024.3356749.

This code only completes the low resolution part of this work. With the help of Yang Qingyue, it successfully gets almost the same result as in the work above.
Some figures during the correction process are shown below:

  • Slope Esitimation
    k_htc
  • Slope Interpolation
    interpolation
  • Intercept Filtering
    intercept
  • Estimated Low-resolution Tropo Delay
    tropo_delay

Low-resolution correction in Yang' work:
image

Before corrections
Figure_1_-_timeseries_ramp_demErr_wrap10 png
Date: February 3, 2015 and August 21, 2017
Figure_1

After corrections
Figure_1_-_timeseries_tropolocaltexture_wrap10 png
Date: February 3, 2015 and August 21, 2017
Figure_2

Reminders

  • Fix #xxxx
  • Pass Pre-commit check (green)
  • Pass Codacy code review (green)
  • Pass Circle CI test (green)
  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • If modifying functionality, describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

Summary by Sourcery

Add a new tropospheric correction method using local texture correlation, based on Yang et al.'s 2024 research. Update the configuration and workflow to support this method, and provide documentation for its usage.

New Features:

  • Introduce a new tropospheric correction method based on local texture correlation, as described in Yang et al., 2024.

Enhancements:

  • Add support for the 'local_texture' method in the tropospheric delay correction workflow.

Documentation:

  • Include documentation for the new 'local_texture' method, detailing its parameters and usage.

Summary by Sourcery

Add a new tropospheric correction method using local texture correlation, based on Yang et al.'s 2024 research. Update the configuration and workflow to support this method, and provide documentation for its usage.

New Features:

  • Introduce a new tropospheric correction method based on local texture correlation, as described in Yang et al., 2024.

Enhancements:

  • Add support for the 'local_texture' method in the tropospheric delay correction workflow.

Documentation:

  • Include documentation for the new 'local_texture' method, detailing its parameters and usage.

Copy link

welcome bot commented Nov 11, 2024

💖 Thanks for opening this pull request! Please check out our contributing guidelines. 💖
Keep in mind that all new features should be documented. It helps to write the comments next to the code or below your functions describing all arguments, and return types before writing the code. This will help you think about your code design and usually results in better code.

Copy link

sourcery-ai bot commented Nov 11, 2024

Reviewer's Guide by Sourcery

This PR introduces a new tropospheric delay correction method based on local texture correlation, implementing the low-resolution component of Yang et al.'s 2024 work. The implementation includes slope estimation, interpolation, and intercept filtering steps to correct tropospheric delays in InSAR time series data.

Sequence diagram for tropospheric delay correction process

sequenceDiagram
    participant User
    participant CLI
    participant TropoLocalTexture
    User->>CLI: Run tropo_local_texture.py
    CLI->>TropoLocalTexture: run_tropo_local_texture(inps)
    TropoLocalTexture->>TropoLocalTexture: read_topographic_data(geom_file)
    TropoLocalTexture->>TropoLocalTexture: estimate_local_slope(dem, ts_data, inps, n_ref, meta)
    TropoLocalTexture->>TropoLocalTexture: slope_interpolation(ts_data, inps, k_htc)
    TropoLocalTexture->>TropoLocalTexture: intercept_filtering(dem, ts_data, inps, k_htc_interp, meta)
    TropoLocalTexture-->>CLI: Return corrected data
    CLI-->>User: Output corrected timeseries file
Loading

Class diagram for the new tropospheric correction method

classDiagram
    class TropoLocalTexture {
        +read_topographic_data(geom_file)
        +estimate_local_slope(dem, ts_data, inps, n_ref, meta)
        +slope_interpolation(ts_data, inps, k_htc)
        +intercept_filtering(dem, ts_data, inps, k_htc_interp, meta)
        +run_tropo_local_texture(inps)
    }
    class CLI {
        +create_parser(subparsers)
        +cmd_line_parse(iargs)
        +main(iargs)
    }
    TropoLocalTexture <|-- CLI
    note for TropoLocalTexture "This class implements the new tropospheric correction method based on local texture correlation."
Loading

File-Level Changes

Change Details Files
Added new tropospheric correction method using local texture correlation
  • Created new module for local texture-based tropospheric correction
  • Implemented slope estimation using texture correlation
  • Added slope interpolation for full-scale coverage
  • Implemented intercept filtering for final correction
src/mintpy/tropo_local_texture.py
src/mintpy/cli/tropo_local_texture.py
Updated configuration system to support the new correction method
  • Added 'local_texture' as a new tropospheric correction method option
  • Added configuration parameters for window size and overlap ratio
  • Set default values for new parameters (window size: 141, overlap ratio: 0.4)
src/mintpy/defaults/smallbaselineApp.cfg
src/mintpy/defaults/smallbaselineApp_auto.cfg
Integrated new correction method into existing workflow
  • Added support for local texture method in timeseries filename generation
  • Updated tropospheric delay correction workflow to handle the new method
src/mintpy/smallbaselineApp.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

codeautopilot bot commented Nov 11, 2024

PR summary

This Pull Request introduces a new method for tropospheric correction in InSAR data processing, based on local texture correlation as described in Yang et al.'s 2024 research. The new method, implemented in tropo_local_texture.py, aims to improve the accuracy of tropospheric delay corrections by leveraging high-frequency texture to estimate local slopes. The PR updates the configuration files and workflow to support this new method and includes documentation for its usage. The changes are expected to enhance the precision of InSAR data analysis by providing an alternative correction method that can be particularly useful in heterogeneous environments.

Suggestion

  1. Ensure comprehensive testing of the new method across various datasets to validate its effectiveness and robustness.
  2. Consider adding more detailed comments and documentation within the code to facilitate understanding and future maintenance.
  3. Evaluate the performance impact of the new method, as the additional computations for local texture correlation might increase processing time.
  4. Provide a comparison of results with existing methods to highlight the improvements or differences achieved by the new approach.

Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect.

Current plan usage: 0.00%

Have feedback or need help?
Discord
Documentation
[email protected]

@Yohcy Yohcy marked this pull request as ready for review November 12, 2024 07:52
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Yohcy - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider removing commented out debug code (e.g. in smallbaselineApp.py) and resolving remaining TODO comments before merging
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

max_tmp = np.where(max_tmp > res_step, max_tmp - res_step, max_tmp)
mask_std[np.abs(cor_tmp) > max_tmp] = np.nan

if np.nansum(~np.isnan(mask_std)) < np.nansum(~np.isnan(mask_process)) / 10: #TODO
Copy link

Choose a reason for hiding this comment

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

suggestion: Magic number 10 in threshold check should be a named constant or configurable parameter

MIN_VALID_PIXELS_RATIO = 0.1
                    if np.nansum(~np.isnan(mask_std)) < np.nansum(~np.isnan(mask_process)) * MIN_VALID_PIXELS_RATIO:

phase_tmp = ts_data[n, :, :] * mask_std
dem_tmp = dem * mask_std
valid_idx = ~np.isnan(phase_tmp) & ~np.isnan(dem_tmp)
if np.nansum(valid_idx) == 0:
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The continue statement could silently skip processing without any warning

Consider logging a warning when skipping processing due to no valid pixels, as this could indicate an underlying data quality issue.

phase_ts_htc_low[n, :, :] = tmp
intercept[n, :, :] = tmp_filt
reference_phase = phase_ts_htc_low[:, ref_y - 1, ref_x - 1]
phase_ts_htc_low = phase_ts_htc_low - reference_phase[:, np.newaxis, np.newaxis] #TODO
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): TODO comment on critical reference phase correction needs to be resolved

The TODO comment on this reference phase correction operation should be resolved before production use, as it could affect the correctness of the results.

src/mintpy/tropo_local_texture.py Show resolved Hide resolved
@yunjunz yunjunz self-requested a review November 14, 2024 06:05
@yunjunz yunjunz changed the title Tropo local texture: Add tropo_local_texture.py for troposphere correction based on Yang's work Add tropo_local_texture.py for troposphere correction based on Yang et al, 2024 Nov 24, 2024
@yunjunz yunjunz changed the title Add tropo_local_texture.py for troposphere correction based on Yang et al, 2024 Add tropo_local_texture.py for tropospheric correction based on Yang et al. (2024, TGRS) Nov 27, 2024
@yunjunz yunjunz changed the title Add tropo_local_texture.py for tropospheric correction based on Yang et al. (2024, TGRS) Add tropo_local_texture.py for tropo correction based on Yang et al. (2024, TGRS) Nov 27, 2024
@yunjunz yunjunz changed the title Add tropo_local_texture.py for tropo correction based on Yang et al. (2024, TGRS) Add tropo_local_texture.py for tropo correction based on Yang et al., 2024 Nov 27, 2024
@yunjunz yunjunz changed the title Add tropo_local_texture.py for tropo correction based on Yang et al., 2024 Add tropo_local_texture.py for tropo correction (Yang et al., 2024) Nov 27, 2024
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