Changeset 1409 in lmdz_wrf


Ignore:
Timestamp:
Jan 16, 2017, 4:20:52 PM (9 years ago)
Author:
lfita
Message:

Adding no-sliced variables (by absence of one of the dimensions in the slice) from `curve_section'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1405 r1409  
    1107811078            exctcurvloc[icv,0] = np.float(exctcurvloc[icv,0]) + curveweights[icv,ipy,ipx]*(ipy-1.)
    1107911079            exctcurvloc[icv,1] = np.float(exctcurvloc[icv,1]) + curveweights[icv,ipy,ipx]*(ipx-1.)
    11080             print '    ' + fname + 'ip:', ip, 'ipy:', ipy-1., 'wgt:', curveweights[icv,ipy,ipx], \
    11081               'exctcurv:', exctcurvloc[icv,0]
    11082         print '  ' + fname + ' icv:', icv, 'curve:', curve[icv,:], 'ijloc:', ijloc, \
    11083           'cwgt:', curveweights[icv,:,:], 'exctloc:', exctcurvloc[icv,:]
     11080            #print '    ' + fname + 'ip:', ip, 'ipy:', ipy-1., 'wgt:', curveweights[icv,ipy,ipx], \
     11081            #  'exctcurv:', exctcurvloc[icv,0]
     11082        #print '  ' + fname + ' icv:', icv, 'curve:', curve[icv,:], 'ijloc:', ijloc, \
     11083        #  'cwgt:', curveweights[icv,:,:], 'exctloc:', exctcurvloc[icv,:]
    1108411084#    quit()
    1108511085
  • trunk/tools/nc_var_tools.py

    r1400 r1409  
    1857918579        print '  ' + fname + ": file '" + ncfile + "' does not have dimension '" +   \
    1858018580          xdimn + "' !!"
    18581         print '    available dimensions:', onc.dimensions
     18581        print '    available dimensions:', onc.dimensions.keys()
    1858218582        onc.close()
    1858318583        quit(-1)
     
    1858718587        print '  ' + fname + ": file '" + ncfile + "' does not have dimension '" +   \
    1858818588          ydimn + "' !!"
    18589         print '    available dimensions:', onc.dimensions
     18589        print '    available dimensions:', onc.dimensions.keys()
    1859018590        onc.close()
    1859118591        quit(-1)
     
    1874818748            print '    ' + fname + ": adding section of '" + vn + "' ..."
    1874918749            dimvar = list(ovar.dimensions)
    18750             if gen.searchInlist(dimvar, xdimn): dimvar.remove(xdimn)
    18751             if gen.searchInlist(dimvar, ydimn): dimvar.remove(ydimn)
    18752 
    18753             varcurve = interp_curve(ovar, xdimn, ydimn, loccurve, curvewgts, Nwgts, \
    18754               curveloc3x3)
    18755 
    18756             # Writing values of variable along the curve
    18757             add_dims(onc,newnc,dimvar)
    18758 
    18759             newvar = newnc.createVariable(vn+'curve', 'f4', tuple(dimvar+['curve']))
    18760             newvar[:] = varcurve[:]
    18761             add_varattrs(onc,newnc,[vn],[vn+'curve'])
    18762             set_attribute(newvar,'along','xcurve,ycurve')
    18763             set_attribute(newvar,'curve',curvetype)
     18750            # Look if variable has the dimension along the curve
     18751            foundxdim = False
     18752            foundydim = False
     18753            if gen.searchInlist(dimvar, xdimn):
     18754                foundxdim = True
     18755            if gen.searchInlist(dimvar, ydimn):
     18756                foundydim = True
     18757
     18758            if foundxdim and foundydim:
     18759                dimvar.remove(xdimn)
     18760                dimvar.remove(ydimn)
     18761                varcurve = interp_curve(ovar, xdimn, ydimn, loccurve, curvewgts,     \
     18762                  Nwgts, curveloc3x3)
     18763                # Writing values of variable along the curve
     18764                add_dims(onc,newnc,dimvar)
     18765
     18766                newvar = newnc.createVariable(vn+'curve', 'f4', tuple(dimvar+['curve']))
     18767                newvar[:] = varcurve[:]
     18768                add_varattrs(onc,newnc,[vn],[vn+'curve'])
     18769                set_attribute(newvar,'along','xcurve,ycurve')
     18770                set_attribute(newvar,'curve',curvetype)
     18771                newnc.sync()
     18772
     18773            else:
     18774                print warnmsg
     18775                print '  ' + fname + ": variable '" + vn + "' does not have curve "+ \
     18776                  " dimensions '", xdimn, "' and '", ydimn, "' !!"
     18777                print '    keeping as it is in output file'
     18778
     18779                # Writing values of variable along the curve
     18780                add_dims(onc,newnc,dimvar)
     18781
     18782                newvar = newnc.createVariable(vn, nctype(ovar.dtype), tuple(dimvar))
     18783                print '    Lluis shapes newvar:', newvar.shape, 'ovar:', ovar.shape
     18784                newvar[:] = ovar[:]
     18785
    1876418786            newnc.sync()
    1876518787 
Note: See TracChangeset for help on using the changeset viewer.