-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump to 2.12.1 * update numpy constraint * pin min version of xarray that supports NumPy 2.0. Co-authored-by: Tom Vo <[email protected]> * Apply suggestions from code review * Apply suggestions from code review * git add image_checker.py --------- Co-authored-by: Tom Vo <[email protected]>
- Loading branch information
1 parent
3f5b036
commit ca41b0e
Showing
7 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
from PIL import Image, ImageChops | ||
|
||
def images_are_identical(img1_path, img2_path): | ||
# Open both images | ||
with Image.open(img1_path) as img1, Image.open(img2_path) as img2: | ||
# Check if dimensions are the same | ||
if img1.size != img2.size: | ||
return False | ||
|
||
# Check if pixel values are the same | ||
diff = ImageChops.difference(img1, img2) | ||
return not diff.getbbox() # getbbox() returns None if images are identical | ||
|
||
def compare_png_images(dir1, dir2): | ||
# List to hold mismatched files, if any | ||
mismatched_files = [] | ||
|
||
# Walk through both directories simultaneously | ||
for root, _, files in os.walk(dir1): | ||
for file in files: | ||
if file.endswith('.png'): | ||
# Full path for file in dir1 | ||
path1 = os.path.join(root, file) | ||
|
||
# Construct corresponding path for file in dir2 | ||
relative_path = os.path.relpath(path1, dir1) | ||
path2 = os.path.join(dir2, relative_path) | ||
|
||
# Check if the file exists in the second directory | ||
if not os.path.exists(path2): | ||
print(f"File missing in second directory: {relative_path}") | ||
mismatched_files.append(relative_path) | ||
continue | ||
|
||
# Compare images | ||
if not images_are_identical(path1, path2): | ||
print(f"Images do not match: {relative_path}") | ||
mismatched_files.append(relative_path) | ||
|
||
# Final output | ||
if not mismatched_files: | ||
print("All .png images are identical.") | ||
else: | ||
print("Some images do not match or are missing in the second directory.") | ||
|
||
# Example usage | ||
compare_png_images('/global/cfs/cdirs/e3sm/www/chengzhu/complete_run_11112024/e3sm_diags_extended', '/global/cfs/cdirs/e3sm/www/chengzhu/tutorial2024/e3sm_diags_extended') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ def get_all_files_in_dir(directory, pattern): | |
"Programming Language :: Python :: 3.10", | ||
], | ||
name="e3sm_diags", | ||
version="2.12.0", | ||
version="2.12.1", | ||
author="Chengzhu (Jill) Zhang, Tom Vo, Ryan Forsyth, Chris Golaz and Zeshawn Shaheen", | ||
author_email="[email protected]", | ||
description="E3SM Diagnostics", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters