Index: trunk/UTIL/PYTHON/create_ecmwf.py
===================================================================
--- trunk/UTIL/PYTHON/create_ecmwf.py	(revision 558)
+++ trunk/UTIL/PYTHON/create_ecmwf.py	(revision 558)
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+##########################################################################
+#var = ["151","146","167"]
+#var = ["167"]
+##var = ["78"]
+##var = ["137"]
+##var = ["174"] albedo marche pas.
+#var = ["134","151"] 
+#fieldtype = "2d"
+##var = ["130"]
+#lev = ["700.","850."]
+#tim = ["00"]
+#date = ['10','08','2010','10','08','2010']
+#date = ['01','09','2009','01','09','2009']
+##date = ['01','09','2010','01','09','2010']
+#area = "Whole"
+###########################################################################
+
+
+##########################################################################
+######### FIGURES DE LA PRESSION
+var = ["134","151"]
+fieldtype = "2d"
+lev = ["9999."]
+tim = ["00"]
+date = ['01','09','2009','01','09','2009']
+area = "Whole"
+##########################################################################
+
+##########################################################################
+from myplot import latinterv
+from myecmwf import get_ecmwf
+from os import system
+##########################################################################
+[wlon,wlat] = latinterv(area)
+nc = get_ecmwf (var, fieldtype, wlat, wlon, lev, date, tim) 
+system("cp -f create_ecmwf.py output.py")
Index: trunk/UTIL/PYTHON/ecmwf.py
===================================================================
--- trunk/UTIL/PYTHON/ecmwf.py	(revision 558)
+++ trunk/UTIL/PYTHON/ecmwf.py	(revision 558)
@@ -0,0 +1,101 @@
+import urllib
+import urllib2
+import time
+import datetime
+
+class ECMWFDataServer:
+    def __init__(self,portal,token,email):
+        self.version = '0.3'
+        self.portal  = portal
+        self.token   = token
+        self.email   = email
+
+    def _call(self,action,args):
+
+        params = {'_token'   : self.token,
+                  '_email'   : self.email,
+                  '_action'  : action,
+                  '_version' : self.version}
+        params.update(args)
+            
+        data = urllib.urlencode(params)
+        req = urllib2.Request(self.portal, data)
+        response = urllib2.urlopen(req)
+
+        json = response.read();
+
+        undef = None;
+        json = eval(json)
+
+        if json != None:
+            if 'error' in json:
+                raise RuntimeError(json['error'])
+            if 'message' in json:
+                self.put(json['message'])
+
+        return json
+
+    def put(self,*args):
+        print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
+        for a in args:
+            print a,
+        print
+
+        
+    def retrieve(self,args):
+        self.put("ECMWF data server batch tool version",self.version);
+        user = self._call("user_info",{});
+        self.put("Welcome to",user['name'], "from" , user['organisation']);
+
+        r = self._call('retrieve',args)
+        rid = r['request']
+
+        last  = ''
+        sleep = 0
+        while r['status'] != 'complete' and r['status'] != 'aborted':
+            text = r['status'] + '.'
+            if 'info' in r and r['info'] != None:
+                text = text + ' ' + r['info'] 
+
+            if text != last:
+                self.put("Request",text)
+                last = text
+
+            time.sleep(sleep)
+            r = self._call('status',{'request':rid})
+            if sleep < 60:
+                sleep = sleep + 1
+
+        if r['status'] != last:
+            self.put("Request",r['status'])
+
+        if 'reason' in r:
+            for m in r['reason']:
+                self.put(m)
+
+        if 'result' in r:
+            size = long(r['size'])
+            self.put("Downloading",self._bytename(size))
+            done = self._transfer(r['result'],args['target'])
+            self.put("Done")
+            if done != size:
+                raise RuntimeError("Size mismatch: " + str(done) + " and " + str(size))
+
+        self._call('delete',{'request':rid})
+        
+        if r['status'] == 'aborted':
+            raise RuntimeError("Request aborted")
+        
+    def _transfer(self,url,path):
+        result =  urllib.urlretrieve(url,path)
+        return long(result[1]['content-length'])
+        
+    def _bytename(self,size):   
+        next = {'':'K','K':'M','M':'G','G':'T','T':'P'}
+        l    = ''
+        size = size*1.0
+        while 1024 < size:
+            l = next[l]
+            size = size / 1024
+        return "%g %sbyte%s" % (size,l,'s')
+
Index: trunk/UTIL/PYTHON/examples/map.py
===================================================================
--- trunk/UTIL/PYTHON/examples/map.py	(revision 558)
+++ trunk/UTIL/PYTHON/examples/map.py	(revision 558)
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+from myplot import latinterv, define_proj, makeplotres
+[wlon,wlat] = latinterv("Africa")
+define_proj("ortho",wlon,wlat,back="blueclouds")
+makeplotres("blueclouds",ext='ps')
+define_proj("ortho",wlon,wlat,back="blue")
+makeplotres("blue",ext='ps')
+define_proj("ortho",wlon,wlat,back="justclouds")
+makeplotres("justclouds",ext='ps')
+
Index: trunk/UTIL/PYTHON/examples/map_ecmwf.py
===================================================================
--- trunk/UTIL/PYTHON/examples/map_ecmwf.py	(revision 558)
+++ trunk/UTIL/PYTHON/examples/map_ecmwf.py	(revision 558)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+##########################################################################
+var = ["151","146","167"]
+var = ["167"]
+var = ["78"]
+var = ["137"]
+#var = ["174"] albedo marche pas.
+lev = ["700.","850."]
+tim = ["00"]
+date = ['10','08','2010','10','08','2010']
+date = ['01','09','2009','01','09','2009']
+#date = ['01','09','2010','01','09','2010']
+dataset = ["an","pl","0"]
+dataset = ["fc","sfc","3"]
+##########################################################################
+proj = "cyl"  #"moll" "ortho" "lcc"
+#proj = "ortho"
+#proj = "moll"
+area = "Europe"
+area = "Africa"
+area = "Central_America"
+#area = "Southern_Hemisphere"
+#area = "Northern_Hemisphere"
+#area = "Whole_No_High"
+area = "Whole"
+back="blue"
+#back="bw"
+#back="moc"
+##########################################################################
+
+
+##########################################################################
+import 	numpy 				as np
+import 	matplotlib.pyplot 		as plt
+import  myplot				as myp
+import  myecmwf				as mye
+##########################################################################
+if dataset[1] == "sfc": lev = [9999.]
+[wlon,wlat] = myp.latinterv(area)
+nc = mye.get_ecmwf (var, dataset, wlat, wlon, lev, date, tim) 
+##########################################################################
+[lon2d,lat2d] = myp.getcoord2d (nc,nlat='lat',nlon='lon',is1d=True)
+step=10.
+##########################################################################
+ntime = 0
+for i in range( np.array(var).size ):
+	for z in range( np.array(lev).size ):
+		for t in range( np.array(tim).size ):
+
+                    field, error = myp.reducefield( myp.getfield(nc,'var'+var[i]), d4=t, d3=z )
+                    if not error:
+                        ### Map projection
+                        m = myp.define_proj(proj,wlon,wlat,back=back)
+                        x, y = m(lon2d, lat2d)
+		        zeplot = m.contour(x, y, field, 10) #15
+		        plt.clabel(zeplot, inline=1, inline_spacing=1, fontsize=7, fmt='%0i')
+		        #plt.colorbar(fraction=0.05,pad=0.1)
+		        plt.title(mye.ecmwf_title_field(var[i]))
+                        myp.makeplotres(str(var[i])+str(lev[z])+str(tim[t]),res=100.,pad_inches_value=0.35)
Index: trunk/UTIL/PYTHON/myecmwf.py
===================================================================
--- trunk/UTIL/PYTHON/myecmwf.py	(revision 558)
+++ trunk/UTIL/PYTHON/myecmwf.py	(revision 558)
@@ -0,0 +1,61 @@
+def ecmwf_title_field (var):
+	### http://www.ecmwf.int/services/archive/d/table/grib_table_2_versions
+	### http://www.ecmwf.int/services/archive/d/parameters/mars=1/order=grib_parameter/table=128/
+	### http://www.atmos.albany.edu/facstaff/rmctc/ecmwfGrib/ecmwfgrib128.tbl
+	if   var == "151": name="Mean Sea Level Pressure (Pa)"          # ["151", "fc", "3", "sfc"]
+	elif var == "146": name="Sensible Heat Flux (W m^-2)"           # ["146", "fc", "3", "sfc"]
+	elif var == "130": name="Atmospheric Temperature (K)"           # ["130", "an", "0", "pl" ]
+	elif var == "167": name="2m Atmospheric Temperature (K)"        # ["167", "fc", "3", "sfc"]
+        elif var == "78":  name="Total column liquid water (kg/kg)"
+        elif var == "137": name="Total column water vapour (kg/m2)"
+        else:              name=""
+	return name
+
+def split_char_add (var,add):
+	import  numpy as np
+	varchar = ""
+	for i in range( np.array(var).size ):
+		varchar = varchar + str(var[i]) + add + "/"
+	return varchar
+
+def split_char (var):
+	varchar = split_char_add (var,"")
+	return varchar
+
+def get_ecmwf (var, fieldtype, wlat, wlon, lev, date, tim):
+	from ecmwf 	import ECMWFDataServer
+	from os		import system
+	from netCDF4	import Dataset
+	gbfile = 'output.grib'
+	#ncfile = str(date[2]) + str(date[1]) + str(date[0]) + str(date[5]) + str(date[4]) + str(date[3])+'.nc'
+        ncfile = 'output.nc'
+        ######
+        if fieldtype == "3d":    
+            dataset = ["an","pl","0"]
+        elif fieldtype == "2d":  
+            dataset = ["fc","sfc","3"]
+            lev = [9999.]
+	######
+	timchar = split_char (tim)
+	levchar = split_char (lev)
+	varchar = split_char_add (var,".128")
+	##########################################################################
+	## First registrer at http://data-portal.ecmwf.int/data/d/license/interim/
+	## Then get your token at http://data-portal.ecmwf.int/data/d/token/interim_daily/
+	server = ECMWFDataServer('http://data-portal.ecmwf.int/data/d/dataserver/','6948746482e9e3e29d64211e06329a2e','spiga@lmd.jussieu.fr')
+	server.retrieve({
+		'dataset'  : "interim_daily",
+		'date'     : date[2] + date[1] + date[0] + "/to/" + date[5] + date[4] + date[3],
+		'time'     : timchar,
+		'step'     : dataset[2],
+		'levtype'  : dataset[1],
+		'type'     : dataset[0],
+		'param'    : varchar,
+		'levelist' : levchar,   
+		'area'     : str(wlat[0])+"/"+str(wlon[0])+"/"+str(wlat[1])+"/"+str(wlon[1]),
+		'target'   : gbfile
+	})
+	system("cdo -f nc copy "+gbfile+" "+ncfile+" ; rm -f "+gbfile)
+	nc = Dataset(ncfile)
+	#system("rm -f "+ncfile)
+	return nc
Index: trunk/UTIL/PYTHON/myplot.py
===================================================================
--- trunk/UTIL/PYTHON/myplot.py	(revision 548)
+++ trunk/UTIL/PYTHON/myplot.py	(revision 558)
@@ -43,4 +43,6 @@
     elif hasattr(nc,'START_DATE'):             typefile = 'meso' 
     elif 'HGT_M' in nc.variables:              typefile = 'geo'
+    elif hasattr(nc,'institution'):
+      if "European Centre" in getattr(nc,'institution'):  typefile = 'ecmwf'
     else:                                      typefile = 'gcm' # for lslin-ed files from gcm
     return typefile
@@ -449,5 +451,5 @@
     elif typefile in ['gcm']: 
         [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True)
-    elif typefile in ['earthgcm']: 
+    elif typefile in ['earthgcm','ecmwf']: 
         [lon2d,lat2d] = getcoord2d(nc,nlat="lat",nlon="lon",is1d=True)
     elif typefile in ['geo']:
@@ -886,4 +888,5 @@
                 "jupiter":     "http://www.mmedia.is/~bjj/data/jupiter_css/jupiter_css.jpg",\
                 "jupiter_voy": "http://www.mmedia.is/~bjj/data/jupiter/jupiter_vgr2.jpg",\
+                #"bw":          domain+"EarthElevation_2500x1250.jpg",\
                 "bw":          "http://users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/EarthElevation_2500x1250.jpg",\
                 "contrast":    "http://users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/EarthMapAtmos_2500x1250.jpg",\
Index: trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- trunk/UTIL/PYTHON/planetoplot.py	(revision 548)
+++ trunk/UTIL/PYTHON/planetoplot.py	(revision 558)
@@ -160,14 +160,23 @@
          else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
          if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom)
-         elif zarea is not None: [wlon,wlat] = latinterv(area=zarea)
+         elif zarea is not None:           [wlon,wlat] = latinterv(area=zarea)
 
 ##########################################################
 ############ LOAD 4D DIMENSIONS : x, y, z, t #############
 ##########################################################
-      if typefile in ["gcm","earthgcm"]:
-          ### SPACE
-          if typefile == "gcm":         lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:] ; vert = nc.variables["altitude"][:]
-          elif typefile == "earthgcm":  lat = nc.variables["lat"][:] ; lon = nc.variables["lon"][:] ; vert = nc.variables["Alt"][:]
-          if "aire" in nc.variables:      area = nc.variables["aire"][:,:]  #JL to weight means with the area
+      if typefile in ["gcm","earthgcm","ecmwf"]:
+          ### LAT
+          if "latitude" in nc.variables:  lat = nc.variables["latitude"][:]
+          elif "lat" in nc.variables:     lat = nc.variables["lat"][:]
+          ### LON
+          if "longitude" in nc.variables: lon = nc.variables["longitude"][:]
+          elif "lon" in nc.variables:     lon = nc.variables["lon"][:]
+          ### ALT
+          if "altitude" in nc.variables:  vert = nc.variables["altitude"][:]
+          elif "Alt" in nc.variables:     vert = nc.variables["Alt"][:]
+          elif "lev" in nc.variables:     vert = nc.variables["lev"][:]
+          else:                           vert = [0.]
+          ### AIRE (to weight means with the area)
+          if "aire" in nc.variables:      area = nc.variables["aire"][:,:]  
           else:                           area = None
           ### TIME
