-
Notifications
You must be signed in to change notification settings - Fork 298
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
Share FCI L1c metadata between segments #2828
base: main
Are you sure you want to change the base?
Changes from all commits
4d37286
1524ad7
90fd3f8
21a5bcc
37f9305
7c536c2
b6361a1
80c40b4
f46df94
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 |
---|---|---|
|
@@ -158,6 +158,15 @@ | |
"grid_width": 5568}, | ||
} | ||
|
||
NONSHAREABLE_VARIABLE_ENDINGS = [ | ||
"index", | ||
"time", | ||
"measured/effective_radiance", | ||
"measured/y", | ||
"position_row", | ||
"index_map", | ||
"pixel_quality"] | ||
|
||
|
||
def _get_aux_data_name_from_dsname(dsname): | ||
aux_data_name = [key for key in AUX_DATA.keys() if key in dsname] | ||
|
@@ -700,6 +709,31 @@ | |
res = 100 * radiance * np.float32(np.pi) * np.float32(sun_earth_distance) ** np.float32(2) / cesi | ||
return res | ||
|
||
def _collect_listed_variables(self, file_handle, listed_variables, filetype_info): | ||
listed_variables = self._collect_from_inter_segment_cache(listed_variables, filetype_info) | ||
super()._collect_listed_variables(file_handle, listed_variables, filetype_info) | ||
self._store_shared_info(filetype_info) | ||
|
||
def _collect_from_inter_segment_cache(self, listed_variables, filetype_info): | ||
if "shared_info" in filetype_info: | ||
shared_info = filetype_info["shared_info"] | ||
for key in shared_info: | ||
self.file_content[key] = shared_info[key] | ||
try: | ||
listed_variables.remove(key) | ||
except ValueError: | ||
pass | ||
return listed_variables | ||
|
||
def _store_shared_info(self, filetype_info): | ||
if "shared_info" not in filetype_info: | ||
shared_info = {} | ||
for key in self.file_content: | ||
if any(key.endswith(k) for k in NONSHAREABLE_VARIABLE_ENDINGS): | ||
continue | ||
Comment on lines
+732
to
+733
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. By default you are sharing (in case of unknown variable names). Would it be safer to default to not-sharing, i.e. use a whitelist rather than a blacklist? 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. I think your dict of sharing stuff would make this obsolete in any case as it explicitly says what can be shared and how. |
||
shared_info[key] = self.file_content[key] | ||
filetype_info["shared_info"] = shared_info | ||
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. Is 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. We talked about this with @ameraner at PCW and this was already used in somewhere. LI L2, perhaps? It was also the path of least resistance as it was already in place and the same dict is passed between different filehandlers by the YAML reader. If there are other backwards compatible ways to pass the info between the file handlers then let me know. |
||
|
||
|
||
def _ensure_dataarray(arr): | ||
if not isinstance(arr, xr.DataArray): | ||
|
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.
In #2686 I have added this information to the YAML file. Essentially, I have changed
required_variable_names
to be a dict rather than a list. The keys of the dict remain the required variable names, and the values indicate how they can be shared between segments or between repeat cycles:See https://github.com/pytroll/satpy/pull/2686/files#diff-2170f8edf16088150763d5f3a6cbd69d62600d238c0ba80a41afcb4832fb7b5dR23-R84
We should agree on an approach to avoid a duplication of information. One difference is that I need information not only on what can be shared between segments, but also between repeat cycles. By adding information to the YAML file, I don't need to repeat variable names (or parts of variable names) in different places (YAML file + source code).
I think
swath_number
is not shareable between segments.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.
Yup. I kinda made this on the basis "lets see if this makes things faster" so the approach was the simplest I saw. I think yours is more general and I'll update this PR to match yours when yours is ready.
Could be that
swath_number
can't be shared, but apparently sharing it didn't break anything when creating imagery 😅