# Input plugins: the `mpop.satin` package

## Available plugins and their requirements

### mipp_xrit

Reader for for hrit/lrit formats. Recommends numexpr and pyresample.

### aapp1b

Reader for AAPP level 1b format. Requires numpy, recommends pyresample.

Reader for aapp level 1b data.

Options for loading:

> - pre_launch_coeffs (False): use pre-launch coefficients if True, operational otherwise (if available).

http://research.metoffice.gov.uk/research/interproj/nwpsaf/aapp/ NWPSAF-MF-UD-003_Formats.pdf

class `mpop.satin.aapp1b.``AAPP1b`(fname)

  AAPP-level 1b data reader

  `calibrate`(chns=('1', '2', '3A', '3B', '4', '5'), calibrate=1, pre_launch_coeffs=False, calib_coeffs=None)

    Calibrate the data

  `navigate`()

    Return the longitudes and latitudes of the scene.

  `read`()

    Read the data.

`mpop.satin.aapp1b.``load`(satscene, *args, **kwargs)

  Read data from file and load it into satscene. A possible calibrate keyword argument is passed to the AAPP reader. Should be 0 for off (counts), 1 for default (brightness temperatures and reflectances), and 2 for radiances only.

  If use_extern_calib keyword argument is set True, use external calibration data.

`mpop.satin.aapp1b.``load_avhrr`(satscene, options)

  Read avhrr data from file and load it into satscene.

`mpop.satin.aapp1b.``main`()

`mpop.satin.aapp1b.``show`(data, negate=False)

  Show the stetched data.

### eps_l1b

Reader for EPS level 1b format. Recommends pyresample.

Reader for eps level 1b data. Uses xml files as a format description. See: http://www.eumetsat.int/website/wcm/idc/idcplg?IdcService=GET_FILE&dDocName=PDF_TEN_97231-EPS-AVHRR&RevisionSelectionMethod=LatestReleased&Rendition=Web and http://www.eumetsat.int/website/wcm/idc/idcplg?IdcService=GET_FILE&dDocName=PDF_TEN_990004-EPS-AVHRR1-PGS&RevisionSelectionMethod=LatestReleased&Rendition=Web

class `mpop.satin.eps_l1b.``EpsAvhrrL1bReader`(filename)

  Eps level 1b reader for AVHRR data.

  `get_channels`(channels, calib_type)

    Get calibrated channel data. calib_type = 0: Counts calib_type = 1: Reflectances and brightness temperatures calib_type = 2: Radiances

  `get_full_lonlats`()

    Get the interpolated lons/lats.

  `get_lonlat`(row, col)

    Get lons/lats for given indices. WARNING: if the lon/lats were not expanded, this will refer to the tiepoint data.

  `keys`()

    List of reader’s keys.

`mpop.satin.eps_l1b.``get_corners`(filename)

  Get the corner lon/lats of the file.

`mpop.satin.eps_l1b.``get_filename`(satscene, level)

  Get the filename.

`mpop.satin.eps_l1b.``get_lonlat`(scene, row, col)

  Get the longitutes and latitudes for the give rows and cols.

`mpop.satin.eps_l1b.``load`(scene, *args, **kwargs)

  Loads the channels into the satellite scene. A possible calibrate keyword argument is passed to the AAPP reader Should be 0 for off, 1 for default, and 2 for radiances only. However, as the AAPP-lvl1b file contains radiances this reader cannot return counts, so calibrate=0 is not allowed/supported. The radiance to counts conversion is not possible.

`mpop.satin.eps_l1b.``norm255`(a__)

  normalize array to uint8.

`mpop.satin.eps_l1b.``read_raw`(filename)

  Read filename without scaling it afterwards.

`mpop.satin.eps_l1b.``show`(a__)

  show array.

`mpop.satin.eps_l1b.``to_bt`(arr, wc_, a__, b__)

  Convert to BT.

`mpop.satin.eps_l1b.``to_refl`(arr, solar_flux)

  Convert to reflectances.

### viirs_sdr

Reader for the VIIRS SDR format. Requires h5py.

Interface to VIIRS SDR format

Format documentation: http://npp.gsfc.nasa.gov/science/sciencedocuments/082012/474-00001-03_CDFCBVolIII_RevC.pdf

class `mpop.satin.viirs_sdr.``GeolocationFlyweight`(cls)
  `clear_cache`()

class `mpop.satin.viirs_sdr.``HDF5MetaData`(filename)

  Small class for inspecting a HDF5 file and retrieve its metadata/header data. It is developed for JPSS/NPP data but is really generic and should work on most other hdf5 files.

  Supports

  `collect_metadata`(name, obj)
  `get_data_keys`()
  `keys`()
  `read`()

class `mpop.satin.viirs_sdr.``NPPMetaData`(filename)
  `get_band_description`()
  `get_begin_orbit_number`()
  `get_begin_time`()
  `get_brightness_temperature_keys`()
  `get_end_orbit_number`()
  `get_end_time`()
  `get_geofilname`()
  `get_radiance_keys`()
  `get_reflectance_keys`()
  `get_ring_lonlats`()
  `get_shape`()
  `get_unit`(calibrate=1)

class `mpop.satin.viirs_sdr.``ViirsBandData`(filenames, calibrate=1)

  Placeholder for the VIIRS M&I-band data. Reads the SDR data - one hdf5 file for each band. Not yet considering the Day-Night Band

  `read`()
  `read_lonlat`(geofilepaths=None, geodir=None)

class `mpop.satin.viirs_sdr.``ViirsSDRReader`(*args, **kwargs)
  `get_elevation`(**kwargs)

    Get elevation/topography for a given band type (M, I, or DNB) Optional arguments:

    > bandtype = ‘M’, ‘I’, or ‘DNB’

    Return
      elevation
  `get_sunsat_angles`(**kwargs)

    Get sun-satellite viewing geometry for a given band type (M, I, or DNB) Optional arguments:

    > bandtype = ‘M’, ‘I’, or ‘DNB’

    Return
      sun-zenith, sun-azimuth, sat-zenith, sat-azimuth
  `load`(satscene, calibrate=1, time_interval=None, area=None, filename=None, **kwargs)

    Read viirs SDR reflectances and Tbs from file and load it into satscene.

  `pformat` = 'viirs_sdr'

`mpop.satin.viirs_sdr.``get_elevation_into`(filename, out_height, out_mask)

  Read elevation/height from hdf5 file

`mpop.satin.viirs_sdr.``get_lonlat_into`(filename, out_lons, out_lats, out_height, out_mask)

  Read lon,lat from hdf5 file

`mpop.satin.viirs_sdr.``get_viewing_angle_into`(filename, out_val, out_mask, param)

  Read a sun-sat viewing angle from hdf5 file

`mpop.satin.viirs_sdr.``globify`(filename)

### viirs_compact

Reader for the VIIRS compact format from EUMETSAT. Requires h5py.

Compact viirs format.

`mpop.satin.viirs_compact.``expand_array`(data, scans, c_align, c_exp, scan_size=16, tpz_size=16, nties=200, track_offset=0.5, scan_offset=0.5)

`mpop.satin.viirs_compact.``load`(satscene, *args, **kwargs)

`mpop.satin.viirs_compact.``lonlat2xyz`(lon, lat)

`mpop.satin.viirs_compact.``navigate_dnb`(h5f)

`mpop.satin.viirs_compact.``navigate_m`(h5f, channel)

`mpop.satin.viirs_compact.``read_dnb`(h5f)

`mpop.satin.viirs_compact.``read_m`(h5f, channels, calibrate=1)

`mpop.satin.viirs_compact.``xyz2lonlat`(x, y, z)

### hdfeos_l1b

Reader for Modis data format. Requires pyhdf.

### msg_hdf

Reader for MSG cloud products. Requires h5py, recommends acpg.

### pps_hdf

Reader for PPS cloud products. Requires acpg.

Plugin for reading PPS’s cloud products hdf files.

class `mpop.satin.pps_hdf.``PpsCTTH`
  `copy`(other)
  `read`(filename)

class `mpop.satin.pps_hdf.``PpsCloudType`
  `copy`(other)
  `is_loaded`()
  `read`(filename)

`mpop.satin.pps_hdf.``load`(scene, **kwargs)

  Load data into the channels. Channels is a list or a tuple containing channels we will load data into. If None, all channels are loaded.

### hrpt

Reader for level 0 hrpt format. Requires AAPP and pynav.

### eps1a

Reader for level 1a Metop segments. Requires AAPP, kai and eugene.

## Interaction with reader plugins

The reader plugin instance used for a specific scene is accessible through a scene attribute named after the plugin format. For example, the attribute for the foo format would be called foo_reader.

This way the other methods present in the plugins are available through the scene object.

## The plugin API

Changed in version 0.13.0: New plugin API

The `mpop.plugin_base` module defines the plugin API.

class `mpop.plugin_base.``Plugin`

  The base plugin class. It is not to be used as is, it has to be inherited by other classes.

class `mpop.plugin_base.``Reader`(scene)

  Reader plugins. They should have a pformat attribute, and implement the load method. This is an abstract class to be inherited.

  `load`(channels_to_load)

    Loads the channels_to_load into the scene object.

  `ptype` = 'reader'

class `mpop.plugin_base.``Writer`(scene)

  Writer plugins. They must implement the save method. This is an abstract class to be inherited.

  `ptype` = 'writer'
  `save`(filename)

    Saves the scene to a given filename.

## Adding a new plugin

For now only reader and writer plugins base classes are defined.

To add one of those, just create a new class that subclasses the plugin.

The interface of any reader plugin must include the `load()` method.

Take a look at the existing readers for more insight.