Changeset 1069 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Aug 31, 2016, 1:24:55 PM (8 years ago)
Author:
lfita
Message:

First version of 'pinterp' model differences working!
Inclusion of empty dictionarys if there are not 'PLOTDIFF[OP/VAR]' differences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1067 r1069  
    13981398    dirplot = gen.get_specdictionary_HMT(config, H=pkind+'_')
    13991399
     1400    # No plots because there are not plots of this kind
     1401    if dirplot is None:
     1402        print warnmsg
     1403        print '  ' + fname + ": no plots for type '" + pkind + "' !!"
     1404        return {}, 0
     1405
    14001406    if debug:
    14011407        print "  '" + pkind + "' plots to draw ________"
     
    14351441            values = line.replace('\\n','').split(' ')
    14361442            if values[0] == 'plots:':
    1437                 plots = gen.stringList_dictKeysVals(values[1],cV=':')
     1443                if values[1] != 'none':
     1444                    plots = gen.stringList_dictKeysVals(values[1],cV=':')
     1445                else:
     1446                    pots = {}
    14381447            elif values[0] == 'itotp:':
    14391448                Nplots = int(values[1])
     
    19871996
    19881997    if debug:
    1989         print "  'op' differences ________"
    1990         gen.printing_dictionary(diffop)
    1991         print "  'var' differences ________"
    1992         gen.printing_dictionary(diffvar)
     1998        if diffop is not None:
     1999            print "  'op' differences ________"
     2000            gen.printing_dictionary(diffop)
     2001        if diffvar is not None:
     2002            print "  'var' differences ________"
     2003            gen.printing_dictionary(diffvar)
    19932004
    19942005    # Getting variable characteristics from each model/experiment
     
    20062017    files2, testfiles2, allcompvar2, Nvar2= read_varcomp_file(idir2 + '/' + fvc2)
    20072018
    2008     # Getting 'op' differences characteristics
    2009     doops, opvar, indivopvar, varglobalp = get_differences_var(diffop, 'op', debug)
    2010 
    20112019    diffops = {}
    2012     Ndiffop = 0
    2013     for vn in opvar.keys():
    2014         vnops = opvar[vn]
    2015         for op in vnops:
    2016             vnop = vn + '_' + op
    2017             if not allcompvar1.has_key(vnop):
    2018                 print warnmsg
    2019                 print '  ' + fname + ": DIFFOP variable+operation '" + vnop +        \
    2020                   "' in '" + mods[0] + '/' + exps[0] + "' was not computed !!"
    2021                 print '    skipping it!'
    2022                 break
    2023             if not allcompvar2.has_key(vnop):
    2024                 print warnmsg
    2025                 print '  ' + fname + ": DIFFOP variable+operation '" + vnop +        \
    2026                   "' in '" + mods[1] + '/' + exps[1] + "' was not computed !!"
    2027                 print '    skipping it!'
    2028                 break
    2029             vals1 = allcompvar1[vnop]
    2030             vals2 = allcompvar2[vnop]
    2031 
    2032             headerf1 = vals1[0]
    2033             headerf2 = vals2[0]
    2034 
    2035             diffops[vnop] = [mods[0], mods[1], exps[0], exps[1], headerf1, headerf2]
    2036 
    2037             Ndiffop = Ndiffop + 1       
    2038 
    2039     # Getting 'var' differences characteristics
    2040     doops, opvar, indivopvar, varglobalp = get_differences_var(diffvar, 'var', debug)
     2020    if diffop is not None:
     2021        # Getting 'op' differences characteristics
     2022        doops, opvar, indivopvar, varglobalp = get_differences_var(diffop,'op',debug)
     2023
     2024        Ndiffop = 0
     2025        for vn in opvar.keys():
     2026            vnops = opvar[vn]
     2027            for op in vnops:
     2028                vnop = vn + '_' + op
     2029                if not allcompvar1.has_key(vnop):
     2030                    print warnmsg
     2031                    print '  ' + fname + ": DIFFOP variable+operation '" + vnop +    \
     2032                      "' in '" + mods[0] + '/' + exps[0] + "' was not computed !!"
     2033                    print '    skipping it!'
     2034                    break
     2035                if not allcompvar2.has_key(vnop):
     2036                    print warnmsg
     2037                    print '  ' + fname + ": DIFFOP variable+operation '" + vnop +    \
     2038                      "' in '" + mods[1] + '/' + exps[1] + "' was not computed !!"
     2039                    print '    skipping it!'
     2040                    break
     2041                vals1 = allcompvar1[vnop]
     2042                vals2 = allcompvar2[vnop]
     2043
     2044                headerf1 = vals1[0]
     2045                headerf2 = vals2[0]
     2046
     2047                diffops[vnop] = [mods[0],mods[1],exps[0],exps[1],headerf1,headerf2]
     2048
     2049                Ndiffop = Ndiffop + 1       
     2050    else:
     2051        Ndiffop = 0
    20412052
    20422053    diffvars = {}
    2043     Ndiffvar = 0
    2044     for vn in opvar.keys():
    2045         vnops = opvar[vn]
    2046         for op in vnops:
    2047             vnop = vn + '_' + op
    2048             if not allcompvar1.has_key(vnop):
    2049                 print warnmsg
    2050                 print '  ' + fname + ": DIFFVAR variable+operation '" + vnop +       \
    2051                   "' in '" + mods[0] + '/' + exps[0] + "' was not computed !!"
    2052                 print '    skipping it!'
    2053                 break
    2054             if not allcompvar2.has_key(vnop):
    2055                 print warnmsg
    2056                 print '  ' + fname + ": DIFFVAR variable+operation '" + vnop +       \
    2057                   "' in '" + mods[1] + '/' + exps[1] + "' was not computed !!"
    2058                 print '    skipping it!'
    2059                 break
    2060             vals1 = allcompvar1[vnop]
    2061             vals2 = allcompvar2[vnop]
    2062 
    2063             headerf1 = vals1[0]
    2064             headerf2 = vals2[0]
    2065 
    2066             diffvars[vnop] = [mods[0], mods[1], exps[0], exps[1], headerf1, headerf2]
    2067 
    2068             Ndiffvar = Ndiffvar + 1       
    2069 
    2070     Sopdiffs = gen.dictKeysVals_stringList(diffops)
    2071     Svardiffs = gen.dictKeysVals_stringList(diffvars)
    2072 
    2073     # Outwritting the op diffferences file to avoid next time (if it is not filescratch!)
     2054    if diffvar is not None:
     2055        # Getting 'var' differences characteristics
     2056        doops,opvar,indivopvar,varglobalp = get_differences_var(diffvar,'var',debug)
     2057
     2058        Ndiffvar = 0
     2059        for vn in opvar.keys():
     2060            vnops = opvar[vn]
     2061            for op in vnops:
     2062                vnop = vn + '_' + op
     2063                if not allcompvar1.has_key(vnop):
     2064                    print warnmsg
     2065                    print '  ' + fname + ": DIFFVAR variable+operation '" + vnop +   \
     2066                      "' in '" + mods[0] + '/' + exps[0] + "' was not computed !!"
     2067                    print '    skipping it!'
     2068                    break
     2069                if not allcompvar2.has_key(vnop):
     2070                    print warnmsg
     2071                    print '  ' + fname + ": DIFFVAR variable+operation '" + vnop +   \
     2072                      "' in '" + mods[1] + '/' + exps[1] + "' was not computed !!"
     2073                    print '    skipping it!'
     2074                    break
     2075                vals1 = allcompvar1[vnop]
     2076                vals2 = allcompvar2[vnop]
     2077   
     2078                headerf1 = vals1[0]
     2079                headerf2 = vals2[0]
     2080
     2081                diffvars[vnop] = [mods[0],mods[1],exps[0],exps[1],headerf1,headerf2]
     2082
     2083                Ndiffvar = Ndiffvar + 1
     2084    else:
     2085        Ndiffvar = 0
     2086
     2087    if diffop is not None:
     2088        Sopdiffs = gen.dictKeysVals_stringList(diffops)
     2089    else:
     2090        Sopdiffs = 'none'
     2091    # Outwritting the op diffferences file to avoid next time
    20742092    objf = open(odir + '/diffop.inf', 'w')
    20752093    objf.write('differences: ' + Sopdiffs + '\n')
     
    20772095    objf.close()
    20782096
    2079     # Outwritting the var diffferences file to avoid next time (if it is not filescratch!)
     2097    if diffvar is not None:
     2098        Svardiffs = gen.dictKeysVals_stringList(diffvars)
     2099    else:
     2100        Svardiffs = 'none'
     2101    # Outwritting the var diffferences file to avoid next time
    20802102    objf = open(odir + '/diffvar.inf', 'w')
    20812103    objf.write('differences: ' + Svardiffs + '\n')
     
    20832105    objf.close()
    20842106
    2085     return diffops, diffvars, Ndiffvar, Ndiffop
     2107    return diffops, diffvars, Ndiffop, Ndiffvar
    20862108
    20872109def read_diff_file(difffile):
     
    30743096        # Re-projecting also the 'original' (at least with 'pinterp') file for varsdif
    30753097        if op.find('pinterp') != -1:
    3076             ifileorig = vn +'_'+ values[0].replace('reproj-','') + '_pinterp.nc'
    3077             ofileorig = vn +'_'+ values[0] + '_pinterp.nc'
    3078             ofilen = vn +'_'+ values[0] + '_pinterp.nc'
     3098            ifileorig = vn +'_'+ values[0].replace('reproj-','') + 'p_pinterp.nc'
     3099            ofileorig = vn +'_'+ values[0] + 'p_pinterp.nc'
     3100            ofilen = vn +'_'+ values[0] + 'p_pinterp.nc'
    30793101        else:
    30803102            ifileorig = vn +'_'+ values[0].replace('reproj-','') + '.nc'
Note: See TracChangeset for help on using the changeset viewer.