Changeset 781 in lmdz_wrf for trunk/tools/drawing.py


Ignore:
Timestamp:
May 27, 2016, 6:15:05 PM (9 years ago)
Author:
lfita
Message:

Creation a working version of `draw_basins'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r776 r781  
    33333333
    33343334def draw_basins(ncfile, values, varns):
     3335    """ Function to plot wind basins
     3336      values= [lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:[veclength]:[freq]:
     3337        [ifreq]:[gtit]:[kindfig]:[figuren]
     3338        [lonlatbox]= [lonSW],[lonNE],[latSW],[latNE] coordinates of the lon/lat box
     3339        [xtrmbasin]= pminbasin],[maxbasin]
     3340        gtit= title of the graph ('|', for spaces)
     3341        kindfig= kind of figure
     3342        figuren= name of the figure
     3343      ncfile= file to use
     3344    """
     3345    fname = 'draw_basins'
     3346
     3347    if values == 'h':
     3348        print fname + '_____________________________________________________________'
     3349        print draw_vectors.__doc__
     3350        quit()
     3351
     3352    expectargs = '[lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:' +          \
     3353      '[veclength]:[freq]:[ifreq]:[gtit]:[kindfig]:[figuren]'
     3354 
     3355    drw.check_arguments(fname,values,expectargs,':')
     3356
     3357    varn='basins'
     3358    lonname = 'nav_lon'
     3359    latname = 'nav_lat'
     3360    flowname = 'trip'
     3361
     3362    lonlims =[]
     3363    latlims =[]
     3364
     3365    lonlims.append(np.float(values.split(':')[0].split(',')[0]))
     3366    lonlims.append(np.float(values.split(':')[0].split(',')[1]))
     3367    latlims.append(np.float(values.split(':')[0].split(',')[2]))
     3368    latlims.append(np.float(values.split(':')[0].split(',')[3]))
     3369    map_res = values.split(':')[1]
     3370    cbarname = values.split(':')[2]
     3371    vtit = 'basins'
     3372    minbasin = np.int(values.split(':')[3].split(',')[0])
     3373    maxbasin = np.int(values.split(':')[3].split(',')[1])
     3374    mapdraw0 = gen.Str_Bool(values.split(':')[4])
     3375    veclength = np.float(values.split(':')[5])
     3376    freq0 = values.split(':')[6]
     3377    ifreq = int(values.split(':')[7])
     3378    gtit = values.split(':')[8].replace('|',' ')
     3379    kindfig = values.split(':')[9]
     3380    figuren = values.split(':')[10]
     3381
     3382    if freq0 == 'None': freq = None
     3383
     3384    ofile = NetCDFFile(ncfile, 'r')
     3385
     3386    obasins = ofile.variables[varn]
     3387    olon = ofile.variables[lonname]
     3388    olat = ofile.variables[latname]
     3389    oflow = ofile.variables[flowname]
     3390
     3391    lons = olon[:]
     3392    lats = olat[:]
     3393
     3394    lon, lat = drw.lonlat2D(lons, lats)
     3395
     3396    nlon = lonlims[0]
     3397    xlon = lonlims[1]
     3398    nlat = latlims[0]
     3399    xlat = latlims[1]
     3400
     3401    imin, imax, jmin, jmax = gen.ijlonlat(lon, lat, nlon, xlon, nlat, xlat)
     3402
     3403    drw.plot_basins(lon[jmin:jmax,imin:imax], lat[jmin:jmax,imin:imax],              \
     3404      oflow[jmin:jmax,imin:imax], freq, cbarname+'@basin@-',                         \
     3405      obasins[jmin:jmax,imin:imax], veclength, minbasin, maxbasin, 'outflow', '-',   \
     3406      'cyl,'+map_res, gtit, kindfig, figuren)
     3407
     3408    ofile.close()
     3409
     3410    return
     3411
     3412def draw_basinsold(ncfile, values, varns):
    33353413    """ Function to plot wind basins
    33363414      values= [dimname]|[vardimname]|[value]:[vecvals]:[windlabs]:[mapvalues]:
Note: See TracChangeset for help on using the changeset viewer.