Python Script Examples to Generate GOES-16 / 17 RGB’s: Part II

GOES-R-RGB-Tutorial-2.png

This is the second part of this series. Please find the first part at the following link:

Please find below other Python example scripts to generate GOES-16 / 17 RGB’s:

RGB_Natural_True_Colors_g16

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Natural True Color RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
####################################################################################################### 

# Python Script: Natural True Color RGB
# Quick Guide: http://cimss.ssec.wisc.edu/goes/OCLOFactSheetPDFs/ABIQuickGuide_CIMSSRGB_v2.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C02_G16_s20191841700283_e20191841709591_c20191841710072-114300_0.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C03_G16_s20191841700283_e20191841709591_c20191841710072.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C01_G16_s20191841700283_e20191841709591_c20191841710066.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1
G = (0.45 * data1) + (0.1 * data2) + (0.45 * data3)
B = data3

# Minimuns and Maximuns
Rmin = 0
Rmax = 1

Gmin = 0
Gmax = 1

Bmin = 0
Bmax = 1

R[RRmax] = Rmax

G[GGmax] = Gmax

B[BBmax] = Bmax

# Choose the gamma
gamma = 2

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma)

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.3,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Natural_True_Colors.png', dpi=DPI, pad_inches=0)
RGB_Day_Snow_Fog_g16.jpg

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Day Snow Fog RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#######################################################################################################

# Python Script: Day Snow Fog RGB
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/QuickGuide_DaySnowFog.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C07_G16_s20191841700283_e20191841710002_c20191841710072.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
#data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C13_G16_s20191841700283_e20191841710002_c20191841710081.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()
# Convert to Celsius
#data2 = data2 - 273.15

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C03_G16_s20191841700283_e20191841709591_c20191841710072.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()

# File to read
image4 = "OR_ABI-L2-CMIPF-M6C05_G16_s20191841700283_e20191841709591_c20191841710071.nc"
# Read the file using the NetCDF library
file4 = Dataset(image4)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image4, extent, resolution)
# Read the data as an array
data4 = grid.ReadAsArray()

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# Calculate the solar zenith angle
from pyorbital import astronomy
from datetime import datetime
utc_time = datetime(2019, 7, 3, 17, 00)

lat = np.linspace(extent[3], extent[1], data1.shape[0])
lon = np.linspace(extent[0], extent[2], data1.shape[1])
zenith = np.zeros((data1.shape[0], data1.shape[1]))

for x in range(len(lat)):
for y in range(len(lon)):
zenith[x,y] = astronomy.sun_zenith_angle(utc_time, lon[y], lat[x])
#zenith[zenith > 90] = np.nan

print("Solar Zenith Angle calculus finished")

# Calculate the solar component (band 3.7 um)
from pyspectral.near_infrared_reflectance import Calculator
refl39 = Calculator('GOES-16', 'abi', 'ch7')
data1b = refl39.reflectance_from_tbs(zenith, data1, data2)
print("Solar Component calculus finished")

# RGB Components
R = data3
G = data4
B = data1b

# Minimuns and Maximuns

Rmin = 0
Rmax = 1

Gmin = 0
Gmax = 0.7

Bmin = 0
Bmax = 0.3

R[RRmax] = Rmax

G[GGmax] = Gmax

B[BBmax] = Bmax

# Choose the gamma
gamma_R = 1.7
gamma_G = 1.7
gamma_B = 1.7

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B)

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================
# Create the basemap bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010', 'estados2010', linewidth=0.3, color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.3, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.3, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.4, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.4, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Day_Snow_Fog.png', dpi=DPI, pad_inches=0)
RGB_Differential_Water_Vapor_g16

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Differential Water Vapor RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#######################################################################################################

# Python Script: Differential Water Vapor RGB
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/QuickGuide_GOESR_DifferentialWaterVaporRGB_final.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C10_G16_s20191841700283_e20191841710002_c20191841710078.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C08_G16_s20191841700283_e20191841709591_c20191841710070.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()
# Convert to Celsius
data2 = data2 - 273.15

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1 - data2
G = data1
B = data2

# Minimuns and Maximuns
Rmin = 30
Rmax = -3

Gmin = 5
Gmax = -60

Bmin = -29.25
Bmax = -64.65

R[RRmin] = Rmin

G[GGmin] = Gmin

B[BBmin] = Bmin

# Choose the gamma
gamma_R = 3.5
gamma_G = 2.5
gamma_B = 2.5

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B) 

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.6,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Differential_Water_Vapor.png', dpi=DPI, pad_inches=0)
RGB_Dust_g16.jpg

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Dust RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#######################################################################################################

# Python Script: Dust RGB
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/Dust_RGB_Quick_Guide.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C15_G16_s20191841700283_e20191841709596_c20191841710080.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C13_G16_s20191841700283_e20191841710002_c20191841710081.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()
# Convert to Celsius
data2 = data2 - 273.15

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C14_G16_s20191841700283_e20191841709591_c20191841710083.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()
# Convert to Celsius
data3 = data3 - 273.15

# File to read
image4 = "OR_ABI-L2-CMIPF-M6C11_G16_s20191841700283_e20191841709591_c20191841710080.nc"
# Read the file using the NetCDF library
file4 = Dataset(image4)
# Resolução Desejada
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image4, extent, resolution)
# Read the data as an array
data4 = grid.ReadAsArray()
# Convert to Celsius
data4 = data4 - 273.15

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1 - data2
G = data3 - data4
B = data2

# Minimuns and Maximuns
Rmin = -6.7
Rmax = 2.6

Gmin = -0.5
Gmax = 20

Bmin = -11.95
Bmax = 15.55

R[RRmax] = Rmax

G[GGmax] = Gmax

B[BBmax] = Bmax

# Choose the gamma
gamma_R = 1
gamma_G = 2.5
gamma_B = 1

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B)

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.6,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Dust.png', dpi=DPI, pad_inches=0)
RGB_Fire_Temperature_g16.jpg

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Fire Temperature RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#######################################################################################################

# Python Script: Fire Temperature RGB
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/Fire_Temperature_RGB.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C07_G16_s20191841700283_e20191841710002_c20191841710072.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C06_G16_s20191841700283_e20191841709596_c20191841710062.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C05_G16_s20191841700283_e20191841709591_c20191841710071.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-55, -26, -43, -19]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the reflectances
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()

# Calculates the solar zenith angle
from pyorbital import astronomy
from datetime import datetime

lat = np.linspace(extent[3], extent[1], data1.shape[0])
lon = np.linspace(extent[0], extent[2], data1.shape[1])

xx,yy = np.meshgrid(lon,lat)
lats = xx.reshape(data1.shape[0], data1.shape[1])
lons = yy.reshape(data1.shape[0], data1.shape[1])

# Get the year month day hour and minute to apply the zenith correction
utc_time = datetime(2019, 7, 3, 17, 00)
sun_zenith = np.zeros((data1.shape[0], data1.shape[1]))
sun_zenith = astronomy.sun_zenith_angle(utc_time, lats, lons)

# Apply the sun zenith correction
data2 = (data2)/(np.cos(np.deg2rad(sun_zenith)))
data3 = (data3)/(np.cos(np.deg2rad(sun_zenith)))

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1
G = data2
B = data3

# Minimuns and Maximuns
Rmin = 0
Rmax = 60

Gmin = 0
Gmax = 1

Bmin = 0
Bmax = 0.75

R[RRmax] = Rmax

G[GGmax] = Gmax

B[BBmax] = Bmax

# Choose the gamma
gamma_R = 0.4
gamma_G = 1
gamma_B = 1

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B) 

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.6,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Fire_Temperature.png', dpi=DPI, pad_inches=0)
RGB_Simple_Water_Vapor_g16

Hurricane Barbara – GOES-16 – July 3rd 2019, 17:00 UTC – Simple Water RGB created with Python

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
####################################################################################################### 

# Python Script: Simple Water Vapor RGB
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/Simple_Water_Vapor_RGB.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C13_G16_s20191841700283_e20191841710002_c20191841710081.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C08_G16_s20191841700283_e20191841709591_c20191841710070.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()
# Convert to Celsius
data2 = data2 - 273.15

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C10_G16_s20191841700283_e20191841710002_c20191841710078.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
#extent = [-156.29, -81.32, 6.29, 81.32]
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()
# Convert to Celsius
data3 = data3 - 273.15

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1
G = data2
B = data3

# Minimuns and Maximuns
Rmin = 5.81
Rmax = -70.86

Gmin = -30.48
Gmax = -58.49

Bmin = -12.12
Bmax = -28.03

R[RRmin] = Rmin

G[GGmin] = Gmin

B[BBmin] = Bmin

# Choose the gamma
gamma_R = 1
gamma_G = 1
gamma_B = 1

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B) 

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326)

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.6,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Simple_Water_Vapor.png', dpi=DPI, pad_inches=0)

RGB_Night_Microphysics_Summer_g16.jpg

#######################################################################################################
# LICENSE
# Copyright (C) 2019 - INPE - NATIONAL INSTITUTE FOR SPACE RESEARCH
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
#######################################################################################################

# Python Script: Night Microphysics
# Quick Guide: http://rammb.cira.colostate.edu/training/visit/quick_guides/QuickGuide_GOESR_NtMicroRGB_final.pdf

# Required modules
import matplotlib.pyplot as plt           # Import the Matplotlib package
import numpy as np                        # Import the Numpy package
from netCDF4 import Dataset               # Import the NetCDF Python interface
from remap import remap                   # Import the Remap function
from mpl_toolkits.basemap import Basemap  # Import the Basemap utility

# File to read
image1 = "OR_ABI-L2-CMIPF-M6C15_G16_s20191850300287_e20191850310001_c20191850310084.nc"
# Read the file using the NetCDF library
file1 = Dataset(image1)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image1, extent, resolution)
# Read the data as an array
data1 = grid.ReadAsArray()
# Convert to Celsius
data1 = data1 - 273.15

# File to read
image2 = "OR_ABI-L2-CMIPF-M6C13_G16_s20191850300287_e20191850310006_c20191850310084.nc"
# Read the file using the NetCDF library
file2 = Dataset(image2)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image2, extent, resolution)
# Read the data as an array
data2 = grid.ReadAsArray()
# Convert to Celsius
data2 = data2 - 273.15

# File to read
image3 = "OR_ABI-L2-CMIPF-M6C07_G16_s20191850300287_e20191850310006_c20191850310078.nc"
# Read the file using the NetCDF library
file3 = Dataset(image3)
# Desired resolution
resolution = 2
# Desired extent
extent = [-138, 5.0, -112, 24.0]
# Remap and get the brightness temperatures
grid = remap(image3, extent, resolution)
# Read the data as an array
data3 = grid.ReadAsArray()
# Convert to Celsius
data3 = data3 - 273.15

# Define the size of the saved picture=================================================================
#plt.figure(figsize=(10,6))
DPI = 150
fig = plt.figure(figsize=(data1.shape[1]/float(DPI), data1.shape[0]/float(DPI)), frameon=False, dpi=DPI)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax = plt.axis('off')
# ====================================================================================================

# RGB Components
R = data1 - data2
G = data2 - data3
B = data2

# Minimuns and Maximuns
Rmin = -6.7
Rmax = 2.6

Gmin = -3.1
Gmax = 5.2

Bmin = -29.60
Bmax = 19.5

R[RRmax] = Rmax

G[GGmax] = Gmax

B[BBmax] = Bmax

# Choose the gamma
gamma_R = 1
gamma_G = 1
gamma_B = 1

# Normalize the data
R = ((R - Rmin) / (Rmax - Rmin)) ** (1/gamma_R)
G = ((G - Gmin) / (Gmax - Gmin)) ** (1/gamma_G)
B = ((B - Bmin) / (Bmax - Bmin)) ** (1/gamma_B)

# Create the RGB
RGB = np.stack([R, G, B], axis=2)

# ====================================================================================================

# Create the basemap
bmap = Basemap(llcrnrlon=extent[0], llcrnrlat=extent[1], urcrnrlon=extent[2], urcrnrlat=extent[3], epsg=4326, resolution = 'i')

# Plot the image
bmap.imshow(RGB, origin='upper')

# Insert a shapefile
bmap.readshapefile('estados_2010','estados_2010',linewidth=0.6,color='white')

# Configure the map
bmap.drawcoastlines(linewidth=0.6, linestyle='solid', color='gold')
bmap.drawcountries(linewidth=0.6, linestyle='solid', color='orange')
bmap.drawparallels(np.arange(-90.0, 90.0, 5.0), dashes = [4 ,4], linewidth=0.8, color='cyan', labels=[True,False,False,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)
bmap.drawmeridians(np.arange(0.0, 360.0, 5.0), dashes = [4,4], linewidth=0.8, color='cyan', labels=[False,False,True,False], fmt='%g', labelstyle="+/-", xoffset= 0.00, yoffset= 0.00, size=7)

# Save the image
plt.savefig('RGB_Night_Microphysics.png', dpi=DPI, pad_inches=0)