Skip to content

[IDEA] Compositing ir_sanwdich with geo_color #3431

Description

@guidocioni

I always dreamed of being able to combine geo_color with ir_sandwich because the former becomes kind of saturated in areas with many reflective cloud tops (deep convection) while the latter doesn't really capture the contrast between land and stratus clouds. After giving claude some food for thoughts (and my code as example) it was able to create a result that, to my eye, does not look too bad...

Here is an example for some strong thunderstorms that formed some days ago over Senegal.

Original geo_color

Image

Original ir_sanwdich

Image

Merged product

Image

I (we) had to tweak something to get the right overlay effect, but it was more straightforward than I thought

The pseudo code looks something like this

      geo_color_image = get_enhanced_image(fci_scene_r["geo_color"]).data.compute()
      sandwich_image = (
          get_enhanced_image(fci_scene_r["ir_sandwich_with_night_colorized_ir_clouds"])
          .data.compute()
          .transpose("y", "x", "bands")
      )
      bt = fci_scene_r["ir_105"].compute().values  # Kelvin, native resolution/grid
      valid = ~np.isnan(bt)

      # NaN/off-swath BT is forced fully transparent rather than left to propagate
      # into the alpha channel -- that produced a stray blue-ish ring at the mask
      # edge in an earlier version (NaN alpha smeared by interpolation).
      alpha = np.where(
          valid, np.clip((IR_WARM_K - bt) / (IR_WARM_K - IR_COLD_K), 0.0, 1.0), 0.0
      )
      ir_rgba = np.concatenate(
          [sandwich_image.values, np.zeros_like(sandwich_image.values[..., :1])], axis=-1
      )
      ir_rgba[..., 3] = alpha

      geo_color_image.plot.imshow(
          vmin=0, vmax=1, add_colorbar=False, rgb="bands", ax=ax,
          transform=area_def.to_cartopy_crs(), zorder=4, interpolation="spline36",
      )
      ax.imshow(
          ir_rgba,
          transform=area_def.to_cartopy_crs(),
          extent=[x_min, x_max, y_min, y_max],
          origin="upper",
          zorder=6,
          # nearest, not spline36: cubic/spline kernels ring at the sharp alpha edge
          # on a non-monotonic (diverging) colormap like Spectral, producing false
          # hues instead of a smooth fade.
          interpolation="nearest",
      )

I believe this composite could not be added as-is to the YAML, but do you think is of any interest? Or did I duplicate something that already exists? :)

Note: there are still some graphical artifacts at cloud edges due to the combination of both FDHSI and HRFI. Haven't found a solution for that yet.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions