Make a MODIS true color image using Satpy and Pyspectral

Created with:

Package Version
SatPy 0.9.0
PyResample 1.10.1
Trollimage 1.5.3
PyKdtree 1.3.1

In order for the modis reader (hdf eos l1b), you need the pyhdf python package to be installed with:

pip install python-hdf4

or if running a conda environment:

conda install pyhdf

In [1]:
from satpy.scene import Scene
from satpy import find_files_and_readers
from datetime import datetime
In [2]:
DATA_DIR = "/home/a000680/data/polar_in/direct_readout/eos/lvl1"
In [3]:
myfiles = find_files_and_readers(base_dir=DATA_DIR,
                                 sensor="modis",
                                 start_time=datetime(2016, 3, 30, 11, 40),
                                 end_time=datetime(2016, 3, 30, 12, 5),
                                 reader='modis_l1b')
scn = Scene(filenames=myfiles)
(0, ['/home/a000680/usr/src/satpy/satpy/etc/readers/hdfeos_l1b.yaml'], ['hdfeos_l1b'])
In [4]:
composite_name = 'true_color'
scn.load([composite_name], resolution=1000)
/home/a000680/.local/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
In [5]:
areaid = 'eurol'
lcn = scn.resample(areaid, radius_of_influence=10000)
In [6]:
lcn.show(composite_name)
Out[6]:
<trollimage.xrimage.XRImage at 0x7fdc88025310>

In [7]:
lcn.save_dataset(composite_name, './modis_%s_rgb_%s_%s.png' %
                 (composite_name, lcn.attrs['start_time'].strftime('%Y%m%d%H%M'), areaid))
/home/a000680/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in less
  return func(*args2)
/home/a000680/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in log10
  return func(*args2)