Changeset 2190 in lmdz_wrf


Ignore:
Timestamp:
Oct 17, 2018, 8:09:59 PM (7 years ago)
Author:
lfita
Message:

Improving `sellonlatbox', removing special case on stations list... will see !!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/tools/nc_var_tools.py

    r2187 r2190  
    69166916# Adding variable dimensions
    69176917        varslice = []
     6918        haslonlat = False
     6919        if gen.searchInlist(varinf.dimns, dlonn): haslonlat=True
     6920        if gen.searchInlist(varinf.dimns, dlatn): haslonlat=True
     6921
    69186922        for dimn in varinf.dimns:
    69196923            if not gen.searchInlist(newncobj.dimensions, dimn):
     
    69226926                else:
    69236927                    newncobj.createDimension(dimn, len(objfile.dimensions[dimn]))
    6924 # Very special case when we have for example a list of stations (which is the case!)
    6925             if dimn == dlonn and dimx != dimy:
     6928            # Very special case when we have for example a list of stations (which is the case!)
     6929            #if dimn == dlonn and dimx != dimy: [removed]
     6930            if dimn == dlonn:
    69266931                varslice.append(slice(ilon,elon+1))
    6927             elif dimn == dlatn and dimx != dimy:
     6932            #elif dimn == dlatn and dimx != dimy:
     6933            elif dimn == dlatn:
    69286934                varslice.append(slice(ilat,elat+1))
    69296935            else:
     
    69366942              fill_value = varinf.FillValue)
    69376943
    6938         if dimx != dimy:
     6944        if not haslonlat:
    69396945            newvar[:] = varobj[tuple(varslice)]
    69406946        else:
    6941 # Very special case when we have for example a list of stations (which is the case!)
    6942             print '  ' + fname + ': woow we are in a stations-list like of file...'
    6943             inpos0 = 0
    6944             for i in range(newdimx):
    6945                 inpos = gen.index_vec(malonlat[inpos0:dimx+1], False)
    6946                 inpos = inpos + inpos0
    6947                 inpos0 = inpos + 1
    6948                 varslice = []
    6949                 newvarslice = []
    6950                 for dimn in varinf.dimns:
    6951                     if not gen.searchInlist(newncobj.dimensions, dimn):
    6952                         newncobj.createDimension(dimn, len(objfile.dimensions[dimn]))
    6953 # Very special case when we have for example a list of stations (which is the case!)
    6954                     if dimn == dlonn:
    6955                         varslice.append(inpos)
    6956                         newvarslice.append(i)
    6957                     else:
    6958                         varslice.append(slice(0,len(objfile.dimensions[dimn])))
    6959                         newvarslice.append(slice(0,len(objfile.dimensions[dimn])))
    6960                 newvar[tuple(newvarslice)] = varobj[tuple(varslice)]
     6947#            if dimx != dimy:
     6948            if dlonn != dlatn:
     6949                newvar[:] = varobj[tuple(varslice)]
     6950            else:
     6951                # Very special case when we have for example a list of stations (which is the case!)
     6952                print '  ' + fname + ': woow we are in a stations-list like of file...'
     6953                inpos0 = 0
     6954                for i in range(newdimx):
     6955                    inpos = gen.index_vec(malonlat[inpos0:dimx+1], False)
     6956                    inpos = inpos + inpos0
     6957                    inpos0 = inpos + 1
     6958                    varslice = []
     6959                    newvarslice = []
     6960                    for dimn in varinf.dimns:
     6961                        if not gen.searchInlist(newncobj.dimensions, dimn):
     6962                            newncobj.createDimension(dimn, len(objfile.dimensions[dimn]))
     6963                    # Very special case when we have for example a list of stations (which is the case!)
     6964                        if dimn == dlonn:
     6965                            varslice.append(inpos)
     6966                            newvarslice.append(i)
     6967                        else:
     6968                            varslice.append(slice(0,len(objfile.dimensions[dimn])))
     6969                            newvarslice.append(slice(0,len(objfile.dimensions[dimn])))
     6970                    newvar[tuple(newvarslice)] = varobj[tuple(varslice)]
    69616971
    69626972        for atrn in varinf.attributes:
     
    1156511575    if uvalsecs[1] == 'since':
    1156611576        tunits = True
    11567         if len(uvalsecs) == 4:
    11568             date=uvalsecs[2]
    11569             time=uvalsecs[3]
    11570         else:
    11571             if uvalsecs[2].find('_') == -1:
    11572                 date=uvalsecs[2]
    11573                 time='00:00:00'
    11574             else:
    11575                 date=uvalsecs[2].split('_')[0]
    11576                 time=uvalsecs[2].split('_')[1]
     11577        CFtimeu = gen.get_right_CFtimeunits(urefvals)
     11578        uvalsecs = CFtimeu.split(' ')
     11579        date=uvalsecs[2]
     11580        time=uvalsecs[3]
    1157711581        refdate = gen.datetimeStr_datetime(date+'_'+time)
    1157811582        print warnmsg
Note: See TracChangeset for help on using the changeset viewer.