Changeset 22871


Ignore:
Timestamp:
06/22/18 06:59:45 (7 years ago)
Author:
bdef
Message:

CHG:modification in greater smaller of checkfield

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/consistency/checkfield.py

    r22865 r22871  
    132132        if options.exist('>='):
    133133                lowerbound = options.getfieldvalue('>=')
    134                 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
    135                 if options.getfieldvalue('timeseries',0):
    136                         field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
    137 
    138                 if options.getfieldvalue('singletimeseries',0):
    139                         field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
    140 
    141                 if np.any(field2<lowerbound):
    142                         md = md.checkmessage(options.getfieldvalue('message',\
    143                                 "field '%s' should have values above %d" % (fieldname,lowerbound)))
     134                if np.size(lowerbound)>1: #checking elementwise
     135                        if any(field<upperbound):
     136                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
     137                else:
     138                        minval=np.nanmin(field)
     139                        if options.getfieldvalue('timeseries',0):
     140                                minval=np.nanmin(field[:-1])
     141                        elif options.getfieldvalue('singletimeseries',0):
     142                                if np.size(field)==1: #some singletimeseries are just one value
     143                                        minval=field
     144                                else:
     145                                        minval=np.nanmin(field[0])
     146
     147                        if minval<lowerbound:
     148                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values above %d" % (fieldname,lowerbound)))
    144149
    145150        if options.exist('>'):
    146151                lowerbound=options.getfieldvalue('>')
    147                 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
    148                 if options.getfieldvalue('timeseries',0):
    149                         field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
    150 
    151                 if options.getfieldvalue('singletimeseries',0):
    152                         field2 = np.reshape(field[0],np.prod(np.shape(field[0])),1)
    153 
    154                 if np.any(field2<=lowerbound):
    155                         md = md.checkmessage(options.getfieldvalue('message',\
    156                                 "field '%s' should have values above %d" % (fieldname,lowerbound)))
     152                if np.size(lowerbound)>1: #checking elementwise
     153                        if any(field<=upperbound):
     154                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
     155                else:
     156                        minval=np.nanmin(field)
     157                        if options.getfieldvalue('timeseries',0) :
     158                                minval=np.nanmin(field[:-1])
     159                        elif options.getfieldvalue('singletimeseries',0):
     160                                if np.size(field)==1: #some singletimeseries are just one value
     161                                        minval=field
     162                                else:
     163                                        minval=np.nanmin(field[0])
     164
     165                        if minval<=lowerbound:
     166                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values above %d" % (fieldname,lowerbound)))
    157167
    158168        #check smaller
    159169        if options.exist('<='):
    160170                upperbound=options.getfieldvalue('<=')
    161                 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
    162                 if options.getfieldvalue('timeseries',0):
    163                         field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
    164 
    165                 if options.getfieldvalue('singletimeseries',0):
    166                         field2 = np.reshape(field[0],int(np.prod(np.shape(field[0]))),1)
    167 
    168                 if np.any(field2>upperbound):
    169                         md = md.checkmessage(options.getfieldvalue('message',\
    170                                 "field '%s' should have values below %d" % (fieldname,upperbound)))
     171                if np.size(upperbound)>1: #checking elementwise
     172                        if any(field>upperbound):
     173                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
     174                else:
     175                        maxval=np.nanmax(field)
     176                        if options.getfieldvalue('timeseries',0):
     177                                maxval=np.nanmax(field[:-1])
     178                        elif  options.getfieldvalue('singletimeseries',0):
     179                                if np.size(field)==1: #some singletimeseries are just one value
     180                                        maxval=field
     181                                else:
     182                                        maxval=np.nanmax(field[0])
     183                        if maxval>upperbound:
     184                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
     185
    171186        if options.exist('<'):
    172187                upperbound=options.getfieldvalue('<')
    173                 field2 = np.reshape(field,(np.prod(np.shape(field)),1),order='F').copy()
    174                 if options.getfieldvalue('timeseries',0):
    175                         field2 = np.reshape(field[:-1],np.prod(np.shape(field[:-1])),1)
    176 
    177                 if options.getfieldvalue('singletimeseries',0):
    178                         field2 = np.reshape(field[0],int(np.prod(np.shape(field[0]))),1)
    179 
    180                 if np.any(field2>=upperbound):
    181                         md = md.checkmessage(options.getfieldvalue('message',\
    182                                 "field '%s' should have values below %d" % (fieldname,upperbound)))
     188                if np.size(upperbound)>1: #checking elementwise
     189                        if any(field>=upperbound):
     190                                md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
     191
     192                else:
     193                        maxval=np.nanmax(field)
     194                        if options.getfieldvalue('timeseries',0):
     195                                maxval=np.nanmax(field[:-1])
     196                        elif options.getfieldvalue('singletimeseries',0):
     197                                if np.size(field)==1: #some singletimeseries are just one value
     198                                        maxval=field.copy()
     199                                else:
     200                                        maxval=np.nanmax(field[0])
     201
     202                                if maxval>=upperbound:
     203                                        md = md.checkmessage(options.getfieldvalue('message',"field '%s' should have values below %d" % (fieldname,upperbound)))
    183204
    184205        #check file
Note: See TracChangeset for help on using the changeset viewer.