-
Notifications
You must be signed in to change notification settings - Fork 303
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
Reduce Dask computations in DayNightCompositor
#2617
Conversation
The tests fail (at least) locally, even though I get identical results with real composites with the three composite types we have: natural_color_day_only:
compositor: !!python/name:satpy.composites.DayNightCompositor
standard_name: natural_color_day_only
day_night: day_only
include_alpha: true
lim_low: 87.0
lim_high: 93.0
prerequisites:
- name: natural_color
night_microphysical_night_only:
compositor: !!python/name:satpy.composites.DayNightCompositor
standard_name: night_microphysical_night_only
day_night: night_only
include_alpha: True
lim_low: 87.0
lim_high: 87.0
prerequisites:
- name: night_microphysical
vis06_with_ir108:
compositor: !!python/name:satpy.composites.DayNightCompositor
standard_name: vis06_with_ir108
lim_low: 85.0
lim_high: 88.0
prerequisites:
- vis06
- ir108 My test script (adapted from the original by @gerritholl): #!/usr/bin/env python
import dask.config
from satpy.tests.utils import CustomScheduler
from satpy import Scene
from glob import glob
seviri_files = glob("/home/lahtinep/data/satellite/geo/0deg/*202303080900*")
sc = Scene(filenames={"seviri_l1b_hrit": seviri_files})
with dask.config.set(scheduler=CustomScheduler(max_computes=1)):
sc.load(["natural_color_day_only", "night_microphysical_night_only", "vis06_with_ir108"])
ls = sc.resample("eurol")
ls.save_datasets(base_dir="/tmp") |
Three of the five failing tests are with
|
There was a simple logic error when I converted the calls, still trying to figure out the |
I'm a bit lost with the last failing test I've now added the context manager to make sure only one computation is triggered. |
I'm a little concerned we have some magic conversion of DataArray to dask and/or dask to DataArray and/or DataArray to numpy and it was just getting hidden before and now is causing an error. My other worry about be the compositor overwriting |
I don't see any places in the compositor where The failure is in the only test where SZA data are not provided and both day and night data are used. This works with real data (I'm testing with SEVIRI HRIT), so I'm I guess the fake data in the test class is somehow wrong. |
Ok, my real data test was using a composite where both day and night parts were single channels. With RGB sub-composites I get
The DataArray Switching the mock data in the test to 1D makes the failing test pass. |
Found something that works, not entirely sure why: use |
Codecov Report
@@ Coverage Diff @@
## main #2617 +/- ##
=======================================
Coverage 95.18% 95.18%
=======================================
Files 354 354
Lines 51256 51270 +14
=======================================
+ Hits 48789 48803 +14
Misses 2467 2467
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Pull Request Test Coverage Report for Build 6657105421
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This might be a case where type annotations would make it more clear what type of objects are being passed where and if we can expect them to work. I'll try to review this in detail this morning and merge if it all looks good. Thanks for tackling this @pnuu! |
Ok I did some debugging into this. What happens is we call this method:
The |
And add a lot more type annotations
# Conflicts: # satpy/composites/__init__.py # satpy/tests/test_composites.py
@pnuu I ended up making more changes than I anticipated after adding and fixing some type annotations. Please review and merge if you're OK with everything. |
Thank you for explaining what really was happening! Also thanks for the type annotations, some day I need to start looking at them my self... |
This PR gets rid of unnecessary Dask computations in
DayNightCompositor
. This is enforced with a custom scheduler for the compositor tests.AUTHORS.md
if not there already