#!/usr/bin/env python

from pyhdf.SD import SD, SDC
from mpl_toolkits.basemap import Basemap, cm
from matplotlib.colors import LogNorm

from pylab import *
import matplotlib.pyplot as plt
import numpy as np
import math

#---------- read data ----------#

File_Name = 'A20080012008031.L3m_MO_CHL_chlor_a_9km'
File = SD(File_Name, SDC.READ)
l3chlor = File.select('l3m_data')
l3chlor_data = l3chlor.get()

print l3chlor_data.shape
print l3chlor_data.max()
print l3chlor_data.min()

FillValue = -32767.0

l3chlor_data[ (l3chlor_data < 0.01) & (l3chlor_data != -32767.0) ] = 0.011
l3chlor_data[ l3chlor_data > 10 ] = 10.0
l3chlor_data[ l3chlor_data == FillValue ] = 0.00001

#---------- Plot Data Global Map ----------#

m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90, llcrnrlon=-180, \
			urcrnrlon=180,resolution='c')
m.drawcoastlines()
m.drawlsmask(land_color='white',ocean_color='white',lakes=True)
m.drawparallels(np.arange(-90.,90.,30.))
m.drawmeridians(np.arange(-180.,180.,30.))
m.drawmapboundary(fill_color='aqua')

colors = [(0.33,0.33,0.33)] + [(plt.cm.jet(i)) for i in xrange(1,256)]
new_map = matplotlib.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256)

img = m.imshow(np.flipud(l3chlor_data), norm=LogNorm(vmin=0.01, vmax=10.0), \
			   cmap=new_map, interpolation='bilinear')
cb = m.colorbar(img,"bottom", size="5%", pad='4%')

plt.title('MODIS/Aqua Chlorophyll Concentration \n January 2008')
plt.savefig('ExampleChlorophyllConcentration.png',dpi=200)
plt.show()

About / Au sujet de

Ben
Created:
30 octobre 2016 13:22:57

Updated:
30 octobre 2016 13:22:57

License / Licence

MIT License

Abstract / Résumé