Changeset 1031 in lmdz_wrf


Ignore:
Timestamp:
Aug 18, 2016, 3:31:59 PM (9 years ago)
Author:
lfita
Message:

Working copy with plots even from the SCRATCH !

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/model_graphics.py

    r1029 r1031  
    3333        filescr = True
    3434        figscr = True
     35        difscr = True
    3536        tim.sleep(10)
    3637    else:
     
    5455            figscr = False
    5556
     57        if config['diffscratch'] == 'true':
     58            difscr = True
     59            print warnmsg
     60            print "  " + main + ": differences starting from the SCRATCH !!"
     61            print "    5 seconds left!!"
     62            tim.sleep(5)
     63        else:
     64            difscr = False
     65
    5666    if config['addfiles'] == 'true':
    5767        addfils = True
     
    6474        addfigs = False
    6575
     76    if config['adddiffs'] == 'true':
     77        adddiffs = True
     78    else:
     79        adddiffs = False
     80
    6681    if config['debug'] == 'true':
    6782        debug = True
     
    6984        debug = False
    7085
    71     return scr, filescr, figscr, addfils, addfigs, debug
     86    return scr, filescr, figscr, difscr, addfils, addfigs, adddiffs, debug
    7287
    7388def exp_headers(mod,config):
     
    455470                print '  ' + fname + ": creation of variable file '" + CFvarn +      \
    456471                  "' in file '" + ifilen + "' ..."
    457 
    458             if modvar is not None and diagvar is None:
     472                print 'model variable:', modvar
     473                print 'diagostic variable:', diagvar
     474
     475            if diagvar is None:
    459476                # model variable
    460                 values = modvar[0] + ',0,-1,-1'
    461                 vs = modvar[0] + ',' + vdnx + ',' + vdny + ',' + vdnz + ',' + vdnt
    462                 with gen.Capturing() as output:
    463                     ncvar.DataSetSection_multivars(values, cf, vs)
    464                
     477                if db: print '  '+fname+ ": variable direct from model '" +modvar+ "'"
     478                values = modvar + ',0,-1,-1'
     479                vs = modvar + ',' + vdnx + ',' + vdny + ',' + vdnz + ',' + vdnt
     480
     481                try:
     482                    with gen.Capturing() as output:
     483                        ncvar.DataSetSection_multivars(values, cf, vs)
     484                except:
     485                    print errmsg
     486                    print 'ncvar.DataSetSection_multivars('+values+', '+cf+', '+vs+')'
     487                    for sout in output: print sout
     488                    quit(-1)
     489
    465490                newfile, loc = gen.search_sec_list(output,'succesfull')
    466491                ofile = newfile[0].split(' ')[7]
     
    471496                  vs + " -S '" + values + "'"
    472497                otrackf.write('\n')
    473                 otrackf.write('# ' + CFvarn + " " + modvar[0] + '\n')
     498                otrackf.write('# ' + CFvarn + " " + modvar + '\n')
    474499                otrackf.write(pyins + '\n')
    475500
    476501                # CF renaming of variable
    477                 ncvar.chvarname(CFvarn,ifilen,modvar[0])
     502                ncvar.chvarname(CFvarn,ifilen,modvar)
    478503            else:
    479504                # diagnostic variable
     505                if db: print '  '+fname+ ": variable as diagnostic '" +diagvar[0]+ "'"
    480506                dims = dnt+'@'+vdnt+','+dnz+'@'+vdnz+','+dny+'@'+vdny+','+dnx+'@'+vdnx
    481507                diagn = diagvar[0]
     
    549575        sout = sub.call('mv netcdf_fold_concatenated_HMT.nc ' + fileon, shell=True)
    550576        if os.path.isfile(fileon):
    551             sout = sub.call('rm ' + CFvarn + '_' + headerf + '_*-*.nc', shell=True)
     577            sout = sub.call('rm ' + CFvarn +'_'+ headerf+SgP + '_*-*.nc >& /dev/null',
     578              shell=True)
    552579
    553580    return
     
    968995    fname = 'compute_vars'
    969996
    970     for vopn in allvarcomp:
     997    for vopn in allvarcomp.keys():
    971998        # variable & operation
    972999        vn = vopn.split('_')[0]
     
    10571084                else:
    10581085                    plots = indivplotsvar[VOv]
    1059                     indivplots.append(pln)
     1086                    plots.append(pln)
    10601087                    indivplotsvar[VOv] = plots
    10611088
     
    15041531                vnopS = vn + '_' + op
    15051532                if not allvarcomp.has_key(vnopS):
    1506                     print errormsg
    1507                     print '  ' + fname + ": no entry for variable-operation '" +     \
     1533                    print errmsg
     1534                    print '  ' + fname + ": no file for variable-operation '" +     \
    15081535                      vnopS + "' !!"
    15091536                vopvals = allvarcomp[vnopS]
     
    15971624
    15981625# scratches
    1599 scratch, filescratch, figscratch, addfiles, addfigures, dbg = scratches(cnf)
     1626scratch, filescratch, figscratch, diffscratch, addfiles, addfigures, adddiffs, dbg = scratches(cnf)
    16001627
    16011628# Getting models
     
    16071634    print mod
    16081635    if scratch:
    1609         sout = sub.call('rm -rf '+cnf['ofold']+'/'+mod+' > /dev/null', shell=True)
     1636        if cnf['ofold'] != cnf['ifold']:
     1637            sout = sub.call('rm -rf '+cnf['ofold']+'/'+mod+' > /dev/null', shell=True)
     1638        else:
     1639            print warnmsg
     1640            print '  ' + main + ": input '" + cnf['ifold'] + "' and output '" +      \
     1641              cnf['ofold'] + "' are the same folder !!"
     1642            print "    Keeping output folder although it has 'scratch' start"
    16101643
    16111644    # Get experiments and headers of model
     
    17471780        draw_plots(cnf, listplots, mod, exp, owdir, allcompvar, figscratch, dbg)
    17481781
    1749         quit()
    17501782    # end of experiments loop
    17511783
     1784### ## #
     1785# Experiment differences
     1786## # ## #
     1787
     1788# Experiments loop
     1789##
     1790    Nexps = len(exps)
     1791    for exp1 in exps[0:Nexps-1]:
     1792        for exp2 in exps[1:Nexps]:
     1793            print '  ' + exp2 + '-' + exp1 + '...'
     1794            owdir = cnf['ofold'] + '/' + mod + '/' + exp2 + '-' + exp1
     1795            sout = sub.call('mkdir -p ' + owdir, shell=True)
     1796
     1797            diffvarcompf = owdir + '/diffvarcompute.inf'
     1798            if diffscratch:
     1799                sub.call('rm -rf' + owdir +' >& /dev/null', shell=True)
     1800                sub.call('rm ' + diffvarcompf +' >& /dev/null', shell=True)
     1801                objf = open(owdir+'/all_diffcomputevars.inf','w')
     1802                objf.write("## Computation and drawing of differences between '" +   \
     1803                  exp2 + "'-'" + exp1 + "'\n")
     1804                objf.close()
     1805
     1806            if adddiffs:
     1807                sub.call('rm ' + diffvarcompf +' >& /dev/null', shell=True)
     1808
     1809            if not os.path.isfile(diffvarcompf):
     1810                alldiffcompvar, Ndiffs = diffcompvars_listconstruct(cnf, Modinf,     \
     1811                  allcompvar, owdir, dbg)
     1812            else:
     1813                print warnmsg
     1814                print '  ' + main + ": getting differences to compute already from file !!"
     1815                alldiffcompvar, Ndiffs = read_diffvarcomp_file(diffvarcompf)
     1816
     1817        # End of avoiding to repeat all the experiment search
     1818
     1819        print "  For experiments '"+exp2+"'-'"+exp1+"' is required to compute:",     \
     1820          Nvar, "differences"
     1821
     1822        if dbg:
     1823            print 'Differences to compute _______'
     1824            gen.printing_dictionary(alldiffcompvar)
     1825
     1826    quit()
    17521827# end of mods loop
    17531828
  • trunk/tools/model_graphics_template.dat

    r1029 r1031  
    2727
    2828# Scratch figures: should be any figures previous work removed and start from the scratch?
    29 figscratch = true
     29figscratch = false
     30
     31# Scratch differences: should be any differences previous work removed and start from the scratch?
     32diffscratch = false
    3033
    3134# Have new files been added and do they need to be processed?
     
    3437# Have new figures been added and do they need to be drawn?
    3538addfigures = false
     39
     40# Have new differences been added and do they need to be processed and drawn?
     41adddiffs = false
    3642
    3743# Debug
     
    9096#   VAR_[calc1]+[calc2] = tas:wss
    9197#     will compute first [calc1] and then [calc2] for 'tas' and 'wss'
    92 VAR_last = tas:uas:vas:hfss:hfls:wss
    93 VAR_tmean = tas:uas:vas:hfss:hfls:wss
    94 VAR_xmean = tas:uas:vas:hfss:hfls:wss
    95 #VAR_last+pinterp+xmean = ta:ua:va:hur:hus:turb
    96 VAR_pinterp+tmean+xmean = ta:ua:va:hur:hus
     98VAR_last = uas:vas:hfss:hfls
     99VAR_tmean = uas:vas:hfss:hfls
     100VAR_xmean = uas:vas:hfss:hfls
     101#VAR_last+pinterp+xmean = ua:va:hur:hus:turb
     102VAR_pinterp+tmean+xmean = ua:va
    97103
    98104#varlast = tas:uas:vas:ps:pr:pracc:rsds:prw:evspsbl:hfss:hfls:hurs:huss:zmla:hufs:wakes:lwakeh:stherm:zmaxth:clt:cll:clm:clh:prc:prls:bils:wss
     
    137143# DIRPLT_: Figures which can be made directly without another model/experiment output
    138144
    139 DIRPLT_shadcont2Dsfc = uas|last#vas|last:hfls|last#hfss|last:wss|last#tas|last
    140 DIRPLT_shadconthovmsfc = wss|xmean#tas|xmean
    141 DIRPLT_shadcont2Dzsec = ua|pinterp+tmean+xmean#va|pinterp+tmean+xmean:hus|pinterp+tmean+xmean#ta|pinterp+tmean+xmean
     145DIRPLT_shadcont2Dsfc = uas|last#vas|last:hfls|last#hfss|last
     146DIRPLT_shadconthovmsfc = hfls|xmean#hfss|last
     147DIRPLT_shadcont2Dzsec = ua|pinterp+tmean+xmean#va|pinterp+tmean+xmean
    142148
    143149#pltshadcont2Dsfc = huss|tmean#tas|tmean:vas|tmean#uas|tmean:ps|tmean#wss|tmean:pr|tmean#rsds|tmean:prw|tmean#clt|tmean:hfls|tmean#hfss|tmean:evspsbl|tmean#bils|tmean:zmaxth|tmean#stherm|tmean:wakeh|tmean#wakes|tmean:zmaxth|tmean#stherm|tmean:prls|tmean#prc|tmean:clt|tmean#cll|tmean:clm|tmean#clh|tmean:hurs|tmean#zmla|tmean:huss|last#tas|last:vas|last#uas|last:ps|last#wss|tmean:pr|last#rsds|last:prw|last#clt|last:hfls|last#hfss|last:evspsbl|last#bils|last:zmaxth|last#stherm|last:wakeh|last#wakes|last:zmaxth|last#stherm|last:prls|last#prc|last:clt|last#cll|last:clm|last#clh|last:hurs|last#zmla|last
Note: See TracChangeset for help on using the changeset viewer.