1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | import string |
---|
4 | import matplotlib.pyplot as pyplot #used to build contour and wind barbs plots |
---|
5 | from numpy import * |
---|
6 | import string |
---|
7 | import numpy as np |
---|
8 | import netCDF4 |
---|
9 | #from mpl_toolkits.basemap import shiftgrid, cm |
---|
10 | from netCDF4 import Dataset |
---|
11 | from pylab import * |
---|
12 | from mpl_toolkits.basemap import Basemap |
---|
13 | from mpl_toolkits.basemap import shiftgrid, cm |
---|
14 | |
---|
15 | # ici je boucle sur les dates |
---|
16 | list_anne=arange(2010,2011,1) |
---|
17 | list_mois=arange(8,9,1) |
---|
18 | list_jour=arange(15,32,1) |
---|
19 | |
---|
20 | #pluie_mois=np.zeros([15,nbtotal],float) |
---|
21 | |
---|
22 | for ian in range(0,1): |
---|
23 | for imo in range(0,1): |
---|
24 | for ijr in range(0,1): |
---|
25 | if (list_mois[imo] <= 9): |
---|
26 | nom_mois='0'+ str(list_mois[imo]) |
---|
27 | else: |
---|
28 | nom_mois= str(list_mois[imo]) |
---|
29 | |
---|
30 | if (list_jour[ijr] <= 9): |
---|
31 | nom_jour='0'+ str(list_jour[ijr]) |
---|
32 | else: |
---|
33 | nom_jour= str(list_jour[ijr]) |
---|
34 | |
---|
35 | jour_an=str(list_anne[ian])+nom_mois+nom_jour |
---|
36 | print jour_an |
---|
37 | fichier_netcdf='z:/arome/arome_grib_'+jour_an+'.nc' |
---|
38 | arome=Dataset(fichier_netcdf, 'r', format='NETCDF3_CLASSIC') |
---|
39 | nc_surf1= arome.variables['prevision6h humidite relative 2m'] |
---|
40 | nc_surf2= arome.variables['prevision6h temperature 2m'] |
---|
41 | nc_surf3= arome.variables['prevision6h nebul'] |
---|
42 | nc_surf4= arome.variables['prevision30h nebul'] |
---|
43 | nc_surf5= arome.variables['prevision6h TCWV'] |
---|
44 | nc_surf6= arome.variables['prevision6h flux net solaire D'] |
---|
45 | nc_surf7= arome.variables['prevision6h flux net thermique D'] |
---|
46 | nc_surf8= arome.variables['analyse pression au sol'] |
---|
47 | nc_surf9= arome.variables['prevision6h pression au sol'] |
---|
48 | nc_surf10= arome.variables['analyse altitude'] |
---|
49 | nc_surf11= arome.variables['prevision6h neige'] |
---|
50 | nc_surf12= arome.variables['prevision30h neige'] |
---|
51 | nc_surf13= arome.variables['prevision6h eau'] |
---|
52 | nc_surf14= arome.variables['prevision30h eau'] |
---|
53 | nc_surf15= arome.variables['prevision6h graupel'] |
---|
54 | nc_surf16= arome.variables['prevision30h graupel'] |
---|
55 | nc_surf17= arome.variables['prevision6h Vvent 10m'] |
---|
56 | nc_surf18= arome.variables['prevision6h Uvent 10m'] |
---|
57 | eau6h = nc_surf13[:] |
---|
58 | eau30h = nc_surf14[:] |
---|
59 | eau24h = eau30h - eau6h |
---|
60 | neige6h = nc_surf11[:] |
---|
61 | neige30h = nc_surf12[:] |
---|
62 | neige24h = neige30h - neige6h |
---|
63 | graupel6h = nc_surf15[:] |
---|
64 | graupel30h = nc_surf16[:] |
---|
65 | graupel24h = graupel30h - graupel6h |
---|
66 | rain = eau24h + graupel24h + neige24h |
---|
67 | |
---|
68 | |
---|
69 | lat=arome.variables['latitude'][:] |
---|
70 | lon=arome.variables['longitude'][:] |
---|
71 | m = Basemap(llcrnrlon=-7,urcrnrlon=11,llcrnrlat=40,urcrnrlat=52,projection='cyl',resolution='h',fix_aspect=True) |
---|
72 | |
---|
73 | xii, yii = m(*np.meshgrid(lon,lat)) |
---|
74 | ax = plt.gca() |
---|
75 | #clevs=arange(0,0.8,0.005) |
---|
76 | clevs=arange(1,30,1) |
---|
77 | m.drawcoastlines(linewidth=0.5) |
---|
78 | m.drawlsmask(ocean_color='#F4EAF1', lakes=False) |
---|
79 | cs=m.contourf(xii,yii,rain, clevs, cmap=cm.s3pcpn_l_r) # emissivity |
---|
80 | cbar =colorbar(cs) |
---|
81 | cbar.set_label('Precips 24h') |
---|
82 | #cbar.set_clim(0.65,1) |
---|
83 | # m.drawmapboundary(fill_color='aqua') |
---|
84 | #m.drawparallels(np.arange(-90.,90.,10.), labels=[1,0,0,0]) |
---|
85 | #m.drawmeridians(np.arange(-180.,180.,30.), labels=[0,0,0,1]) |
---|
86 | # m.drawparallels(np.arange(-90.,90.,45.), color='#909090', linewidth=1.0, zorder=None, dashes=[1, 1]) |
---|
87 | plt.show() |
---|
88 | plt.savefig('test_sorties_arome.png') |
---|
89 | #close() |
---|
90 | |
---|
91 | |
---|