Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 969:5d788d2e8ffc
work in progress
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 07 Dec 2017 17:03:09 -0500 |
| parents | d8ab183a7351 |
| children | 9897a13772fb |
comparison
equal
deleted
inserted
replaced
| 968:32a34a143c27 | 969:5d788d2e8ffc |
|---|---|
| 10 from scipy.sparse import dok_matrix | 10 from scipy.sparse import dok_matrix |
| 11 from numpy import zeros, array, exp, sum as npsum, int as npint, arange, cumsum, median, isnan, ones, convolve, dtype, isnan, NaN, mean, ma, isinf, savez, load as npload, log | 11 from numpy import zeros, array, exp, sum as npsum, int as npint, arange, cumsum, median, isnan, ones, convolve, dtype, isnan, NaN, mean, ma, isinf, savez, load as npload, log |
| 12 | 12 |
| 13 | 13 |
| 14 datetimeFormat = "%Y-%m-%d %H:%M:%S" | 14 datetimeFormat = "%Y-%m-%d %H:%M:%S" |
| 15 | |
| 16 sjcamDatetimeFormat = "%Y_%m%d_%H%M%S"#2017_0626_143720 | |
| 15 | 17 |
| 16 ######################### | 18 ######################### |
| 17 # Strings | 19 # Strings |
| 18 ######################### | 20 ######################### |
| 19 | 21 |
| 937 if i>0: | 939 if i>0: |
| 938 return filename[:i] | 940 return filename[:i] |
| 939 else: | 941 else: |
| 940 return filename | 942 return filename |
| 941 | 943 |
| 944 def getExtension(filename, delimiter = '.'): | |
| 945 '''Returns the filename minus the extension (all characters after last .)''' | |
| 946 i = filename.rfind(delimiter) | |
| 947 if i>0: | |
| 948 return filename[i+1:] | |
| 949 else: | |
| 950 return '' | |
| 951 | |
| 942 def cleanFilename(s): | 952 def cleanFilename(s): |
| 943 'cleans filenames obtained when contatenating figure characteristics' | 953 'cleans filenames obtained when contatenating figure characteristics' |
| 944 return s.replace(' ','-').replace('.','').replace('/','-').replace(',','') | 954 return s.replace(' ','-').replace('.','').replace('/','-').replace(',','') |
| 945 | 955 |
| 946 def listfiles(dirname, extension, remove = False): | 956 def listfiles(dirname, extension, remove = False): |
