Skip to content

Get the bounding box from the HDF EOS level-1 files and pass it to the array attributes#3399

Draft
adybbroe wants to merge 2 commits into
pytroll:mainfrom
adybbroe:modis_get_bounding_box_data_from_hdfeos_file
Draft

Get the bounding box from the HDF EOS level-1 files and pass it to the array attributes#3399
adybbroe wants to merge 2 commits into
pytroll:mainfrom
adybbroe:modis_get_bounding_box_data_from_hdfeos_file

Conversation

@adybbroe
Copy link
Copy Markdown
Contributor

@adybbroe adybbroe commented May 21, 2026

Get the gringpoint (bounding box) data from the HDF EOS level-1 files, and pass it to the projectabe channel data array object.

It can be debated if this PR really closes the issue referenced above. It will then also require Pyresample being enhanced, as suggested in a recent PR there:
pytroll/pyresample#724

If solving the issue without a Pyresample upgrade one should clip the NaN arrays upon reading as discussed in the issue.

There is at least one issue I would like to hear your opinion on: When loading the MODIS data the HDFEOSBandReader init is invoked three times, ones for each radiance file (1km, half km and quarter km), in my example case these are:

MYD021km_A26131_134600_2026131140033.hdf
MYD02Hkm_A26131_134600_2026131140033.hdf
MYD02Qkm_A26131_134600_2026131140033.hdf

So, the bounding box is read and set three times. Bounding box is exactly the same in all three as far as I can see...

…ss it to the projectabe channel data array object

Signed-off-by: Adam.Dybbroe <a000680@c22526.ad.smhi.se>
@adybbroe adybbroe added enhancement code enhancements, features, improvements help wanted PCW Pytroll Contributors' Week labels May 21, 2026
array = self._mask_invalid(array, valid_min, valid_max)
array = self._mask_uncertain_pixels(array, uncertainty, band_index)
# array = self._mask_rows_all_nan(array)
info["boundingbox"] = self._boundingbox
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"bbox"? And I wonder if this should go in the .attrs["orbital_parameters"]?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Eh I guess it isn't "orbital" though. Nevermind. Ohand I just realized this is a draft. Sorry for early review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you prefer bbox over boundingbox? Or should it be bounding_box?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

...and yes "orbital_parameters" sounds reasonable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I prefer bbox but bounding_box is maybe OK too. I think I take back what I said about orbital_parameters. I'm not sure it should go there. I think long term it will go in the .attrs of the future SwathDefinition, but the .attrs of the DataArray is good enough for now. But I also still think the min/max of all lon/lats is the way to fix this in pyresample. This bbox solution is a larger undertaking that needs discussion.

Signed-off-by: Adam.Dybbroe <a000680@c22526.ad.smhi.se>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.30%. Comparing base (97d6314) to head (a3e833b).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
satpy/readers/modis_l1b.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3399      +/-   ##
==========================================
- Coverage   96.32%   96.30%   -0.02%     
==========================================
  Files         466      466              
  Lines       59090    59096       +6     
==========================================
- Hits        56917    56912       -5     
- Misses       2173     2184      +11     
Flag Coverage Δ
behaviourtests 3.59% <0.00%> (-0.01%) ⬇️
unittests 96.39% <77.77%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement code enhancements, features, improvements help wanted PCW Pytroll Contributors' Week

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Fails resampling MODIS level-1 using an omerc projection definition

2 participants