Changeset 2212 in lmdz_wrf for trunk/tools/diagnostics.py


Ignore:
Timestamp:
Nov 2, 2018, 7:01:51 PM (6 years ago)
Author:
lfita
Message:

Addding the `range_faces' with all its glory...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r2209 r2212  
    101101
    102102# Variables not to check
    103 NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face:WE', 'face:SN', 'TSrhs',       \
     103NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face', 'TSrhs',                     \
    104104  'TStd', 'TSwds', 'TSwss',                                                          \
    105105  'WRFbils',                                                                         \
     
    415415            if depvars[0] == 'accum': diagn='accum'
    416416            for depv in depvars:
     417                # Checking without extra arguments of a depending variable (':', separated)
     418                if depv.find(':') != -1: depv=depv.split(':')[0]
    417419                if not ncobj.variables.has_key(depv) and not                         \
    418420                  gen.searchInlist(NONcheckingvars, depv) and                        \
     
    679681        ncvar.insert_variable(ncobj, 'hurs', diagout, diagoutd, diagoutvd, newnc)
    680682
    681 # range_faces: LON, LAT, HGT, 'face:['WE'/'SN']'
     683# range_faces: LON, LAT, HGT, 'face:['WE'/'SN']:[Nptfilt]'
    682684    elif diagn == 'range_faces':
    683685           
     
    685687        var1 = ncobj.variables[depvars[1]][:]
    686688        var2 = ncobj.variables[depvars[2]][:]
    687         var3 = depvars[3].split(':')[1]
    688 
     689        face = depvars[3].split(':')[1]
     690        Nptfilt = depvars[3].split(':')[2]
     691
     692        dnamesvar = list(ncobj.variables[depvars[0]].dimensions)
     693        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
    689694        lon, lat = gen.lonlat2D(var0, var1)
    690695        if len(var2.shape) == 3:
     
    692697            print '  ' + diagn + ": shapping to 2D variable '" + depvars[2] + "' !!"
    693698            hgt = var2[0,:,:]
     699            dnamesvar.pop(0)
     700            dvnamesvar.pop(0)           
    694701        else:
    695702            hgt = var2[:]
    696703
    697         dnamesvar = list(ncobj.variables[depvars[0]].dimensions)
    698         dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
    699 
    700         diagout, diagoutd, diagoutvd = diag.Forcompute_range_faces(lon, lat, hgt,    \
    701           var3, dnamesvar, dvnamesvar)
    702 
    703         # Removing the nonChecking variable-dimensions from the initial list
    704         varsadd = []
    705         diagoutvd = list(dvnames)
    706         for nonvd in NONchkvardims:
    707             if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
    708             varsadd.append(nonvd)
    709         ncvar.insert_variable(ncobj, 'range_faces', diagout, diagoutd, diagoutvd,    \
     704        dhgt, peaks, valleys, origfaces, diagout, diagoutd, diagoutvd =              \
     705          diag.Forcompute_range_faces(lon, lat, hgt, face, Nptfilt, dnamesvar,       \
     706          dvnamesvar)
     707
     708        # Removing the nonChecking variable-dimensions from the initial list
     709        varsadd = []
     710        diagoutvd = list(dvnames)
     711        for nonvd in NONchkvardims:
     712            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     713            varsadd.append(nonvd)
     714
     715        ncvar.insert_variable(ncobj, 'hgtderivdeg', dhgt, diagoutd, diagoutvd,       \
    710716          newnc)
     717        ovar = newnc.variables['orogderivdeg']
     718        if face == 'WE': axis = 'lon'
     719        elif face == 'SN': axis = 'lat'
     720        ncvar.set_attribute(ovar, 'deriv', axis)
     721
     722        ncvar.insert_variable(ncobj, 'peak', peaks, diagoutd, diagoutvd, newnc)
     723        ncvar.insert_variable(ncobj, 'valley', valleys, diagoutd, diagoutvd, newnc)
     724
     725        ncvar.insert_variable(ncobj, 'rangefaces', diagout, diagoutd, diagoutvd,    \
     726          newnc)
     727        newnc.renameVariable('rangefaces', 'rangefacesfilt')
     728        ovar = newnc.variables['rangefacesfilt']
     729        ncvar.set_attribute(ovar, 'face', face)
     730        ncvar.set_attributek(ovar, 'grid_points_filter', Nptfilt, 'I')
     731
     732        ncvar.insert_variable(ncobj, 'rangefaces', origfaces, diagoutd, diagoutvd,  \
     733          newnc)
     734        ovar = newnc.variables['rangefaces']
     735        ncvar.set_attribute(ovar, 'face', face)
    711736
    712737# mrso: total soil moisture SMOIS, DZS
Note: See TracChangeset for help on using the changeset viewer.