source: trunk/src/python_script/draw_map_3gc.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: 6.4 KB
Line 
1#mod gabi para graficar AMSUA CH2
2#!/usr/bin/env python
3# -*- coding: utf-8 -*-
4import string
5import numpy as np
6import matplotlib.pyplot as plt
7import ffgrid2
8from pylab import *
9from mpl_toolkits.basemap import Basemap
10from mpl_toolkits.basemap import shiftgrid, cm
11#import netCDF4
12
13#x=monthly_lon
14#y=monthly_lat
15#z=monthly_outz
16
17zz1=zzpgrid_3n
18zz2=sigma_grid_3n
19zz3=nngrid_3n
20
21t1='amsua_ch2_tb.png'
22tt1='amsua_ch2 tb'
23t2='amsua_ch2_ecart_type.png'
24tt2='amsua_ch2 ecart type'
25t3='amsua_ch2_nom_donnes_tb.png'
26tt3='amsua ch2 nom donnes tb'
27
28t1='amsua_ch2_pos3_tb.png'
29tt1='amsua_ch2 pos3 tb'
30t2='amsua_ch2_pos3_ecart_type.png'
31tt2='amsua_ch2 pos3 ecart type'
32t3='amsua_ch2_pos3_nom_donnes_tb.png'
33tt3='amsua ch2 pos3 nom donnes tb'
34
35
36# on recupere les coordonnes xy de la projection orth standard
37m1 = Basemap(projection='ortho', lat_0 = -90, lon_0 = 0,
38resolution = 'l')
39
40xii, yii = m1(*np.meshgrid(xvec,yvec))
41width = m1.urcrnrx - m1.llcrnrx
42height = m1.urcrnry - m1.llcrnry
43
44coef = 0.6
45width = width*coef
46height = height*coef
47
48# on fait une nouvelle projection en zoomant sur l'antarctique
49
50map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
51
52llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
53xii, yii = map(*np.meshgrid(xvec,yvec))
54cs=m.contourf(xii,yii,zz1)
55#, clevs, cmap=my_cmap)
56cs=map.pcolormesh(xii,yii,zz1,cmap=cm.s3pcpn_l_r)
57#cs=map.pcolormesh(xii,yii,zz2)
58#cmap=cm.s3pcpn_l_r)
59#sstanom)
60#s3pcpn_l_r)
61cbar =colorbar(cs)
62plt.title(tt1)
63
64# draw coastlines, country boundaries, fill continents.
65map.drawcoastlines(linewidth=1)
66# draw the edge of the map projection region (the projection limb)
67map.drawmapboundary()
68# draw lat/lon grid lines every 30 degrees.
69map.drawmeridians(np.arange(0, 360, 10))
70map.drawparallels(np.arange(-90, 90, 10))
71#plt.show()
72
73plt.savefig(t1)
74close()
75
76#carte ecart type
77zz21 = sigma_grid_t
78zz22 = sigma_grid_1n
79zz23 = sigma_grid_2n
80zz24 = sigma_grid_3n
81tt21='amsua ch2 t ecart type'
82tt22='amsua ch2 1n ecart type'
83tt23='amsua ch2 2n ecart type'
84tt24='amsua ch2 3n ecart type'
85t='amsua_ch2_ecart_type.png'
86
87figure(1)
88subplot(221)
89m1 = Basemap(projection='ortho', lat_0 = -90, lon_0 = 0,
90resolution = 'l')
91
92xii, yii = m1(*np.meshgrid(xvec,yvec))
93width = m1.urcrnrx - m1.llcrnrx
94height = m1.urcrnry - m1.llcrnry
95
96coef = 0.6
97width = width*coef
98height = height*coef
99
100# on fait une nouvelle projection en zoomant sur l'antarctique
101map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
102llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
103xii, yii = map(*np.meshgrid(xvec,yvec))
104clevs=arange(0,40,0.1)#star, stop, step
105cs=map.contourf(xii,yii,zz21, clevs, cmap=cm.s3pcpn_l)
106#cs=map.pcolormesh(xii,yii,zz2)
107#cmap=cm.s3pcpn_l_r)
108#sstanom)
109#s3pcpn_l_r)
110cbar =colorbar(cs)
111plt.title(tt21)
112# draw coastlines, country boundaries, fill continents.
113map.drawcoastlines(linewidth=1)
114# draw the edge of the map projection region (the projection limb)
115map.drawmapboundary()
116# draw lat/lon grid lines every 30 degrees.
117map.drawmeridians(np.arange(0, 360, 10))
118map.drawparallels(np.arange(-90, 90, 10))
119
120subplot(222)
121# on fait une nouvelle projection en zoomant sur l'antarctique
122map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
123llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
124xii, yii = map(*np.meshgrid(xvec,yvec))
125clevs=arange(0,40,0.1)#star, stop, step
126cs=map.contourf(xii,yii,zz22, clevs, cmap=cm.s3pcpn_l)
127#cs=map.pcolormesh(xii,yii,zz2)
128#cmap=cm.s3pcpn_l_r)
129#sstanom)
130#s3pcpn_l_r)
131cbar =colorbar(cs)
132plt.title(tt22)
133# draw coastlines, country boundaries, fill continents.
134map.drawcoastlines(linewidth=1)
135# draw the edge of the map projection region (the projection limb)
136map.drawmapboundary()
137# draw lat/lon grid lines every 30 degrees.
138map.drawmeridians(np.arange(0, 360, 10))
139map.drawparallels(np.arange(-90, 90, 10))
140
141
142subplot(223)
143# on fait une nouvelle projection en zoomant sur l'antarctique
144map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
145llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
146xii, yii = map(*np.meshgrid(xvec,yvec))
147clevs=arange(0,40,0.1)#star, stop, step
148cs=map.contourf(xii,yii,zz23, clevs, cmap=cm.s3pcpn_l)
149#cs=map.pcolormesh(xii,yii,zz2)
150#cmap=cm.s3pcpn_l_r)
151#sstanom)
152#s3pcpn_l_r)
153cbar =colorbar(cs)
154plt.title(tt23)
155# draw coastlines, country boundaries, fill continents.
156map.drawcoastlines(linewidth=1)
157# draw the edge of the map projection region (the projection limb)
158map.drawmapboundary()
159# draw lat/lon grid lines every 30 degrees.
160map.drawmeridians(np.arange(0, 360, 10))
161map.drawparallels(np.arange(-90, 90, 10))
162
163
164subplot(224)
165# on fait une nouvelle projection en zoomant sur l'antarctique
166map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
167llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
168xii, yii = map(*np.meshgrid(xvec,yvec))
169clevs=arange(0,40,0.1)#star, stop, step
170cs=map.contourf(xii,yii,zz24, clevs, cmap=cm.s3pcpn_l)
171#cs=map.pcolormesh(xii,yii,zz2)
172#cmap=cm.s3pcpn_l_r)
173#sstanom)
174#s3pcpn_l_r)
175cbar =colorbar(cs)
176plt.title(tt24)
177# draw coastlines, country boundaries, fill continents.
178map.drawcoastlines(linewidth=1)
179# draw the edge of the map projection region (the projection limb)
180map.drawmapboundary()
181# draw lat/lon grid lines every 30 degrees.
182map.drawmeridians(np.arange(0, 360, 10))
183map.drawparallels(np.arange(-90, 90, 10))
184
185plt.show()
186plt.savefig(t)
187close()
188
189
190
191
192
193
194##########################"
195#carte nom de donnees
196m1 = Basemap(projection='ortho', lat_0 = -90, lon_0 = 0,
197resolution = 'l')
198
199xii, yii = m1(*np.meshgrid(xvec,yvec))
200width = m1.urcrnrx - m1.llcrnrx
201height = m1.urcrnry - m1.llcrnry
202
203coef = 0.6
204width = width*coef
205height = height*coef
206
207# on fait une nouvelle projection en zoomant sur l'antarctique
208
209map = Basemap(projection='ortho',lon_0=0,lat_0=-90,resolution='l',\
210
211llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)
212xii, yii = map(*np.meshgrid(xvec,yvec))
213
214evels=[300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100]
215cs=map.pcolormesh(xii,yii,zz3)
216#cmap=cm.s3pcpn_l_r)
217#sstanom)
218#s3pcpn_l_r)
219cbar =colorbar(cs)
220plt.title(tt3)
221
222# draw coastlines, country boundaries, fill continents.
223map.drawcoastlines(linewidth=1)
224# draw the edge of the map projection region (the projection limb)
225map.drawmapboundary()
226# draw lat/lon grid lines every 30 degrees.
227map.drawmeridians(np.arange(0, 360, 10))
228map.drawparallels(np.arange(-90, 90, 10))
229#plt.show()
230
231plt.savefig(t3)
232close()
Note: See TracBrowser for help on using the repository browser.