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

[1pt] PR: Remove warning messages #1224

Merged
merged 7 commits into from
Jul 19, 2024
Merged

Conversation

mluck
Copy link
Contributor

@mluck mluck commented Jul 18, 2024

Addresses warnings to reduce output messages. Closes #1223.

Changes

  • src/
    • adjust_thalweg_lateral.py: fixes number type
    • src/delineate_hydros_and_produce_HAND.sh: removes division by zero warning
    • getRasterInfoNative.py: adds gdal.UseExceptions()

Testing

I ran fim_pipeline.sh the REM grids were identical. Evaluation results from synthesize_test_cases.py were also identical. Output from the specific modules is below.

src/adjust_thalweg_lateral.py

Before
Performing lateral thalweg adjustment 03100204 0
/foss_fim/src/adjust_thalweg_lateral.py:31: NumbaTypeSafetyWarning: unsafe cast from int64 to int32. Precision may be lost.
  if elev_m in zone_min_dict:
After
Performing lateral thalweg adjustment 03100204 0

src/delineate_hydros_and_produce_HAND.sh

Before
Mask Burned DEM for Thalweg Only 03100204 0
<string>:1: RuntimeWarning: divide by zero encountered in divide
/usr/lib/python3/dist-packages/osgeo_utils/gdal_calc.py:644: RuntimeWarning: invalid value encountered in multiply
  myResult = ((1 * (myNDVs == 0)) * myResult) + (myOutNDV * myNDVs)
After
Mask Burned DEM for Thalweg Only 03100204 0

src/getRasterInfoNative.py

Currently: without either gdal.UseExceptions() or gdal.DontUseExceptions()

root@0a8147638c97:/foss_fim# python3 /foss_fim/src/getRasterInfoNative.py /outputs/dev-4.5.2.6/05030106/dem_meters.tif
/usr/lib/python3/dist-packages/osgeo/gdal.py:315: FutureWarning: Neither gdal.UseExceptions() nor gdal.DontUseExceptions() has been explicitly called. In GDAL 4.0, exceptions will be enabled by default.
  warnings.warn(
216.9MB 8454 8684 -999999.0 1242040.6235814968 1944553.8012970928 1326580.6235814968 2031393.8012970928 10.000000000000000 10.000000000000000

With gdal.UseExceptions() (this PR):

root@0a8147638c97:/foss_fim# python3 /foss_fim/src/getRasterInfoNative.py /outputs/dev-4.5.2.6/05030106/dem_meters.tif
216.9MB 8454 8684 -999999.0 1242040.6235814968 1944553.8012970928 1326580.6235814968 2031393.8012970928 10.000000000000000 10.000000000000000

With gdal.DontUseExceptions():

root@0a8147638c97:/foss_fim# python3 /foss_fim/src/getRasterInfoNative.py /outputs/dev-4.5.2.6/05030106/dem_meters.tif
216.9MB 8454 8684 -999999.0 1242040.6235814968 1944553.8012970928 1326580.6235814968 2031393.8012970928 10.000000000000000 10.000000000000000

Deployment Plan (For developer use)

How does the changes affect the product?

  • Code only?
  • Require new or adjusted data inputs? Does it have start, end and duration code (in UTC)?
  • If new or updated data sets, has the FIM code been updated and tested with the new/adjusted data (subset is fine, but must be a subset of the new data)?
  • Require new pre-clip set?
  • Has new or updated python packages?
  • If applicable, has a deployment plan be created with the deployment person/team?

Issuer Checklist (For developer use)

You may update this checklist before and/or after creating the PR. If you're unsure about any of them, please ask, we're here to help! These items are what we are going to look for before merging your code.

  • Informative and human-readable title, using the format: [_pt] PR: <description>
  • Links are provided if this PR resolves an issue, or depends on another other PR
  • If submitting a PR to the dev branch (the default branch), you have a descriptive Feature Branch name using the format: dev-<description-of-change> (e.g. dev-revise-levee-masking)
  • Changes are limited to a single goal (no scope creep)
  • The feature branch you're submitting as a PR is up to date (merged) with the latest dev branch
  • pre-commit hooks were run locally
  • Any change in functionality is tested
  • Passes all unit tests locally (inside interactive Docker container, at /foss_fim/, run: pytest unit_tests/)
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • CHANGELOG updated with template version number, e.g. 4.x.x.x
  • Reviewers requested
  • Add yourself as an assignee in the PR as well as the FIM Technical Lead

Merge Checklist (For Technical Lead use only)

  • Update CHANGELOG with latest version number and merge date
  • Update the Citation.cff file to reflect the latest version number in the CHANGELOG
  • If applicable, update README with major alterations

@mluck mluck added Low Priority good first issue This would be well suited for a someone as a first contribution labels Jul 18, 2024
@mluck mluck requested a review from RobHanna-NOAA July 18, 2024 21:38
RobHanna-NOAA
RobHanna-NOAA previously approved these changes Jul 19, 2024
Copy link
Contributor

@RobHanna-NOAA RobHanna-NOAA left a comment

Choose a reason for hiding this comment

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

grep -H -r -i -n "warning" ./logs/ > ./all_warnings_from_logs.log shows tons of warnings but this particular one is gone. :)

(sorry.. didn't mean to sound cheeky. It all helps)

@mluck mluck changed the title [1pt] PR: Remove GDAL FutureWarning [1pt] PR: Remove warning messages Jul 19, 2024
RobHanna-NOAA
RobHanna-NOAA previously approved these changes Jul 19, 2024
Copy link
Contributor

@RobHanna-NOAA RobHanna-NOAA left a comment

Choose a reason for hiding this comment

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

re-tested for new changes and it is good

@CarsonPruitt-NOAA CarsonPruitt-NOAA merged commit efd0b2a into dev Jul 19, 2024
1 check passed
@CarsonPruitt-NOAA CarsonPruitt-NOAA deleted the dev-gdal-UseExceptions branch July 19, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This would be well suited for a someone as a first contribution Low Priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1pt] UseExceptions() FutureWarning being thrown by GDAL
3 participants