pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.06k stars 293 forks source link

piecewise_linear_stretch didn't work properly on GK-2A AMI data #1779

Closed yukaribbba closed 3 years ago

yukaribbba commented 3 years ago

Describe the bug image That's the result. But it's no problem for S3 OLCI. And nothing wrong with CIRA stretch.

To Reproduce enhancement YAML:

  true_color_crefl2:
    name: true_color_crefl2
    standard_name: true_color_crefl2
    operations:
      - name: reflectance_range
        method: !!python/name:satpy.enhancements.stretch
        kwargs: {stretch: 'crude', min_stretch: 0., max_stretch: 100.}
      - name: linear interpolation
        method: !!python/name:satpy.enhancements.piecewise_linear_stretch
        kwargs:
        # Polar2Grid's "Preferred" scaling
         xp: [0., 25., 55., 100., 255.]
         fp: [0., 90., 140., 175., 255.]
         reference_scale_factor: 255

composite YAML:

  true_color2:
    compositor: !!python/name:satpy.composites.GenericCompositor
    prerequisites:
      - name: VI006
        modifiers: [sunz_corrected, rayleigh_corrected]
      - name: green
      - name: VI004
        modifiers: [sunz_corrected, rayleigh_corrected]
    standard_name: true_color_crefl2 
from satpy import Scene, find_files_and_readers
from satpy.dataset import DataQuery
import satpy

satpy.config.set(config_path=['D:\\satpy_config'])
files = find_files_and_readers(base_dir="C:\\Users\\45107\\Downloads\\Sat\\GK2A",
                               reader='ami_l1b')
scn = Scene(filenames=files)
composite = 'true_color2'
scn.load([composite])
new_scn = scn.resample(scn.max_area(), resampler='native')
new_scn.save_dataset(composite, filename='{name}_{start_time:%Y%m%d_%H%M%S}.tif', writer='geotiff', base_dir="C:\\Users\\45107\\Downloads\\Sat\\GK2A", num_threads=8, compress=None)

Environment Info:

djhoese commented 3 years ago

The name of your composite is true_color2, the standard_name is true_color_crefl2. Your enhancement is configured to only be applied to something with a name of true_color_crefl2 (doesn't match your composite) and a standard_name of true_color_crefl2. Your enhancement is not being applied when you think it is. If you turn on debug log message you should see some output about what enhancements are being applied.

The solution is to either change your enhancement where it says name: true_color_crefl2 to name: true_color2 or you could probably just remove that name: true_color_crefl2 line and it should still work.

yukaribbba commented 3 years ago

@djhoese OK it's solved. I got stuck here because I've benn confused about thoses 'names' in the enhancement YAML. Now I'm getting clear. Thank you!