Skip to content

Commit

Permalink
Viirs readers fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Raspaud <martin.raspaud@smhi.se>
  • Loading branch information
mraspaud committed Nov 14, 2014
1 parent 906c380 commit e0439a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 13 additions & 3 deletions mpop/satin/viirs_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
def load(satscene, *args, **kwargs):
del args

files_to_load = []
files_to_delete = []

filename = kwargs.get("filename")
logger.debug("reading " + str(filename))
if filename is not None:
Expand All @@ -63,6 +66,7 @@ def load(satscene, *args, **kwargs):
fp_.write(zipfile.read())
zipfile.close()
files_to_load.append(newname)
files_to_delete.append(newname)
else:
files_to_load.append(filename)
else:
Expand Down Expand Up @@ -114,7 +118,13 @@ def load(satscene, *args, **kwargs):
"M15": "M15",
"M16": "M16"}

chans = [chan_dict[chn] for chn in satscene.channels_to_load]
channels = [(chn, chan_dict[chn])
for chn in satscene.channels_to_load
if chn in chan_dict]
try:
channels_to_load, chans = zip(*channels)
except ValueError:
return

datas = []
lonlats = []
Expand All @@ -129,15 +139,15 @@ def load(satscene, *args, **kwargs):
lons = np.ma.vstack([lonlat[0] for lonlat in lonlats])
lats = np.ma.vstack([lonlat[1] for lonlat in lonlats])

for nb, chn in enumerate(satscene.channels_to_load):
for nb, chn in enumerate(channels_to_load):
data = np.ma.vstack([dat[nb] for dat in datas])
satscene[chn] = data
satscene[chn].info["units"] = units[nb]

area_def = SwathDefinition(np.ma.masked_where(data.mask, lons),
np.ma.masked_where(data.mask, lats))

for chn in satscene.channels_to_load:
for chn in channels_to_load:
satscene[chn].area = area_def


Expand Down
12 changes: 6 additions & 6 deletions mpop/satin/viirs_sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,15 +851,15 @@ def _get_swathsegment(filelist, time_start, time_end=None, area=None):
"""
if area is not None:
from trollsched.spherical import SphPolygon
from trollsched.satpass import Boundary
from trollsched.boundary import AreaBoundary

lons, lats = area.get_boundary_lonlats()
area_boundary = Boundary((lons.side1, lats.side1),
(lons.side2, lats.side2),
(lons.side3, lats.side3),
(lons.side4, lats.side4))
area_boundary = AreaBoundary((lons.side1, lats.side1),
(lons.side2, lats.side2),
(lons.side3, lats.side3),
(lons.side4, lats.side4))
area_boundary.decimate(500)
contour_poly = area_boundary.contour_poly()
contour_poly = area_boundary.contour_poly

segment_files = []
for filename in filelist:
Expand Down

0 comments on commit e0439a5

Please sign in to comment.