-
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
Fixes modifier attribute getting replaced instead of merged with existing one when applying modifications #2333
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,11 @@ | |
'isneginf', 'isposinf'] | ||
|
||
|
||
def merge_tuples(*t): | ||
"""Merge tuples and tuples of tuples into one tuple.""" | ||
return tuple(j for i in (t) for j in (i if isinstance(i, tuple) else (i,))) | ||
|
||
|
||
class IncompatibleAreas(Exception): | ||
"""Error raised upon compositing things of different shapes.""" | ||
|
||
|
@@ -143,13 +148,15 @@ def apply_modifier_info(self, origin, destination): | |
dataset_keys = ['name', 'modifiers'] | ||
for k in dataset_keys: | ||
if k == 'modifiers' and k in self.attrs: | ||
d[k] = self.attrs[k] | ||
d[k] = merge_tuples(d[k], self.attrs[k]) | ||
elif d.get(k) is None: | ||
if self.attrs.get(k) is not None: | ||
d[k] = self.attrs[k] | ||
elif o.get(k) is not None: | ||
d[k] = o[k] | ||
|
||
d["_satpy_id"] = d["_satpy_id"]._replace(**d) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is extremely scary to me. I think the need for adding this here is because the way you are using modifiers does not have the proper information provided. If I remember correctly, if the traditional If this new line of code can't be made unnecessary by providing newer/better information to the Modifier object (either in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You @djhoese obviously have a lot more insight in the whole I might be wrong but from what I grasp I would say that updating the attributes (except for the So I think this needs more thought. Should I mark this as work in progress? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marking as WIP sounds good. I think I agree that the ID stuff shouldn't happen in the compositor classes, but it may need to be due to Satpy's current design and since we allow use of compositors as class instances rather than only through the Scene. |
||
|
||
def match_data_arrays(self, data_arrays): | ||
"""Match data arrays so that they can be used together in a composite. | ||
|
||
|
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.
Could you please use longer names for
i
,j
, andt
? This is very hard to read. Why the extra parentheses around(t)
? When isi
not a tuple?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.
You are right. This is quite bad :-D. I will make it more readable.