Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def channel_image(self, channel, fill_value=0):
"""Make a black and white image of the *channel*.
Linear stretch without clipping is applied by default.
"""
self.check_channels(channel)
img = geo_image.GeoImage(self[channel].data,
self[channel].area,
self.time_slot,
fill_value=fill_value,
mode="L")
img.enhance(stretch="crude")
return img
def dnb(self, stretch="histogram"):
"""Make a black and white image of the Day-Night band."""
self.check_channels('DNB')
img = geo_image.GeoImage(self['DNB'].data,
self.area,
self.time_slot,
fill_value=0,
mode="L")
if stretch:
img.enhance(stretch=stretch)
return img
def red_snow(self):
"""Make a Red Snow RGB image composite.
"""
self.check_channels('M05', 'M10', 'M15')
ch1 = self['M05'].check_range()
ch2 = self['M10'].check_range()
ch3 = -self['M15'].data
img = geo_image.GeoImage((ch1, ch2, ch3),
self.area,
self.time_slot,
fill_value=(0, 0, 0),
mode="RGB")
img.enhance(stretch="crude")
return img
def hr_green_snow(self):
"""Make a Green Snow RGB image composite.
"""
self.check_channels('I01', 'I03', 'I05')
ch1 = self['I03'].check_range()
ch2 = self['I01'].check_range()
ch3 = -self['I05'].data
img = geo_image.GeoImage((ch1, ch2, ch3),
self.area,
self.time_slot,
fill_value=(0, 0, 0),
mode="RGB")
img.enhance(stretch="crude")
img.enhance(gamma=1.6)
return img
green: M04(555)
* X = log10(max(M2, M3)/M4)
"""
self.check_channels("M02", "M03", "M04")
a0, a1, a2, a3, a4 = (0.2228, -2.4683, 1.5867, -0.4275, -0.7768)
#X = np.maximum(self["M02"].data, self["M03"].data)/self["M04"].data
X = self["M02"].data / self["M04"].data
X = np.log10(X)
chlor_a = 10 ** (a0 + a1 * X + a2 * (X ** 2) +
a3 * (X ** 3) + a4 * (X ** 4))
print 'chlor_a:', chlor_a.min(), chlor_a.mean(), chlor_a.max()
img = geo_image.GeoImage(chlor_a,
self.area,
self.time_slot,
fill_value=0,
mode="L")
if stretch:
img.enhance(stretch=stretch)
return img
def convection_co2(self):
"""Make a Severe Convection RGB image composite on SEVIRI compensating
for the CO2 absorption in the 3.9 micron channel.
"""
self.co2corr_chan()
self.check_channels("_IR39Corr", 0.635, 1.63, 6.7, 7.3, 10.8)
ch1 = self[6.7].data - self[7.3].data
ch2 = self["_IR39Corr"].data - self[10.8].data
ch3 = self[1.63].check_range() - self[0.635].check_range()
img = geo_image.GeoImage((ch1, ch2, ch3),
self.area,
self.time_slot,
fill_value=(0, 0, 0),
mode="RGB",
crange=((-30, 0),
(0, 55),
(-70, 20)))
img.enhance(gamma=(1.0, 0.5, 1.0))
return img
| IR3.9 (inverted) | gamma 1 |
+--------------------+--------------------+
| IR10.8 (inverted) | gamma 1 |
+--------------------+--------------------+
| IR12.0 (inverted) | gamma 1 |
+--------------------+--------------------+
Linear stretch with 0.5 % clipping at both ends.
"""
self.check_channels(3.75, 10.8, 12.0)
ch1 = -self[3.75].data
ch2 = -self[10.8].data
ch3 = -self[12.0].data
img = geo_image.GeoImage((ch1, ch2, ch3),
self.area,
self.time_slot,
fill_value=(0, 0, 0),
mode="RGB")
if stretch:
img.enhance(stretch=stretch)
if gamma:
img.enhance(gamma=gamma)
return img
def ir108(self):
"""Make a black and white image of the IR 10.8um channel.
Channel is inverted. Temperature range from -70 °C (white) to
+57.5 °C (black) is shown.
"""
self.check_channels(10.8)
img = geo_image.GeoImage(self[10.8].data,
self.area,
self.time_slot,
fill_value=0,
mode="L",
crange=(-70 + 273.15, 57.5 + 273.15))
img.enhance(inverse=True)
return img
def cloudtop(self, stretch=(0.005, 0.005), gamma=None):
"""Make a Cloudtop RGB image composite from Seviri channels.
"""
self.co2corr_chan()
self.check_channels("_IR39Corr", 10.8, 12.0)
ch1 = -self["_IR39Corr"].data
ch2 = -self[10.8].data
ch3 = -self[12.0].data
img = geo_image.GeoImage((ch1, ch2, ch3),
self.area,
self.time_slot,
fill_value=(0, 0, 0),
mode="RGB")
if stretch:
img.enhance(stretch=stretch)
if gamma:
img.enhance(gamma=gamma)
return img
else:
inv.append(False)
new_channels.append(channel)
data.append(self[channel].data)
new_area = self[channel].area
if area and (new_area != area):
raise ValueError("Channels should have the same area")
else:
area = new_area
self.check_channels(*new_channels)
img = geo_image.GeoImage(data,
area=area,
start_time=self.time_slot,
fill_value=keys.get("fill_value", None),
crange=keys.get("crange", None),
mode=keys.get("mode", None))
img.enhance(inverse=inv,
gamma=keys.get("gamma", 1.0),
stretch=keys.get("stretch", "no"))
return img