Changeset 558 for trunk


Ignore:
Timestamp:
Mar 4, 2012, 9:24:59 PM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON: moved corrected ECMWF stuff for simple use in the main PYTHON directory. corrected planetoplot so that output files from ECMWF can be used. added a more general treatment of lat/lon prescription.

Location:
trunk/UTIL/PYTHON
Files:
1 added
1 deleted
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myecmwf.py

    r546 r558  
    77        elif var == "130": name="Atmospheric Temperature (K)"           # ["130", "an", "0", "pl" ]
    88        elif var == "167": name="2m Atmospheric Temperature (K)"        # ["167", "fc", "3", "sfc"]
    9         elif var == "78": name="Total column liquid water (kg/kg)"
     9        elif var == "78":  name="Total column liquid water (kg/kg)"
    1010        elif var == "137": name="Total column water vapour (kg/m2)"
     11        else:              name=""
    1112        return name
    1213
     
    2223        return varchar
    2324
    24 def get_ecmwf (var, dataset, wlat, wlon, lev, date, tim):
     25def get_ecmwf (var, fieldtype, wlat, wlon, lev, date, tim):
    2526        from ecmwf      import ECMWFDataServer
    2627        from os         import system
    2728        from netCDF4    import Dataset
    2829        gbfile = 'output.grib'
    29         ncfile = 'output.nc'
     30        #ncfile = str(date[2]) + str(date[1]) + str(date[0]) + str(date[5]) + str(date[4]) + str(date[3])+'.nc'
     31        ncfile = 'output.nc'
     32        ######
     33        if fieldtype == "3d":   
     34            dataset = ["an","pl","0"]
     35        elif fieldtype == "2d": 
     36            dataset = ["fc","sfc","3"]
     37            lev = [9999.]
    3038        ######
    3139        timchar = split_char (tim)
  • trunk/UTIL/PYTHON/myplot.py

    r548 r558  
    4343    elif hasattr(nc,'START_DATE'):             typefile = 'meso'
    4444    elif 'HGT_M' in nc.variables:              typefile = 'geo'
     45    elif hasattr(nc,'institution'):
     46      if "European Centre" in getattr(nc,'institution'):  typefile = 'ecmwf'
    4547    else:                                      typefile = 'gcm' # for lslin-ed files from gcm
    4648    return typefile
     
    449451    elif typefile in ['gcm']:
    450452        [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True)
    451     elif typefile in ['earthgcm']:
     453    elif typefile in ['earthgcm','ecmwf']:
    452454        [lon2d,lat2d] = getcoord2d(nc,nlat="lat",nlon="lon",is1d=True)
    453455    elif typefile in ['geo']:
     
    886888                "jupiter":     "http://www.mmedia.is/~bjj/data/jupiter_css/jupiter_css.jpg",\
    887889                "jupiter_voy": "http://www.mmedia.is/~bjj/data/jupiter/jupiter_vgr2.jpg",\
     890                #"bw":          domain+"EarthElevation_2500x1250.jpg",\
    888891                "bw":          "http://users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/EarthElevation_2500x1250.jpg",\
    889892                "contrast":    "http://users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/EarthMapAtmos_2500x1250.jpg",\
  • trunk/UTIL/PYTHON/planetoplot.py

    r548 r558  
    160160         else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
    161161         if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom)
    162          elif zarea is not None: [wlon,wlat] = latinterv(area=zarea)
     162         elif zarea is not None:           [wlon,wlat] = latinterv(area=zarea)
    163163
    164164##########################################################
    165165############ LOAD 4D DIMENSIONS : x, y, z, t #############
    166166##########################################################
    167       if typefile in ["gcm","earthgcm"]:
    168           ### SPACE
    169           if typefile == "gcm":         lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:] ; vert = nc.variables["altitude"][:]
    170           elif typefile == "earthgcm":  lat = nc.variables["lat"][:] ; lon = nc.variables["lon"][:] ; vert = nc.variables["Alt"][:]
    171           if "aire" in nc.variables:      area = nc.variables["aire"][:,:]  #JL to weight means with the area
     167      if typefile in ["gcm","earthgcm","ecmwf"]:
     168          ### LAT
     169          if "latitude" in nc.variables:  lat = nc.variables["latitude"][:]
     170          elif "lat" in nc.variables:     lat = nc.variables["lat"][:]
     171          ### LON
     172          if "longitude" in nc.variables: lon = nc.variables["longitude"][:]
     173          elif "lon" in nc.variables:     lon = nc.variables["lon"][:]
     174          ### ALT
     175          if "altitude" in nc.variables:  vert = nc.variables["altitude"][:]
     176          elif "Alt" in nc.variables:     vert = nc.variables["Alt"][:]
     177          elif "lev" in nc.variables:     vert = nc.variables["lev"][:]
     178          else:                           vert = [0.]
     179          ### AIRE (to weight means with the area)
     180          if "aire" in nc.variables:      area = nc.variables["aire"][:,:] 
    172181          else:                           area = None
    173182          ### TIME
Note: See TracChangeset for help on using the changeset viewer.