Changeset 572


Ignore:
Timestamp:
Mar 7, 2012, 7:56:37 PM (13 years ago)
Author:
aslmd
Message:

UTIL PYTHON: solved problem in previous commit for windamplitude. tested sparse.py and fixed minor problems: use == instead of is and implemented the use of ftype.

Location:
trunk/UTIL/PYTHON
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myplot.py

    r571 r572  
    9393
    9494## Author: AC
    95 def windamplitude (nc)
     95def windamplitude (nc):
    9696    varinfile = nc.variables.keys()
    9797    if "U" in varinfile: zu=getfield(nc,'U')
     
    10411041## Read sparse data
    10421042  from numpy import empty
    1043   if datatype is 'txt':
     1043  if datatype == 'txt':
    10441044     if len(data[coord1].shape) == 1:
    10451045         return data[coord1][:]
     
    10481048     else:
    10491049         errormess('error in readdata')
    1050   elif datatype is 'sav':
     1050  elif datatype == 'sav':
    10511051     return data[coord1][coord2]
    10521052  else:
  • trunk/UTIL/PYTHON/sparse.py

    r568 r572  
    111111   
    112112##### Find file type
    113      if filename[k].find('.sav') is not -1:
    114         all_type[k] ='sav'
    115         print '.sav file detected for', filename[k],'!!'
    116      elif filename[k].find('.txt') is not -1:
    117         all_type[k] ='txt'
    118         #print '.txt file detected for', filename[k],'!!'
     113     if opt.ftype is None:
     114      if filename[k].find('.sav') is not -1:
     115         all_type[k] ='sav'
     116         print '.sav file detected for', filename[k],'!!'
     117      elif filename[k].find('.txt') is not -1:
     118         all_type[k] ='txt'
     119         #print '.txt file detected for', filename[k],'!!'
     120      else:
     121         all_type[k] ='txt'
     122         print 'no file type detected for', filename[k],'!!, default type is', all_type[k]
     123     
     124      if all_type[k] != all_type[0]:
     125         print 'Two different types were used: ', all_type[k], all_type[0]
     126         errormess('Not suported')
    119127     else:
    120         all_type[k] ='txt'
    121         print 'no file type detected for', filename[k],'!!, default type is', all_type[k]
    122      
    123      if all_type[k] != all_type[0]:
    124         print 'Two different types were used: ', all_type[k], all_type[0]
    125         errormess('Not suported')
    126 
     128        all_type[k] = opt.ftype       
    127129
    128130##### Read file       
    129      if all_type[k] is 'sav':
     131     if all_type[k] == 'sav':
    130132       print 'reading .sav file', filename[k], '...'
    131133       data = {}
    132134       data = readsav(filename[k], idict=data, python_dict=False) #, verbose=True)
    133135       all_data[k] = data
    134      elif all_type[k] is 'txt':
     136     elif all_type[k] == 'txt':
    135137       print 'reading .text file', filename[k], '...'
    136138       all_data[k] = np.loadtxt(filename[k])
Note: See TracChangeset for help on using the changeset viewer.