Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@esrivas17
Copy link
Contributor

@esrivas17 esrivas17 commented Jun 26, 2025

I am trying to use Mintpy to process data coming from GMTSAR for ERS (time span 1993-2010) and I noticed that the coherence matrix is not calculated correctly for dates coming before 2000, given that the coherence matrix function uses the ptime.yymmdd function taking the last values of the year for each day, and it works for images after 2000 but not if the time span cover images from the 90's, (once it sorts the dates, the 99, 98 images from 1999, 1998 will be put last with the highest indexes)

I am proposing these changes that can fix the problem for these dates and keep the functionality for more recent times spans (after 2000/ Sentinel1 time coverage)

I am changing the coherence matrix function that only returns the coherence matrix, so I believe it should not affect any other functionality.

Here is an example of a wrong coherence matrix for my ERS (1995-2010) time span data

image

And this is the actual network:

image

@welcome
Copy link

welcome bot commented Jun 26, 2025

πŸ’– 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.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jun 26, 2025

Reviewer's Guide

Replaced two-digit year parsers with four-digit year equivalents and updated date string splitting to underscore-based format in the coherence_matrix function to correctly sort and index pre-2000 dates while preserving existing behavior.

Class diagram for updated date handling in coherence_matrix function

classDiagram
    class ptime {
        +yyyymmdd_date12(date12_list)
        +yyyymmdd(date_list)
        -yymmdd_date12(date12_list)  // replaced
        -yymmdd(date_list)           // replaced
    }
    class network {
        +coherence_matrix(date12_list, coh_list, diag_value, fill_triangle)
    }
    network ..> ptime : uses
direction LR
Loading

Flow diagram for updated date parsing in coherence_matrix

flowchart TD
    A[Input date12_list with date pairs] --> B[Convert date12_list using ptime.yyyymmdd_date12]
    B --> C[Split date pairs by underscore]
    C --> D[Combine and sort unique dates]
    D --> E[Convert date_list using ptime.yyyymmdd]
    E --> F[Build coherence matrix using new indices]
Loading

File-Level Changes

Change Details Files
Replaced two-digit-year conversion calls with four-digit-year equivalents
  • Swap ptime.yymmdd_date12 to ptime.yyyymmdd_date12
  • Swap ptime.yymmdd to ptime.yyyymmdd
src/mintpy/utils/network.py
Changed date12 string delimiter handling to underscore
  • Use split('') instead of split('-') for extracting master and slave dates
  • Updated loop parsing of date12 to split on ''
src/mintpy/utils/network.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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
Contributor

@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 @esrivas17 - I've reviewed your changes and they look great!


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.

Copy link
Member

@yunjunz yunjunz left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @esrivas17 for finding the issue and the PR!

@yunjunz yunjunz changed the title coherence matrix support for dates before 2000 network.coherence_matrix(): bugfix for sorting dates before 2000 Jun 27, 2025
@yunjunz yunjunz merged commit ee92927 into insarlab:main Jun 27, 2025
8 checks passed
@welcome
Copy link

welcome bot commented Jun 27, 2025

πŸŽ‰ πŸŽ‰ πŸŽ‰ Congrats on merging your first pull request! We here at behaviorbot are proud of you! πŸŽ‰ πŸŽ‰ πŸŽ‰

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