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

Skip to content

Conversation

@barely-sad-one
Copy link
Contributor

@barely-sad-one barely-sad-one commented May 18, 2025

This PR adds support for the -m and --zero-mask command-line arguments to the save_gdal.py CLI, allowing users to:

  • -m /path/to/mask: Apply a custom mask file (e.g. maskTempCoh.h5) to exclude invalid pixels.
  • --zero-mask: Automatically mask all zero-valued pixels in the data array.

Changes

  • Updated save_gdal.py to accept and handle inps.mask_file and inps.zero_mask.
  • Applied masking logic before writing output using data[mask == 0] = np.nan and data[data == 0] = np.nan.

Reminders

  • Fix -m --mask option for save_gdal/qgis.pyΒ #1254
  • 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 support for custom and zero-value masking to the save_gdal.py command-line interface and apply the masking logic prior to output generation

New Features:

  • Add -m/--mask argument to save_gdal.py CLI for specifying a custom mask file
  • Add --zero-mask flag to automatically mask zero-valued pixels before writing output

Enhancements:

  • Apply masking logic in save_gdal.py using the provided mask file and zero-mask option before file export

@welcome
Copy link

welcome bot commented May 18, 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 May 18, 2025

Reviewer's Guide

Enhances the save_gdal CLI by adding options to apply a user-supplied mask file and/or automatically mask zero-valued pixels, integrating the new masking steps into the data preparation workflow before writing output.

File-Level Changes

Change Details Files
Integrate custom and zero-value masking in save_gdal
  • Read custom mask via pp.read_mask when mask_file is specified
  • Set data[mask == 0] to NaN to exclude invalid pixels
  • Check zero_mask flag and set data[data == 0] to NaN
  • Release mask array after use
src/mintpy/save_gdal.py
Extend CLI to accept mask and zero-mask options
  • Add -m/--mask argument for specifying a mask file
  • Add --zero-mask flag to enable automatic zero-value masking
src/mintpy/cli/save_gdal.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1254 Add a -m --mask option to save_gdal.py to allow users to specify a mask file. βœ…
#1254 Implement the functionality to mask out pixels based on the provided mask file. βœ…

Possibly linked issues


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

Here's what I looked at during the review
  • 🟑 General issues: 1 issue found
  • 🟒 Testing: all looks good
  • 🟒 Complexity: all looks good
  • 🟒 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.

@yunjunz yunjunz self-requested a review June 3, 2025 06:15
@yunjunz yunjunz changed the title Add -m --zero-mask to save_gdal.py Add save_gdal.py --mask/--zero-mask options Jun 3, 2025
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.

Thank you @barely-sad-one for the PR! Looks all good to me.

@yunjunz yunjunz merged commit 2de8201 into insarlab:main Jun 3, 2025
8 checks passed
@welcome
Copy link

welcome bot commented Jun 3, 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.

-m --mask option for save_gdal/qgis.py

2 participants