Changeset 1060 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 27, 2016, 12:43:55 PM (9 years ago)
Author:
lfita
Message:

Starting to add differences among models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1059 r1060  
    28962896# Models loop
    28972897##
     2898
     2899# dictionary with the experiments of each model
     2900modexps = {}
     2901
    28982902for mod in mods:
    28992903    print mod
     
    29102914    exps, fheaders = exp_headers(mod,cnf)
    29112915
     2916    modexps[mod] = exps
    29122917    # Characteristics of the model
    29132918    Modinf = ncvar.model_characteristics(mod,'None','False')
     
    31623167          dbg)
    31633168
    3164 #    quit()
    31653169# end of mods loop
    31663170
     3171### ## #
     3172# Model differences
     3173## # ## #
     3174
     3175Nmods = len(mods)
     3176for imod1 in range(0,Nmods-1):
     3177    mod1 = mods[imod1]
     3178    exps1 = modexps[mod1]
     3179    for imod2 in range(imod1+1,Nmods):
     3180        mod2 = mods[imod2]
     3181        exps2 = modexps[mod2]
     3182
     3183        Smods = mod2 + '-' + mod1
     3184        print '  ******* ****** ***** **** *** ** * ** *** **** ***** ****** *******'
     3185        print "  ** '" + Smods + "': Inter models differences  "
     3186        print '  ******* ****** ***** **** *** ** * ** *** **** ***** ****** *******'
     3187        print '    experiments mod1:', exps1
     3188        print '    experiments mod2:', exps2
     3189
     3190# Experiments loop
     3191##
     3192        difffiles = ['diffop.inf', 'diffvar.inf']
     3193
     3194        Nexps1 = len(exps1)
     3195        Nexps2 = len(exps2)
     3196        for iexp1 in range(0,Nexps1):
     3197            exp1 = exps1[iexp1]
     3198            for iexp2 in range(0,Nexps2):
     3199                exp2 = exps2[iexp2]
     3200                Sexps = exp2 + '-' + exp1
     3201                print '    ' + Sexps + '...'
     3202                owdir = cnf['ofold'] + '/' + Smods + '/' + exp2 + '-' + exp1
     3203                sout = sub.call('mkdir -p ' + owdir, shell=True)
     3204
     3205                # Removing files with list of differences if should be started from
     3206                #   scratch or add differences
     3207                for fdiff in difffiles:
     3208                    difff = owdir + '/' + fdiff
     3209                    if diffscratch:
     3210                        sub.call('rm -rf' + owdir +' >& /dev/null', shell=True)
     3211                        sub.call('rm ' + difff +' >& /dev/null', shell=True)
     3212                        objf = open(owdir+'/all_' + fdiff,'w')
     3213                        objf.write("## Computation and drawing of differences " +    \
     3214                          "between '" + mod2+'@'+exp2 + "'-'" + mod1+'@'+exp1 + "'\n")
     3215                        objf.close()
     3216                        difff = owdir + '/all_vardiffstatistics.inf'
     3217                        sub.call('rm ' + difff +' >& /dev/null', shell=True)
     3218                        objf = open(owdir+'/all_' + fdiff,'w')
     3219                        objf.write("## Computation of all differences statistics " + \
     3220                          "between '" + mod2+'@'+exp2 + "'-'" + mod1+'@'+exp1 + "'\n")
     3221                        objf.close()
     3222
     3223                    if adddiffs:
     3224                        sub.call('rm ' + difff +' >& /dev/null', shell=True)
     3225
     3226                # op and var differences
     3227                diffvarcompf = owdir + '/' + difffiles[0]
     3228                if not os.path.isfile(diffvarcompf):
     3229                    alldiffop, alldiffvar, Nopdiffs, Nvardiffs =                     \
     3230                      diffvarop_listconstruct(cnf, [mod1, mod2], [exp1, exp2], owdir,\
     3231                      dbg)
     3232                else:
     3233                    print warnmsg
     3234                    print '  ' + main + ": getting 'op' and 'var'differences to " +  \
     3235                      "compute already from file !!"
     3236                    alldiffop, Nopdiffops = read_diff_file(diffvarcompf)
     3237                    alldiffvar, Nopdiffvars = read_diff_file(owdir+'/'+difffiles[1])
     3238
     3239                # End of avoiding to repeat all the experiment search
     3240
     3241                print "    For experiments '" + mod2+'@'+exp2+"'-'"+mod+'@'+exp1+    \
     3242                  "' is required to compute:", Nvar, "differences"
     3243
     3244                if dbg:
     3245                    print 'Differences to compute _______'
     3246                    gen.printing_dictionary(alldiffop)
     3247                    gen.printing_dictionary(alldiffvar)
     3248
     3249# Computing differences
     3250##
     3251                print "    Computing operation differences ..."
     3252                compute_op_diffs(cnf, alldiffop, owdir, diffscratch, dbg)
     3253                print "    Computing variable differences ..."
     3254                compute_var_diffs(cnf, alldiffvar, owdir, diffscratch, dbg)
     3255
     3256# Plotting operation differences
     3257##
     3258                print "  " + main + ": Plotting operation differences' figures ..."
     3259                dirfigf = owdir + '/diffopplotsdraw.inf'
     3260                if figscratch:
     3261                    sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True)
     3262
     3263                objf = open(owdir+'/all_diffopfigures.inf','w')
     3264                objf.write("## Drawing of all operation difference figures \n")
     3265                objf.close()
     3266
     3267                if adddifffigures:
     3268                    sout = sub.call('rm ' + dirfigf + ' >& /dev/null', shell=True)
     3269
     3270                if not os.path.isfile(dirfigf):
     3271                    listplots, Nplt = plots_listconstruct(cnf, 'PLOTDIFFOP', dirfigf,\
     3272                      owdir, dbg)
     3273                else:
     3274                    print warnmsg
     3275                    print '  ' + main + ": getting plots to draw already from file !!"
     3276                        listplots, Nplt = read_plot_file(dirfigf)
     3277
     3278                # End of avoiding to repeat all the plots search
     3279
     3280                print "  For experiment 'operation' differences '" + Sexps + "' is "+\
     3281                  "required to plot:" , Nplt, "plots"
     3282
     3283                if dbg:
     3284                    print 'Plots to draw _______'
     3285                    gen.printing_dictionary(listplots)
     3286
     3287                draw_diff_plots(cnf, listplots, owdir, alldiffop, 'diffop',          \
     3288                  figdiffscratch, dbg)
     3289                draw_diff_plots(cnf, listplots, owdir, alldiffvar, 'diffvar',        \
     3290                  figdiffscratch, dbg)
     3291
     3292            # end of exp2 loop
     3293        # end of exp1 loop
     3294    # end of mod2 loop
     3295# end of mod1 loop
     3296
Note: See TracChangeset for help on using the changeset viewer.