Changeset 1371 in lmdz_wrf


Ignore:
Timestamp:
Dec 6, 2016, 11:28:51 AM (8 years ago)
Author:
lfita
Message:

Adding:

`smean': spatial-weighted mean values
making use of `gen.Str_Bool' on scratch, add definitions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1363 r1371  
    119119    fname = 'scratches'
    120120
    121     if config['scratch'] == 'true':
     121    if gen.Str_Bool(config['scratch']):
    122122        scr = True
    123123        print warnmsg
     
    134134    else:
    135135        scr = False
    136         if config['filescratch'] == 'true':
     136        if gen.Str_Bool(config['filescratch']):
    137137            filescr = True
    138138            print warnmsg
     
    143143            filescr = False
    144144
    145         if config['figscratch'] == 'true':
     145        if gen.Str_Bool(config['figscratch']):
    146146            figscr = True
    147147            print warnmsg
     
    152152            figscr = False
    153153
    154         if config['diffscratch'] == 'true':
     154        if gen.Str_Bool(config['diffscratch']):
    155155            difscr = True
    156156            print warnmsg
     
    161161            difscr = False
    162162
    163         if config['figdiffscratch'] == 'true':
     163        if gen.Str_Bool(config['figdiffscratch']):
    164164            figdifscr = True
    165165            print warnmsg
     
    170170            figdifscr = False
    171171
    172         if config['moddiffscratch'] == 'true':
     172        if gen.Str_Bool(config['moddiffscratch']):
    173173            moddifscr = True
    174174            print warnmsg
     
    179179            moddifscr = False
    180180
    181         if config['figmoddiffscratch'] == 'true':
     181        if gen.Str_Bool(config['figmoddiffscratch']):
    182182            figmoddifscr = True
    183183            print warnmsg
     
    188188            figmoddifscr = False
    189189
    190         if config['figallmodexpscratch'] == 'true':
     190        if gen.Str_Bool(config['figallmodexpscratch']):
    191191            figallmodexpscr = True
    192192            print warnmsg
     
    197197            figallmodexpscr = False
    198198
    199     if config['addall'] == 'true':
     199    if gen.Str_Bool(config['addall']):
    200200        print warnmsg
    201201        print "  " + fname + ": adding new values everywhere !!"
     
    208208        addallmodexpfigs = True
    209209    else:
    210         if config['addfiles'] == 'true':
    211             addfils = True
    212         else:
    213             addfils = False
    214 
    215         if config['addfigures'] == 'true':
    216             addfigs = True
    217         else:
    218             addfigs = False
    219 
    220         if config['adddiffs'] == 'true':
    221             adddiffs = True
    222         else:
    223             adddiffs = False
    224 
    225         if config['adddifffigures'] == 'true':
    226             adddifffigs = True
    227         else:
    228             adddifffigs = False
    229 
    230         if config['addmoddiffs'] == 'true':
    231             addmoddiffs = True
    232         else:
    233             addmoddiffs = False
    234 
    235         if config['addmoddifffigures'] == 'true':
    236             addmoddifffigs = True
    237         else:
    238             addmoddifffigs = False
    239 
    240         if config['addallmodexpfigures'] == 'true':
    241             addallmodexpfigs = True
    242         else:
    243             addallmodexpfigs = False
    244 
    245     if config['debug'] == 'true':
    246         debug = True
    247     else:
    248         debug = False
     210        addfils = gen.Str_Bool(config['addfiles'])
     211        addfigs = gen.Str_Bool(config['addfigures'])
     212        adddiffs = gen.Str_Bool(config['adddiffs'])
     213        adddifffigs = gen.Str_Bool(config['adddifffigures'])
     214        addmoddiffs = gen.Str_Bool(config['addmoddiffs'])
     215        addmoddifffigs =  gen.Str_Bool(config['addmoddifffigures'])
     216        addallmodexpfigs = gen.Str_Bool(config['addallmodexpfigures'])
     217
     218    debug = gen.Str_Bool(config['debug'])
    249219
    250220    return scr, filescr, figscr, difscr, figdifscr, moddifscr, figmoddifscr,         \
     
    1013983        lsec: longitudinal section (longitudinal value must be given, [var]@[lat])
    1014984        pinterp: pressure interpolation (to the given $plevels)
     985        smean: spatial-weighted mean values
    1015986        tmean: temporal mean values
    1016987        tstd: temporal standard deviation values
     
    12701241            CFvarnp = vninF
    12711242            gP = 'none'
     1243
     1244        elif op == 'smean':
     1245            # spatial-weighted mean values
     1246            noLlvdims = list(varnCFs)
     1247            noLlvdims.remove('lon')
     1248            noLlvdims.remove('lat')
     1249            Saddvars = ':'.join(noLlvdims)
     1250            if len(Saddvars) > 1:
     1251                vals = 'reglonlat,lon,lat,lon,lat,' + Saddvars
     1252            else:
     1253                vals = 'reglonlat,lon,lat,lon,lat,None'
     1254
     1255            if dofile:
     1256                try:
     1257                    with gen.Capturing() as output:
     1258                        ncvar.SpatialWeightedMean(vals,prevfile,vninF)
     1259                except:
     1260                    print errmsg
     1261                    print 'SpatialWeightedMean('+vals+',', prevfile, ','+vninF+')'
     1262                    for s1out in output: print s1out
     1263                    quit(-1)
     1264
     1265                if db:
     1266                    for s1out in output: print s1out
     1267
     1268                # renaming variable
     1269                ncvar.chvarname(vninF+'mean', 'SpatialWeightedMean_reglonlat.nc',    \
     1270                  vninF+'spaceweightmean')
     1271                sout = sub.call('mv SpatialWeightedMean_reglonlat.nc '+fileon,       \
     1272                  shell=True)
     1273
     1274                # Keeping the operations
     1275                pyins=pyH + "/nc_var.py -o SpatialWeightedMean -S '" + vals +        \
     1276                  "' -f " + prevfile + " -v " + vninF
     1277                otrackf.write("\n")
     1278                otrackf.write("# " + vninF + " " + Fopers + "\n")
     1279                otrackf.write(pyins + "\n")
     1280
     1281            # removing dimension variable-dimension 'lon', 'lat'
     1282            varnCFs.remove('lon')
     1283            varnCFs.remove('lat')
     1284
     1285            varkeep.append(vninF + 'mean')
    12721286
    12731287        elif op == 'tmean':
Note: See TracChangeset for help on using the changeset viewer.