1

I want blend multiple satellite images. but an error occured. I followed the example on the satpy document.

here is code and netcdf file is here : https://drive.google.com/drive/folders/1zp6EBVfjuh41LDRRZo4PJoeGGGn13AKy?usp=sharing

from glob import glob
from satpy import Scene, MultiScene, DataQuery
from satpy.utils import debug_on
debug_on()


areaid = 'worldeqc3km70'

eumetsat = glob('E:/Global/combine_test/MSG4-SEVI-MSG15-0100-NA-20210801000010.306000000Z-20210801001259-4774254.nat')
goes17 = glob('E:/Global/combine_test/OR_ABI-L1b-RadF-M6C13_G17_s20212130000319_e20212130009396_c20212130009445.nc')
gk2a = glob('E:/Global/combine_test/gk2a_ami_le1b_ir105_fd020ge_202108010000.nc')
goes17_scene = Scene(reader="abi_l1b", filenames=goes17)
eumetsat_scene =  Scene(reader="seviri_l1b_native", filenames=eumetsat)
gk2a_scene = Scene(reader="ami_l1b", filenames=gk2a)

goes17_scene.load(["C13"])
eumetsat_scene.load(['IR_108'])
gk2a_scene.load(["IR105"])

mscn = MultiScene([goes17_scene, eumetsat_scene, gk2a_scene])

#groups = {DataQuery(name='IR_group', wavelength=(9.8, 10.8, 11.8)): ['C13', 'IR105', 'IR_108']}
groups = {DataQuery(name="IR_group", wavelength=(10, 11, 12)): ['C13', 'IR_108', 'IR105']}

mscn.group(groups)
print(mscn.loaded_dataset_ids)



resampled = mscn.resample(areaid, reduce_data=False)
blended = resampled.blend()

blended.save_datasets(filename='./test_{area}.png'.format(area=areaid))

Error message: RuntimeError: None of the requested datasets have been generated or could not be loaded. Requested composite inputs may need to have matching dimensions (eg. through resampling).

singsung
  • 27
  • 3
  • You may be running into a bug that was recently discovered and has not been fixed yet: https://github.com/pytroll/satpy/issues/2089 A simple test (maybe) might be to generate a composite instead of loading the regular bands. My guess is that most composites won't trigger this bug. Don't feel like you need to try this, but it might help the debug effort. Note this mailing list post where I give a workaround by doing the blending in your own custom function: https://groups.google.com/g/pytroll/c/XVTTdXFDewk – djhoese Apr 21 '22 at 21:26
  • Let me know if the solution in that mailing list post works for you and I can turn my comment into an answer that you can accept on here. – djhoese Apr 21 '22 at 21:26
  • 1
    Based on your mailing list, I made nice blended satellite image. Thank you!! – singsung Apr 22 '22 at 00:37

1 Answers1

0

As mentioned in the comments this is a known bug that will hopefully be fixed in the next couple weeks. Follow issue 2089 for more information.

The short-term workaround is to make your own "blend" method that handles things the way you expect:

from satpy.multiscene import stack

def my_blend(mscn, common_datasets, blend_function=stack):
    new_scn = Scene()
    for ds_id in common_datasets:
        datasets = [scn[ds_id] for scn in mscn.scenes if ds_id in scn]
        new_scn[ds_id] = blend_function(datasets)

    return new_scn

blended = my_blend(resampled, ["ir_group"]) 
djhoese
  • 3,567
  • 1
  • 27
  • 45