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

DAS-2280: Update HyBIG reference images 1-band (colour test) #125

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

Conversation

flamingbear
Copy link
Member

@flamingbear flamingbear commented Dec 19, 2024

When nasa/harmony-browse-image-generator#41 gets merged, you can run these tests.

Description

Updates the reference images for "Test that demonstrates variable selection for custom colour maps"

The changes in DAS-2280 (nasa/harmony-browse-image-generator#41 / part-a) now treat nodata and transparent the same.
The differences in the image are nearly exclusively metadata related.
One differences is that the new image now has a "nodata" value specified in the metadata of 255.
New reference:

Band 1 Block=2013x1 Type=Byte, ColorInterp=Palette
  NoData Value=255
  Color Table (RGB with 256 entries)

Old Reference

Band 1 Block=2013x1 Type=Byte, ColorInterp=Palette
  Color Table (RGB with 256 entries)

This is a function of how writing a PNG with multiple all-transparent
values in the color map. If there is only one rgba of (0,0,0,0) that index is set to the NoData value in the PNG metadata. If
there are > 1 all-transparent values, none are listed in the metadata.

That brings us to the second metadata difference.
Last values of color lookup tabes:
New Reference:

  252: 0,0,0,255
  253: 0,0,0,255
  254: 0,0,0,255
  255: 0,0,0,0

Old Reference:

  252: 0,0,0,255
  253: 0,0,0,255
  254: 0,0,0,0
  255: 0,0,0,0

Before we had a transparent and nodata pixel in values 254 and 255, now we only use the 255 as both.

The image data has changed only in that values of 254 are now 255. You can / will verify this with the instructions below.

Jira Issue ID

DAS-2280

Local Test Steps

Before you start, you need to generate images to compare against the existing reference images. So check out this repository's main and edit the last test's cell as described below:

    temp_dir = Path('./new_results')
    temp_dir.mkdir(parents=True, exist_ok=True)
    with TemporaryDirectory() as FAKEDIR:

Run this notebook against the new changes in HyBIG.

When this last cell runs, it will drop the files into ./new_results and we can compare them with the old reference_data.

Copy this cell below the test that just failed and you should be able to verify that the only change between the reference_data and new data is that values that were 254 are now 255. (Along with the previously described metadata differences.)

# compare the new and old reference images
import numpy as np
import rasterio

filenames = [
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c00.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c01.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c02.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c03.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c04.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c00.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c01.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c02.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c03.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c04.png",
    "PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r02c00.png",
]

for filename in filenames:

    new_ref = f"new_results/{filename}"
    old_ref = f"reference_data/colour_map/{filename}"

    new = rasterio.open(new_ref)
    old = rasterio.open(old_ref)

    new_data = new.read(1)
    old_data = old.read(1)

    # compare old_data is new_data or (old_data is 254 and new_data is 255)
    is_equal = (old_data == new_data) | ((old_data == 254) & (new_data == 255))
    print(f"all match {filename}: {is_equal.all()}")
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c00.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c01.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c02.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c03.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r00c04.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c00.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c01.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c02.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c03.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r01c04.png: True
all match PREFIRE_SAT2_2B-FLX_S07_R00_20210721013413_03040.nc.G00.r02c00.png: True

This should convince you that the change are as expected.

Now do a normal validation by reverting the changes to the ipython notebook, Checking out this branch, and running the regression against your local Harmony-In-A-Box.

PR Acceptance Checklist

  • Acceptance criteria met
  • Tests added/updated (if needed) and passing
  • Documentation updated (if needed)
  • CHANGELOG updated with the changes for this PR

Base automatically changed from mhs/DAS-2276/hybig-4band-regression-update to main December 20, 2024 16:51
@flamingbear flamingbear force-pushed the mhs/DAS-2280/update-reference-images-for-colour-test branch from 177e408 to a5bc9af Compare December 20, 2024 18:20
@flamingbear flamingbear marked this pull request as ready for review December 20, 2024 18:20
@flamingbear flamingbear marked this pull request as draft December 20, 2024 18:26
Copy link
Contributor

@lyonthefrog lyonthefrog left a comment

Choose a reason for hiding this comment

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

Review the small code changes and ran the HyBIG regression tests with the new image both before and after the update reference files, and all the tests passed. The final notebook test failed in main as expected, and passed in this branch with the updated references.

@flamingbear flamingbear marked this pull request as ready for review December 20, 2024 21:11
@flamingbear flamingbear changed the title DAS-2276: Update HyBIG reference images. DAS-2280: Update HyBIG reference images 1-band (colour test) Dec 20, 2024
@flamingbear
Copy link
Member Author

This is ready to merge when SIT has HyBIG v2.2.0. I am going to wait until after the new year before doing that though...

Copy link
Member

@owenlittlejohns owenlittlejohns left a comment

Choose a reason for hiding this comment

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

The reference file updates look good, and make sense given the changes in DAS-2280.

Should this PR also have a bump for the regression test Docker image? Feels like it should, and that it would be a patch version maybe?

@flamingbear
Copy link
Member Author

Should this PR also have a bump for the regression test Docker image? Feels like it should, and that it would be a patch version maybe

It should have a bump in version. As so the type, I was thinking none of semver makes sense with these changes. We're not keeping up with the service version and these are sort of all over the place. I've just adopted incrementing the patch. I can bump it to whatever but I don't think there's a lot of value in trying to make these semver.

Copy link
Member

@owenlittlejohns owenlittlejohns left a comment

Choose a reason for hiding this comment

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

Looks good. Agreed that the semver bump feels a little difficult to quantify, and I'm fine with a minor version for it.

@flamingbear
Copy link
Member Author

Looks good. Agreed that the semver bump feels a little difficult to quantify, and I'm fine with a minor version for it.

I obviously was blind with your comment, I'll put it back to patch like I was doing. I kind of wish we just had increasing digits.

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.

3 participants