Skip to content

Commit

Permalink
Merge branch 'pre-master' of github.com:mraspaud/mpop into pre-master
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Nov 12, 2014
2 parents 292b382 + 32021b7 commit abbf03f
Show file tree
Hide file tree
Showing 4 changed files with 456 additions and 10 deletions.
32 changes: 24 additions & 8 deletions mpop/imageo/formats/libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ def get_header_defs(libtiff=None, lib_fn=None):

if tiff_h is None:
include_tiff_h = os.path.join(os.path.split(lib_fn)[0], '..', 'include', 'tiff.h')
if not os.path.isfile(include_tiff_h):
include_tiff_h = include_tiff_h.replace('/usr/lib/', '/usr/include/')
if not os.path.isfile(include_tiff_h):
# fix me for windows:
include_tiff_h = os.path.join('/usr','include','tiff.h')
if not os.path.isfile(include_tiff_h):
# fix me for windows:
include_tiff_h = os.path.join('/usr','include', 'x86_64-linux-gnu', 'tiff.h')
if not os.path.isfile(include_tiff_h):
# fix me for windows:
include_tiff_h = os.path.join('/usr','include', 'x86_32-linux-gnu', 'tiff.h')
if not os.path.isfile(include_tiff_h):
# Base it off of the python called
include_tiff_h = os.path.realpath(os.path.join(os.path.split(sys.executable)[0], '..', 'include', 'tiff.h'))
Expand All @@ -94,12 +102,19 @@ def get_header_defs(libtiff=None, lib_fn=None):
l = []
d = {}
for line in f.readlines():
if not line.startswith('#define'): continue
words = line[7:].lstrip().split()[:2]
if len (words)!=2: continue
name, value = words
i = value.find('/*')
if i!=-1: value = value[:i]
if not line.startswith('#define'):
continue
line = line[7:].strip()
i = line.find('/*')
if i != -1:
line = line[:i]
words = line.split()
if len(words) < 2:
continue
try:
name, value = words[0], ''.join(words[1:])
except:
continue
if value in d:
value = d[value]
else:
Expand Down Expand Up @@ -1410,9 +1425,10 @@ def _test_copy():
print 'test copy ok'

if __name__=='__main__':
pass
#_test_custom_tags()
_test_tile_write()
_test_tile_read("/tmp/libtiff_test_tile_write.tiff")
#_test_tile_write()
#_test_tile_read("/tmp/libtiff_test_tile_write.tiff")
#_test_write_float()
#_test_write()
#_test_read()
Expand Down
6 changes: 5 additions & 1 deletion mpop/imageo/formats/ninjotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,16 @@ def _finalize(geo_image):
**Notes**:
physic_val = image*scale + offset
**Bug**:
We do not handle different fill values for different channels.
"""
if geo_image.mode == 'L':
# PFE: mpop.satout.cfscene
dtype = np.uint8
data = geo_image.channels[0]
fill_value = geo_image.fill_value or 0
fill_value = geo_image.fill_value or [0]
fill_value = fill_value[0]
if np.ma.count_masked(data) == data.size:
# All data is masked
data = np.ones(data.shape, dtype=dtype) * fill_value
Expand Down
2 changes: 1 addition & 1 deletion mpop/imageo/formats/ninjotiff_example
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ except KeyError:
from mpop.satellites import GeostationaryFactory
import mpop.utils

#mpop.utils.debug_on()
mpop.utils.debug_on()
LOG = mpop.utils.get_logger(__name__)

# Handle argument.
Expand Down
Loading

0 comments on commit abbf03f

Please sign in to comment.