WMO Instruments Part 2.1: Enhancements#2
Conversation
8fab067 to
bddff40
Compare
Coverage Report for CI Build 26277325350Coverage decreased (-0.004%) to 96.39%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions11 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
Co-authored-by: David Hoese <david.hoese@ssec.wisc.edu>
…om/sfinkens/satpy into wmo-instruments-part2-enhancements
|
I first tried to specify single instruments as a list in the YAML, but apparently that doesn't work. For example this YAML would break test_multisensor_choice (wrong enhancement applied). Looks like the order of the elements in the tree is different With strings: With lists: The but the behaviour confused me a little bit. |
|
Ok so you're saying the alphabetical-ness of the sensors/instruments handling in the decision tree isn't working and that that test is failing? |
|
I wonder if this Lines 166 to 167 in 8061698 This, along with your forcing of |
|
Side note: This windows py3.11 environment is consistently hanging on some test. Some test around 93-95% it looks like. |
The test only fails if the YAML contains an instrument list with a single element. Strings work fine.
Thanks for the hint. That, together with a change to the query, made the test pass (mix of list and string would also work) diff --git a/satpy/decision_tree.py b/satpy/decision_tree.py
index c1f5e2516..ed5f84bb5 100644
--- a/satpy/decision_tree.py
+++ b/satpy/decision_tree.py
@@ -163,8 +163,11 @@ class DecisionTree:
for match_level, match_key in enumerate(self._match_keys):
# or None is necessary if they have empty strings
this_attr_val = sect_attrs.get(match_key, self.any_key) or None
- if match_key in self._multival_keys and isinstance(this_attr_val, list):
- this_attr_val = tuple(sorted(this_attr_val))
+ if match_key in self._multival_keys:
+ if isinstance(this_attr_val, list):
+ this_attr_val = tuple(sorted(this_attr_val))
+ elif isinstance(this_attr_val, str):
+ this_attr_val = tuple([this_attr_val])
is_last_key = match_key == self._match_keys[-1]
level_needs_init = this_attr_val not in curr_level
if is_last_key:
@@ -179,7 +182,9 @@ class DecisionTree:
@staticmethod
def _convert_query_val_to_hashable(query_val):
_sorted_query_val = sorted(query_val)
- query_vals = [tuple(_sorted_query_val)] + _sorted_query_val
+ query_vals = [tuple(_sorted_query_val)]
+ query_vals += [tuple([v]) for v in _sorted_query_val]
+ query_vals += _sorted_query_val
query_vals += query_val
return query_vals
diff --git a/satpy/tests/enhancement_tests/test_enhancer.py b/satpy/tests/enhancement_tests/test_enhancer.py
index bcb150405..06e03da02 100644
--- a/satpy/tests/enhancement_tests/test_enhancer.py
+++ b/satpy/tests/enhancement_tests/test_enhancer.py
@@ -144,7 +144,7 @@ class TestComplexSensorEnhancerConfigs(_BaseCustomEnhancementConfigTests):
enhancements:
test1_sensor1_specific:
name: test1
- instruments: test_sensor1
+ instruments: [test_sensor1]
operations:
- name: stretch
method: !!python/name:satpy.enhancements.contrast.stretch
@@ -160,7 +160,7 @@ enhancements:
kwargs: {stretch: crude, min_stretch: 0, max_stretch: 100}
test1_sensor2_specific:
name: test1
- instruments: test_sensor2
+ instruments: [test_sensor2]
operations:
- name: stretch
method: !!python/name:satpy.enhancements.contrast.stretchThis is pretty unknown terrain for me and I don't understand all the implications of this change. Do you think it is reasonable and worth including? (together with updating all the enhancement YAMLs with instrument lists) |
|
I don't think the YAMLs have to be changed beyond the name of that key. I think it makes sense and is convenient for users to be able to list a single string for their sensor ( |
|
I prefer proper grammar 😀 |
| # Full match: All elements in the tuple | ||
| query_vals = [tuple(_sorted_query_val)] | ||
| # Partial match: One element of the tuple, as tuple | ||
| query_vals += [tuple([v]) for v in _sorted_query_val] | ||
| # Partial match: One element of the tuple, as string | ||
| query_vals += _sorted_query_val |
There was a problem hiding this comment.
I don't remember how this worked in the old code so I don't understand how this works now, but if you say it works then 👍
There was a problem hiding this comment.
I've updated the docstring to make it more clear.
djhoese
left a comment
There was a problem hiding this comment.
Just some small comments but I think this is good. So this would be part of Satpy 1.0?
Co-authored-by: David Hoese <david.hoese@ssec.wisc.edu>
…om/sfinkens/satpy into wmo-instruments-part2-enhancements
Yes, but together with the other WMO parts |
|
I've also wrapped the compatibility check with |
|
Oh so this could actually be merged since it has the backwards compatibility and the scissor cut outs for 1.0? I thought this would be a merge after the last pre-1.0 release, but before 1.0. If it works in the pre-1.0 release then that's great. |
|
Yes I'm just updating all the WMO PRs so that they can be included the last pre-1.0 release |
Deprecate
sensorenhancement attribute in favor ofinstruments. To be merged into pytroll#3390Summary
sensor: mysensortoinstruments: [mysensor]in enhancement YAML filessensorandinstruments, with a deprecation warning forsensorBreaking Changes
None
AUTHORS.mdif not there already