Skip to content

Commit

Permalink
Clean up style
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Dec 20, 2017
1 parent d1a0746 commit ed7c018
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
13 changes: 6 additions & 7 deletions satpy/enhancements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ def invert(img, *args):


def cira_stretch(img, **kwargs):
"""Logarithmic stretch adapted to human vision."""
"""Logarithmic stretch adapted to human vision.
Applicable only for visible channels.
"""
LOG.debug("Applying the cira-stretch")
for chn in img.channels:
chn /= 100
np.log10(chn.data, out=chn.data)
# chn[:] = np.ma.masked_invalid(chn)
chn -= np.log10(0.0223)
chn /= 1.0 - np.log10(0.0223)
chn /= 0.75


def lookup(img, **kwargs):
"""Assigns values to channels based on a table"""
"""Assign values to channels based on a table."""
luts = np.array(kwargs['luts'], dtype=np.float32) / 255.0

for idx, ch in enumerate(img.channels):
Expand All @@ -67,14 +69,12 @@ def lookup(img, **kwargs):

def colorize(img, **kwargs):
"""Colorize the given image."""

full_cmap = _merge_colormaps(kwargs)
img.colorize(full_cmap)


def palettize(img, **kwargs):
"""Palettize the given image (no color interpolation)."""

full_cmap = _merge_colormaps(kwargs)
img.palettize(full_cmap)

Expand All @@ -95,8 +95,7 @@ def _merge_colormaps(kwargs):


def create_colormap(palette):
"""Create colormap of the given numpy file, color vector or colormap template."""

"""Create colormap of the given numpy file, color vector or colormap."""
from trollimage.colormap import Colormap
fname = palette.get('filename', None)
if fname:
Expand Down
14 changes: 5 additions & 9 deletions satpy/readers/hdfeos_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,13 @@
w=c&wchp=dGLzVlz-zSkWz&md5=bac5bc7a4f08007722ae793954f1dd63&ie=/sdarticle.pdf
"""

import glob
import hashlib
import logging
import math
import multiprocessing
import os.path
from datetime import datetime
from fnmatch import fnmatch

import numpy as np
from pyhdf.error import HDF4Error
from pyhdf.SD import SD

from pyresample import geometry
from satpy.config import CONFIG_PATH
from satpy.dataset import Dataset, DatasetID
from satpy.readers.file_handlers import BaseFileHandler

Expand Down Expand Up @@ -143,6 +135,7 @@ def __init__(self, filename, filename_info, filetype_info):
self.cache[1000]['lats'] = None

def get_dataset(self, key, info, out=None, xslice=None, yslice=None):
"""Get the dataset designated by *key*."""
if key.name in ['solar_zenith_angle', 'solar_azimuth_angle',
'satellite_zenith_angle', 'satellite_azimuth_angle']:

Expand Down Expand Up @@ -189,6 +182,7 @@ def get_dataset(self, key, info, out=None, xslice=None, yslice=None):
return Dataset(self.cache[key.resolution]['lons'], id=key, **info)

def load(self, keys, interpolate=True, raw=False):
"""Load the data."""
projectables = []
for key in keys:
dataset = self.sd.select(key.name.capitalize())
Expand All @@ -200,7 +194,9 @@ def load(self, keys, interpolate=True, raw=False):
data = np.ma.masked_equal(dataset.get(), fill_value) * scale_factor

# TODO: interpolate if needed
if key.resolution is not None and key.resolution < self.resolution and interpolate:
if (key.resolution is not None and
key.resolution < self.resolution and
interpolate):
data = self._interpolate(data, self.resolution, key.resolution)
if raw:
projectables.append(data)
Expand Down

0 comments on commit ed7c018

Please sign in to comment.