Changeset 2744 in lmdz_wrf for trunk


Ignore:
Timestamp:
Nov 4, 2019, 2:33:42 PM (6 years ago)
Author:
lfita
Message:

Adding into `mapFigure', the use of 'DefineMap?'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing_tools.py

    r2743 r2744  
    44014401            m = DefineMap(map_proj, map_res, [lat2, lon2])
    44024402        elif map_proj == 'spstere':
    4403             if len(mapv.split(',')) > 2:
     4403            Nvals = len(mapv.split(','))
     4404            if Nvals > 2:
     4405                expected = ['xlat', 'ref_lon']
     4406                Nexpected = len(expected)
     4407                if Nvals - 2 != Nexpected:
     4408                    print errormsg
     4409                    print '  ' + fname + ": additional values provided for '" +      \
     4410                      map_proj + "' but ", Nexpected, "where expected and", Nvals,   \
     4411                      "provided"
     4412                    print '    one epxect to additinoaly have:', ','.join(expected)
     4413                    quit(-1)
    44044414                xlat = np.float(mapv.split(',')[2])
    44054415                ref_lon = np.float(mapv.split(',')[3])
    44064416                m = DefineMap(map_proj, map_res, [xlat, ref_lon])
    44074417            else:
    4408                 m = DefineMap(map_proj, map_res, [xlat, -65.])
     4418                m = DefineMap(map_proj, map_res, [xlat, lon2])
    44094419        else:
    44104420            print errormsg
     
    44304440        Nboxes = len(boxesX)/4
    44314441        for ibox in range(Nboxes):
    4432             print ibox, boxesX[ibox], boxesY[ibox]
    4433             plt.plot(boxesX[ibox*4], boxesY[ibox*4], linestyle='-', linewidth=3,     \
     4442            xi, yi = m(boxesX[ibox*4], boxesY[ibox*4])
     4443            plt.plot(xi, yi, linestyle='-', linewidth=3,                             \
    44344444              label=gen.latex_text(boxlabels[ibox].replace('!',' ')), color=cols[ibox])
    4435             plt.plot(boxesX[ibox*4+1], boxesY[ibox*4+1], linestyle='-', linewidth=3, \
    4436               color=cols[ibox])
    4437             plt.plot(boxesX[ibox*4+2], boxesY[ibox*4+2], linestyle='-', linewidth=3, \
    4438               color=cols[ibox])
    4439             plt.plot(boxesX[ibox*4+3], boxesY[ibox*4+3], linestyle='-', linewidth=3, \
    4440               color=cols[ibox])
    4441 
    4442             lonlatb = [boxesX[ibox][0], boxesY[ibox][0], boxesX[ibox*4+2][0],        \
    4443               boxesY[ibox*4+2][0]]
    4444             labv = [gen.latex_text(boxlabels[ibox].replace('!',' ')), ]
    4445             drawpolygon_map(lonlatb, m, labv, 10, ['k', 2, '-'])
     4445            xi, yi = m(boxesX[ibox*4+1], boxesY[ibox*4+1])
     4446            plt.plot(xi, yi, linestyle='-', linewidth=3, color=cols[ibox])
     4447            xi, yi = m(boxesX[ibox*4+2], boxesY[ibox*4+2])
     4448            plt.plot(xi, yi, linestyle='-', linewidth=3, color=cols[ibox])
     4449            xi, yi = m(boxesX[ibox*4+3], boxesY[ibox*4+3])
     4450            plt.plot(xi, yi, linestyle='-', linewidth=3, color=cols[ibox])
    44464451
    44474452        m.drawcoastlines()
     
    1426714272
    1426814273    if map_proj == 'cyl':
    14269       mapenv = Basemap(projection=map_proj, llcrnrlon=nlon, llcrnrlat=nlat,          \
    14270         urcrnrlon=xlon, urcrnrlat= xlat, resolution=map_res)
     14274        mapenv = DefineMap(map_proj, map_res, [nlon,nlat,xlon,xlat])
    1427114275    elif map_proj == 'lcc':
    14272       mapenv = Basemap(projection=map_proj, lat_0=lat2, lon_0=lon2, llcrnrlon=nlon,  \
    14273         llcrnrlat=nlat, urcrnrlon=xlon, urcrnrlat= xlat, resolution=map_res)
    14274     else:
    14275       print gen.errormsg
    14276       print '  ' + fname + ": map projection '" + map_proj + "' not defined!!!"
    14277       print '    available: cyl, lcc'
    14278       quit(-1)
     14276        mapenv = DefineMap(map_proj, map_res, [lat2, lon2, nlon, nlat, xlon, xlat])
     14277    elif map_proj == 'npstere':
     14278        mapenv = DefineMap(map_proj, map_res, [lat2, lon2])
     14279    elif map_proj == 'spstere':
     14280        Nvals = len(mapvals.split(','))
     14281        if Nvals > 2:
     14282            expected = ['xlat', 'ref_lon']
     14283            Nexpected = len(expected)
     14284            if Nvals - 2 != Nexpected:
     14285                print errormsg
     14286                print '  ' + fname + ": additional values provided for '" +      \
     14287                  map_proj + "' but ", Nexpected, "where expected and", Nvals,   \
     14288                  "provided"
     14289                print '    one epxect to additinoaly have:', ','.join(expected)
     14290                quit(-1)
     14291            xlat = np.float(mapvals.split(',')[2])
     14292            ref_lon = np.float(mapvals.split(',')[3])
     14293            mapenv = DefineMap(map_proj, map_res, [xlat, ref_lon])
     14294        else:
     14295            mapenv = DefineMap(map_proj, map_res, [xlat, lon2])
     14296    else:
     14297        print errormsg
     14298        print '  ' + fname + ": projection '" + map_proj + "' not ready !!"
     14299        quit(-1)
    1427914300
    1428014301    merids = gen.pretty_int(nlon, xlon, Nlon)
     
    1440814429      polylabv: [polylab, color, size, face, angle, pos]: values for the label of
    1440914430          the polygon. if color='auto', then:
    14410             [polylab, 'k', 10, 'normal', angle=0, pos='c']
     14431            [polylab, 'k', 10, 'normal', 0, 'c']
    1441114432        polylab: label of the polygon (already LaTeX freindly, None for no label)
    1441214433        color: color of the characters
     
    1447414495    if polylabv is not None:
    1447514496        if polylabv[1] == 'auto':
    14476            polylabv = [polylabv[0], 'k', 10, 'normal', angle=0, pos='c']
     14497           polylabv = [polylabv[0], 'k', 10, 'normal', 0, 'c']
    1447714498        polylabpos = polylabv[5].split(',')
    1447814499        if polylabpos[0] == 'c':
     
    1457414595      closeif= Boolean value if the figure has to be closed
    1457514596    """
    14576     fname = 'plot_topofix_geogrid'
     14597    fname = 'plot_topofix_geogrid_boxes'
    1457714598
    1457814599    topobnds=[-140., 0., 100., 200., 300., 400., 500., 600., 700., 800., 900., 1000.,\
     
    1458614607    if type(varv) == type('S') and varv == 'h':
    1458714608        print fname + '_____________________________________________________________'
    14588         print plot_topofix_geogrid.__doc__
     14609        print plot_topofix_geogrid_boxes.__doc__
    1458914610        quit()
    1459014611
Note: See TracChangeset for help on using the changeset viewer.