Changeset 784 in lmdz_wrf for trunk


Ignore:
Timestamp:
May 28, 2016, 5:05:09 PM (9 years ago)
Author:
lfita
Message:

Adding `index_vec': Function to provide the coordinates of a given value inside a vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r780 r784  
    11271127    return string
    11281128
     1129def index_vec(vec,val):
     1130    """ Function to provide the coordinates of a given value inside a vector
     1131    index_vec(vec,val)
     1132      vec= vector with values
     1133      val= value to search
     1134    >>> index_vec(np.arange(27),22)
     1135    22
     1136    """
     1137
     1138    fname = 'index_vec'
     1139
     1140    vecv = np.array(vec)
     1141
     1142    for i in range(vecv.shape[0]):
     1143        if vecv[i] == val:
     1144            valpos = i
     1145            break
     1146
     1147    return valpos
     1148
    11291149def index_mat(mat,val):
    11301150    """ Function to provide the coordinates of a given value inside a matrix
Note: See TracChangeset for help on using the changeset viewer.