Changeset 2757 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Nov 13, 2019, 4:21:26 PM (5 years ago)
Author:
lfita
Message:

Fixing errors
Adding:

  • `begend_spaces': Function to remove any spaces at the beginning and end of an String
Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r2751 r2757  
    25702570
    25712571    timename = timevals.split('|')[0]
    2572     timekind = timevals.split('|')[1]
    2573     timefmt = timevals.split('|')[2]
     2572    timekind = timevals.split('|')[2]
     2573    timefmt = timevals.split('|')[3]
    25742574
    25752575    if rangevals == 'None':
     
    27652765
    27662766        if ifn == 0:
    2767             varunits = drw.units_lunits(vvobj0.units)
     2767            varunits = gen.units_lunits(vvobj0.units)
    27682768        else:
    2769             if varunits != drw.units_lunits(vvobj0.units):
     2769            if varunits != gen.units_lunits(vvobj0.units):
    27702770                print errormsg
    27712771                print '  ' + fname + ': wrong units:', vvobj0.units, " of " +        \
     
    27952795    print '  ' + fname + ': plotting from: ' + dtiS + ' to ' + dteS
    27962796
    2797     timepos, timelabels = drw.CFtimes_plot(tvals, timeunit, timekind, timefmt)
     2797    tU = timeunit.replace('!', ' ')
     2798    print timeunit, timekind, timefmt
     2799    timepos, timelabels = drw.CFtimes_plot(tvals, tU, timekind, timefmt)
    27982800
    27992801#    print 'Lluis min/max tval +/- dtval/2:', mintval-dtvals/2., maxtval+dtvals/2.,'dt:', len(tvals)
  • trunk/tools/drawing_tools.py

    r2755 r2757  
    19281928        fontsize = int(fontsize0)
    19291929    if len(legstring.split(char)) == 2:
    1930         return locleg, fontsize
     1930        return locleg, fontsize, 1
    19311931    else:
    19321932        ncol = int(legstring.split(char)[2])
  • trunk/tools/generic_tools.py

    r2734 r2757  
    7777# auto_val: Function to provide a value following an 'auto' configuration
    7878# auto_val_list: Function to provide a list of values following an 'auto' configuration or a single value
     79# begend_spaces: Function to remove any spaces at the beginning and end of an String
    7980# Capturing: Class to capture the standard output from a function
    8081# CF_gribequiv: Function to provide the GRIB variable code number from a CF name
     
    594595
    595596    return sign
     597
     598def begend_spaces(Str):
     599    """ Function to remove any spaces at the beginning and end of an Sting
     600      Str: string to remove spaces
     601    >>> begend_spaces(' Antartic ')
     602    'Antartic'
     603    """
     604    fname = 'begend_spaces'
     605
     606    newstring=''
     607    Nchars = len(Str)
     608    Hspace = True
     609    for ic in range(Nchars):
     610        if Hspace:
     611            if Str[ic:ic+1] == ' ':
     612                newstring = ''
     613            else:
     614                newstring = newstring + Str[ic:ic+1]
     615                Hspace = False
     616        else:
     617            newstring = newstring + Str[ic:ic+1]
     618
     619    Tspace = True
     620    newstring2 = ''
     621    for ic in range(Nchars-2,-1,-1):
     622        if Tspace:
     623            if newstring[ic:ic+1] == ' ':
     624                newstring2 = ''
     625            else:
     626                newstring2 = newstring[ic:ic+1] + newstring2
     627                Tspace = False
     628        else:
     629            newstring2 = newstring[ic:ic+1] + newstring2
     630
     631    return newstring2
    596632
    597633##
     
    1731717353      'U', 'U']
    1731817354
     17355    print " Lluis '" + stval +  "' "
     17356
    1731917357    if stcrit == 'h':
    1732017358        print fname + '_____________________________________________________________'
     
    1734417382    Nst = 0
    1734517383    stations = {}
     17384    availvals = []
    1734617385    for line in ncf:
    1734717386        if line[0:1] != '#' and len(line) > 10:
     
    1735417393
    1735517394            stvalues = list_listKs(values, stKs)
    17356             if stvalues[icrit] == stv:
     17395            if not searchInlist(availvals, stvalues[icrit]):
     17396                availvals.append(stvalues[icrit])
     17397            print "'" + stvalues[icrit] + "'", "'"+ stv+ "'", type(stvalues[icrit]), type(stv), stvalues[icrit] == stv
     17398            if stvalues[icrit] == stv:
    1735717399                stations[Nst] = stvalues
    1735817400                Nst = Nst + 1
     
    1736017402    if Nst == 0:
    1736117403        print errormsg
    17362         print '  ' + fname + ": station with criteria '" + stcrit + "'= '", stval,   \
    17363           "' not found !!!"
     17404        if type (stval) == type('H'):
     17405            print '  ' + fname + ": station with criteria '" + stcrit + "'= '" +     \
     17406              stval + "' not found !!!"
     17407        else:
     17408            print '  ' + fname + ": station with criteria '" + stcrit + "'= '",      \
     17409              stval, "' not found !!!"
     17410        print '    available ones', availvals
    1736417411        ncf.close()
    1736517412        if Notfound:
     
    1738517432    return stations
    1738617433
     17434print stations_values('prov', 'Antartic')
     17435quit()
     17436
    1738717437def list_rmchar(listv, rmchr):
    1738817438    """ Function to remove a list of characters from its values
Note: See TracChangeset for help on using the changeset viewer.