source: trunk/src/python_script/drawmap.py @ 6

Last change on this file since 6 was 6, checked in by gaclod, 12 years ago

add GC python scripts

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import string
4import numpy as np
5import matplotlib.pyplot as plt
6from pylab import *
7from mpl_toolkits.basemap import Basemap
8from mpl_toolkits.basemap import shiftgrid, cm
9
10def drawmap(z, xvec, yvec, outfile, txt, cax1,cax2,cax3, my_cmap, coef):
11
12           # on recupere les coordonnes xy de la projection orth standard
13           m1 = Basemap(projection='ortho', lat_0 = -90, lon_0 = 0,
14resolution = 'l')
15
16           xii, yii = m1(*np.meshgrid(xvec,yvec))
17           width = m1.urcrnrx - m1.llcrnrx
18           height = m1.urcrnry - m1.llcrnry
19           width = width*coef
20           height = height*coef
21
22# on fait une nouvelle projection en zoomant sur l'antarctique
23
24           map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
25llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
26           xii, yii = map(*np.meshgrid(xvec,yvec))
27           clevs=arange(cax1,cax2,cax3)#star, stop, step
28           cs=map.contourf(xii,yii,z, clevs, cmap=my_cmap)
29           cbar =colorbar(cs)
30           plt.title(txt)
31# draw coastlines, country boundaries, fill continents.
32           map.drawcoastlines(linewidth=1)
33# draw the edge of the map projection region (the projection limb)
34           map.drawmapboundary()
35# draw lat/lon grid lines every 30 degrees.
36           map.drawmeridians(np.arange(0, 360, 30), labels=[0, 0, 0, 1])
37           map.drawparallels(np.arange(-90, 90, 10), labels=[1, 0, 0, 0])
38#plt.show()
39           plt.savefig(outfile)
40           close()
Note: See TracBrowser for help on using the repository browser.