Skip to content

Commit

Permalink
Fix palettes normalised to 0-1 for mpop
Browse files Browse the repository at this point in the history
Signed-off-by: Adam.Dybbroe <a000680@c20671.ad.smhi.se>
  • Loading branch information
Adam.Dybbroe committed Sep 15, 2016
1 parent 738348e commit d07f8dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion mpop/imageo/palettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,9 @@ def get_cot_legend():
def get_log_legend(product_name):
# This is the same data as is used in logdata2image (when indata as for
# the calls from cppimage)
return CPP_COLORS[product_name].palette()
legend = CPP_COLORS[product_name].palette()
palette = convert_palette(legend)
return palette


def oca_get_scenetype_legend():
Expand Down
14 changes: 9 additions & 5 deletions mpop/instruments/seviri.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,22 @@ def oca(self, fieldname):

palette = oca_palette_func[fieldname]()
data = getattr(getattr(self['OCA'], fieldname), 'data')
if fieldname in ['ul_ctp', 'll_ctp']:
if fieldname in ['scenetype']:
data = data.astype('uint8')

elif fieldname in ['ul_ctp', 'll_ctp']:
data = (22. - data / 5000.).astype('Int16')

elif fieldname in ['reff']:
data = (data * 1000000. + 0.5).astype('uint8')
data.fill_value = 255

elif fieldname in ['ul_cot', 'll_cot']:
import pdb
data = np.ma.exp(data * np.ma.log(10))
max_value = palettes.CPP_COLORS['cot'].breaks[-1][0]
no_data = -1000 # FIXME!
data = _arrange_log_data(data, max_value, no_data)
pdb.set_trace()
data.fill_value = 255
no_data = 255 # FIXME!
data = _arrange_log_data(data.filled(), max_value, no_data)

else:
raise NotImplementedError(
Expand Down

0 comments on commit d07f8dd

Please sign in to comment.