Skip to content

Commit

Permalink
Merge branch 'pre-master' of github.com:pytroll/mpop into pre-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam.Dybbroe committed Apr 12, 2016
2 parents 27051c8 + 6fc8e40 commit 4cfa45d
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 167 deletions.
5 changes: 5 additions & 0 deletions mpop/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ def sunzen_corr(self, time_slot, lonlats=None, limit=80., mode='cos',
also stored to the info dictionary of the originating channel.
'''

if self.info.get('sun_zen_correction_applied'):
LOG.debug("Sun zenith correction already applied, skipping")
return self

import mpop.tools

try:
Expand Down Expand Up @@ -423,6 +427,7 @@ def sunzen_corr(self, time_slot, lonlats=None, limit=80., mode='cos',
LOG.debug("cos_limit = %f", cos_limit)
# Mask out data where the sun elevation is below a threshold:
new_ch.data = np.ma.masked_where(cos_zen < cos_limit, new_ch.data, copy=False)
new_ch.info["sun_zen_correction_applied"] = True
return new_ch

# Arithmetic operations on channels.
Expand Down
42 changes: 33 additions & 9 deletions mpop/instruments/viirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,33 @@ def overview(self, stretch='linear', gamma=1.6):
overview.prerequisites = set(['M05', 'M07', 'M15'])

def overview_sun(self, stretch='linear', gamma=1.6):
"""Make an Overview RGB image composite from VIIRS
channels. Sun-zenith correction is implicit for VIIRS
"""Make an overview RGB image composite normalising with cosine to the
sun zenith angle.
"""
return self.overview(stretch=stretch, gamma=gamma)
self.check_channels('M05', 'M07', 'M15')

lonlats = self['M15'].area.get_lonlats()

red = self['M05'].sunzen_corr(self.time_slot, lonlats, limit=88.,
sunmask=95).data
green = self['M07'].sunzen_corr(self.time_slot, lonlats, limit=88.,
sunmask=95).data
blue = -self['M15'].data

img = geo_image.GeoImage((red, green, blue),
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

overview_sun.prerequisites = overview.prerequisites
overview_sun.prerequisites = set(['M05', 'M07', 'M15'])

def hr_overview(self):
"""Make a high resolution Overview RGB image composite
Expand Down Expand Up @@ -596,11 +617,14 @@ def snow_age(self):
self.check_channels('M07', 'M08', 'M09', 'M10', 'M11')

coeff = 255. / 160.
m07 = self['M07'].data * coeff
m08 = self['M08'].data * coeff
m09 = self['M09'].data * coeff
m10 = self['M10'].data * coeff
m11 = self['M11'].data * coeff

lonlats = self['M11'].area.get_lonlats()

m07 = self['M07'].sunzen_corr(self.time_slot, lonlats, limit=88., sunmask=95).data * coeff
m08 = self['M08'].sunzen_corr(self.time_slot, lonlats, limit=88., sunmask=95).data * coeff
m09 = self['M09'].sunzen_corr(self.time_slot, lonlats, limit=88., sunmask=95).data * coeff
m10 = self['M10'].sunzen_corr(self.time_slot, lonlats, limit=88., sunmask=95).data * coeff
m11 = self['M11'].sunzen_corr(self.time_slot, lonlats, limit=88., sunmask=95).data * coeff

refcu = m11 - m10
refcu[refcu < 0] = 0
Expand Down

0 comments on commit 4cfa45d

Please sign in to comment.