Changeset 710 in lmdz_wrf for trunk


Ignore:
Timestamp:
Apr 20, 2016, 6:02:51 PM (9 years ago)
Author:
lfita
Message:

Adding `varval_ind': Function to provide a value from a variable providing a value for each index

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r709 r710  
    1823718237    return ncs
    1823818238
     18239def varval_ind(var, ind):
     18240    """ Function to provide a value from a variable providing a value for each index
     18241      var= variable
     18242      ind= list of indices for each dimension of the variable
     18243    """
     18244    fname = 'varval_ind'
     18245    if len(var.shape) != len(ind):
     18246        print errormsg
     18247        print '  ' + fname + ': different shape:', var.shape,'and indices:', ind, '!!'
     18248        quit(-1)
     18249
     18250    varslice=[]
     18251    for iv in ind:
     18252        varslice.append(iv)
     18253
     18254    val = varval_ind[slice(varslice)]
     18255
     18256    return val
     18257
    1823918258def VarVal_FillValue(values, filen, varn):
    1824018259    """ Function to transform a given value from a given variable to _FillValue in a netCDF file
Note: See TracChangeset for help on using the changeset viewer.