Skip to content
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

wrong start_time with BackgroundCompositor #2630

Closed
gerritholl opened this issue Nov 8, 2023 · 4 comments · Fixed by #2737
Closed

wrong start_time with BackgroundCompositor #2630

gerritholl opened this issue Nov 8, 2023 · 4 comments · Fixed by #2737

Comments

@gerritholl
Copy link
Collaborator

Describe the bug

Loading a composite that uses the BackgroundCompositor, such as natural_color_with_night_ir, leads to a bad start_time attribute in the resulting metadata.

To Reproduce

import os
from satpy import Scene
from glob import glob
from pathlib import Path

fn = "/media/nas/x21308/scratch/data/MSG4-SEVI-MSG15-0100-NA-20220216002743.011000000Z-NA.nat"

sc = Scene(filenames=[fn], reader=["seviri_l1b_native"])
sc.load(["natural_color", "natural_color_with_night_ir"])
ls = sc.resample("eurol")
print(ls["natural_color"].attrs["start_time"])
print(ls["natural_color_with_night_ir"].attrs["start_time"])

Expected behavior

2022-02-16 00:15:00
2022-02-16 00:15:00

Actual results

2022-02-16 00:15:00
2022-07-23 15:40:51.982830

Environment Info:

  • Satpy Version: main

Additional context

This means that {start_time} when passed to save_datasets is also wrong.

@gerritholl
Copy link
Collaborator Author

Related: #2447 #2446 #2427 #1174

@djhoese
Copy link
Member

djhoese commented Nov 8, 2023

Any fixes for this will require some user testing most likely as a None start_time (or non-existent?) would work fine for all compositor related stuff but then fail in the writers or something similar. In some cases we may be OK with that (saving a file to a filename scheme that includes {start_time:%Y%m%d_%H%M%S} when none is available), but others it may not be expected.

@gerritholl
Copy link
Collaborator Author

The problem would also be fixed if combine_metadata defaulted to .min() rather than .mean() when combining different start times, although only because the fictional start_time in the BackgroundCompositor is set to utcnow(), which should be always newer than any other dataset.

@yukaribbba
Copy link
Contributor

I did a little trick to get off this annoying issue.

scn.load(['night_ir_alpha_with_background'])

# this will actually load 'night_ir_alpha' which is the foreground of this composite
scn.load([scn['night_ir_alpha_with_background'].attrs['prerequisites'][0]['name']])

# set the start_time of 'night_ir_alpha_with_background' to the start_time of 'night_ir_alpha'
scn['night_ir_alpha_with_background'].attrs['start_time'] = scn[scn['night_ir_alpha_with_background'].attrs['prerequisites'][0]['name']].attrs['start_time']

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

Successfully merging a pull request may close this issue.

3 participants