59. GOES ABI RGB Recipes#

Brian Blaylock
September 26, 2019

For details on the RGB recipies below see the RAMMB CIRA website for GOES-R, including:

  • TrueColor

  • FireTemperature

  • AirMass

  • DayCloudPhase

  • DayConvection

  • DayLandCloudFire

  • WaterVapor

  • DaySnowFog

  • etc.

These recipies are provided by the rgb custom accessor. This accessor is avaialble when you import goes2go.

59.1. Simple RGB Figure#

At the most simple level, here is how to produce an RGB from the GOES ABI data.

from goes2go.data import goes_nearesttime
import matplotlib.pyplot as plt 
from datetime import datetime
from pathlib import Path
import xarray
/Users/phil/mini310/envs/a301/lib/python3.13/site-packages/goes2go/data.py:673: FutureWarning: 'H' is deprecated and will be removed in a future version. Please use 'h' instead of 'H'.
  within=pd.to_timedelta(config["nearesttime"].get("within", "1h")),
/Users/phil/mini310/envs/a301/lib/python3.13/site-packages/goes2go/NEW.py:185: FutureWarning: 'H' is deprecated and will be removed in a future version. Please use 'h' instead of 'H'.
  within=pd.to_timedelta(config["nearesttime"].get("within", "1h")),
# Get an ABI Dataset
save_dir = Path.home() / "repos/a301/satdata/goes" 
writeit = False
if writeit:
    g = goes_nearesttime(
        datetime(2020, 6, 25, 18), satellite="goes16",product="ABI-L2-MCMIP", domain='C', 
          return_as="xarray", save_dir = save_dir, download = True, overwrite = False
    )
    the_path = g.path[0]
else:
    the_path = ("noaa-goes16/ABI-L2-MCMIPC/2020/177/18/"
                "OR_ABI-L2-MCMIPC-M6_G16_s20201771801172_e20201771803551_c20201771804104.nc")
    full_path = save_dir / the_path
    g = xarray.open_dataset(full_path,mode = 'r',mask_and_scale = True)
# Create RGB and plot
image = g.rgb.TrueColor()
image.plot.imshow();
../../_images/fcc3aef061c7a37ae2365741997932bb39ed01ad505787ae7bcce26d6fa691b9.png

59.2. Cartopy RGB Figure#

The RGB can easily be added to a Cartopy axis

g.rgb.imshow_kwargs
{'extent': [np.float64(-3626269.332309611),
  np.float64(1381769.9431296065),
  np.float64(1584175.830644913),
  np.float64(4588197.756226748)],
 'transform': None,
 'origin': 'upper',
 'interpolation': 'none'}
ax = plt.subplot(projection=g.rgb.crs)
ax.imshow(g.rgb.TrueColor(), **g.rgb.imshow_kwargs)
ax.coastlines()
ax.get_extent()
(-3626269.332309611, 1381769.9431296065, 1584175.830644913, 4588197.756226748)
../../_images/21bc3a7df3c5e89e935df74826c7bb3c55f347b339806f591ce22434b7ece177.png

59.2.1. keywords for cartopy plotting#

g.rgb.imshow_kwargs
{'extent': [np.float64(-3626269.332309611),
  np.float64(1381769.9431296065),
  np.float64(1584175.830644913),
  np.float64(4588197.756226748)],
 'transform': None,
 'origin': 'upper',
 'interpolation': 'none'}

59.3. All available RGB recipes#

from goes2go.data import goes_nearesttime
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
writeit = False
if writeit:
    G16 = goes_nearesttime('2024-06-25 18',satellite=16,save_dir=save_dir)
    print(G16.path[0])
else:
    the_path = ("noaa-goes16/ABI-L2-MCMIPC/2024/177/18"
                "/OR_ABI-L2-MCMIPC-M6_G16_s20241771801172_e20241771803557_c20241771804062.nc")
    full_path = save_dir / the_path
    G16 = xarray.open_dataset(full_path,mode = 'r',mask_and_scale = True)
if writeit:
    G18 = goes_nearesttime('2024-06-25 18',satellite=18,save_dir=save_dir)
    print(G18.path[0])
else:
    the_path = ("noaa-goes18/ABI-L2-MCMIPC/2024/177/18/OR_ABI-L2-MCMIPC-M6_G18_s20241771801172_"
                "e20241771803545_c20241771804067.nc")
    full_path = save_dir / the_path
    G18 = xarray.open_dataset(full_path,mode = 'r',mask_and_scale = True)
rgb_products = [i for i in dir(G16.rgb) if i[0].isupper()]

for product in rgb_products:

    fig = plt.figure(figsize=(15, 12))
    ax18 = fig.add_subplot(1, 2, 1, projection=G18.rgb.crs)
    ax16 = fig.add_subplot(1, 2, 2, projection=G16.rgb.crs)

    for ax, G in zip([ax18, ax16], [G18, G16]):
        RGB = getattr(G.rgb, product)()

        #common_features('50m', STATES=True, ax=ax)
        ax.imshow(RGB, **G.rgb.imshow_kwargs)
        ax.set_title(f"{G.orbital_slot} {product}", loc='left', fontweight='bold')
        ax.set_title(f"{G.t.dt.strftime('%H:%M UTC %d-%b-%Y').item()}", loc="right")
    plt.subplots_adjust(wspace=0.01)
    #plt.savefig(f'../docs/_static/{product}', bbox_inches='tight')
/Users/phil/mini310/envs/a301/lib/python3.13/site-packages/goes2go/accessors.py:1251: UserWarning: THE `NormalizedBurnRatio` FUNCTION IS NOT FULLY DEVELOPED. NEED MORE INFO.
  warnings.warn(
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [-0.757256..1.0].
/Users/phil/mini310/envs/a301/lib/python3.13/site-packages/goes2go/accessors.py:1251: UserWarning: THE `NormalizedBurnRatio` FUNCTION IS NOT FULLY DEVELOPED. NEED MORE INFO.
  warnings.warn(
Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). Got range [-0.49068323..1.0].
/var/folders/h3/5svt7fds58v0x7kkc54kl3640000gn/T/ipykernel_60055/210842163.py:5: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  fig = plt.figure(figsize=(15, 12))
../../_images/4221b82c7a9585163def42593bf86052c5bb705d0bd5194d9313b313fcf5f889.png ../../_images/aa57d1ad31345edaf265b6d6770bf222f652a75debca21ef1e4e565dc4582dc1.png ../../_images/518f0fb923f8a92ca20c0812b5d90d7e98bb3bed555d5e0fb7d37f75a66a9abb.png ../../_images/0085955d4ad1a6da8bb460689669c38f4be1f7f66d51028abfde9cbc0d19aa6a.png ../../_images/753121f8898560462bf1c11ecafe20eac84576d9e0f019a1f34c0f9f2cc00500.png ../../_images/acdf1aff476660115fdb0773c58c635a72396f5d73342af7a29aa80293b4c638.png ../../_images/7bea5fe650b221ee664e1fa33227d217ae19549bcb3921d9a8dda0799d1a5575.png ../../_images/5205b54c48957cb1d0cd95a23792d074d0adaec4c67121c42a01e7172c361710.png ../../_images/db89f0e744442d8ec3e6ea1c9ebe20629489dfeee86e2610ba55500740ab52a2.png ../../_images/743fdf02b54b5e9f50d2ef5fc49ac3b0807a830e1deb232d6ca3ff46478b251c.png ../../_images/b22c06f88da6142721a6ad59a3dd2efc3f14ee00b17ea6c5f11617d6888c69b3.png ../../_images/5284566f10eb1742f9f851c2339e43a2539055fabfc3f730ac782917ce9b078e.png ../../_images/766e4faea282793779b9cf26bc44a22a79825c22543cd2e586865b09f438867d.png ../../_images/23bce7841a29f1079b85ad213e55cba4cfa4d7307bdc8fceb039bdc8d26a7315.png ../../_images/90804c76d661801d4bb6b77949ad00c5b13244f67e7c8bc6712270674a2278f7.png ../../_images/c4d31e0a7ffdf909d900a75cfe6acf84af3fa4c2304da14e9eb34dd535a7d63e.png ../../_images/68ff3244a8d87dbf60df08e2a280180a833571f2b976185caf9b5eb83dbc110f.png ../../_images/49febdaf295390959c25a733ca478dab283178c302ba66d729589f4050b736c8.png ../../_images/1e784d57edb9b5d70a6362bc7ad17145ca656bc0e7b3914302dbe6119a6ea58f.png ../../_images/6f9f92f405e069ba90f68314115bb8c743a9fe5130c33b18d582b508970a6305.png ../../_images/8cfab932b386ea10659947672c3ee9879ea030dca86c6edb843d1a5ef9449b87.png ../../_images/b361e36d09cb820d281827caf5fc1c361abc7b006be5144f097d19bf57390a27.png ../../_images/f1a90bcbdb44997d1c877ae200e74b4ade231855cc38e482240a82640343e43a.png