Changeset 80
- Timestamp:
- 10/07/11 14:25:08
- Files:
-
- sodarplot/trunk/sodarplot/scintec/meanspeed.py (modified) (4 diffs)
- sodarplot/trunk/sodarplot/scintec/winddist.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodarplot/trunk/sodarplot/scintec/meanspeed.py
r78 r80 1 import os,datetime,glob 1 import os,datetime,glob 2 import multiprocessing 2 3 import numpy as np 3 4 import matplotlib as mpl … … 44 45 </body> 45 46 </html>""" 46 47 first = True 48 for previous,ncFile,next in files: 47 48 def _components(fileSpec): 49 "Figure out year and month from file specification." 50 51 fileName = os.path.splitext(os.path.basename(fileSpec))[0] 52 year = fileName[-7:-3] 53 month = fileName[-2:] 54 monthName = datetime.datetime(int(year),int(month),1).strftime('%B') 55 return (fileName, year, month, monthName) 56 57 def meanspeed((previous, ncFile, next), pngDir, genHtml=False, lastMonth=False): 49 58 print 'Processing',ncFile 50 ncFileName = os.path.splitext(os.path.basename(ncFile))[0] 51 year = ncFileName[19:23] 52 month = ncFileName[24:26] 53 month = datetime.datetime(int(year),int(month),1).strftime('%B') 54 if previous: 55 previous = os.path.splitext(os.path.basename(previous))[0] 56 previousYear = previous[19:23] 57 previousMonth = previous[24:26] 58 previousMonth = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B') 59 previous = previous + os.extsep + htmlExt 60 if next: 61 next = os.path.splitext(os.path.basename(next))[0] 62 nextYear = next[19:23] 63 nextMonth = next[24:26] 64 nextMonth = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B') 65 next = next + os.extsep + htmlExt 59 ncFileName, year, month, monthName = _components(ncFile) 60 previous, previousYear, previousMonth, previousMonthName = _components(previous) 61 next, nextYear, nextMonth, nextMonthName = _components(next) 66 62 67 63 nc = pycdf.CDF(ncFile) … … 100 96 fig = figure() 101 97 fig.subplots_adjust(hspace=0.3) 102 spt = suptitle('Billy Mitchell Sodar :: ' + month + " " + year)98 spt = suptitle('Billy Mitchell Sodar :: ' + monthName + " " + year) 103 99 104 100 subplot(2,4,1) … … 189 185 print 'Saving', outFile 190 186 fig.savefig(outFile) 191 192 htmlFile = os.path.join(pngDir,ncFileName + os.extsep + htmlExt) 193 html = html1 + month + " " + year 194 html = html + html2 + previous + html3 + next + html4 195 html = html + os.path.basename(outFile) + html5 196 handle = open(htmlFile,'w') 197 handle.write(html) 198 handle.close() 199 200 if first: 201 first = False 202 htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) 187 fig.clear() 188 189 if genHtml: 190 htmlFile = os.path.join(pngDir,ncFileName + os.extsep + htmlExt) 191 html = html1 + month + " " + year 192 html = html + html2 + previous + os.extsep + htmlExt 193 html = html + html3 + next + os.extsep + htmlExt + html4 194 html = html + os.path.basename(outFile) + html5 203 195 handle = open(htmlFile,'w') 204 196 handle.write(html) 205 197 handle.close() 198 199 if lastMonth: 200 htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) 201 handle = open(htmlFile,'w') 202 handle.write(html) 203 handle.close() 206 204 207 205 if __name__ == "__main__": 206 lastMonth = False 207 for previous,ncFile,next in files: 208 if next <= ncFile: 209 lastMonth = True 210 p = multiprocessing.Process(target=meanspeed, args=((previous, ncFile, next), pngDir, True, lastMonth)) 211 p.start() 212 p.join() 213 if p.exitcode: 214 print "Exitcode %s from processing %s" % (p.exitcode, ncFile) sodarplot/trunk/sodarplot/scintec/winddist.py
r79 r80 48 48 <a href=\"""" 49 49 50 html7 = """\">Next Elevation></a> 51 <a href=\"all.html\"><All At Once></a> 50 html7 = """\">Next Elevation></a> 52 51 </form> 53 52 <br/> … … 67 66 return (fileName, year, month, monthName) 68 67 69 def winddist((previous, ncFile, next), pngDir, genHtml=False, firstMonth=False):68 def winddist((previous, ncFile, next), pngDir, genHtml=False, lastMonth=False): 70 69 print 'Processing',ncFile 71 70 ncFileName, year, month, monthName = _components(ncFile) … … 156 155 handle.close() 157 156 158 if firstMonth and firstElevation:157 if lastMonth and firstElevation: 159 158 firstElevation = False 160 159 htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) … … 164 163 165 164 if __name__ == "__main__": 166 firstMonth = True165 lastMonth = False 167 166 for previous,ncFile,next in files: 168 p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, True, firstMonth)) 167 if next <= ncFile: 168 lastMonth = True 169 p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, True, lastMonth)) 169 170 p.start() 170 171 p.join() 171 172 if p.exitcode: 172 173 print "Exitcode %s from processing %s" % (p.exitcode, ncFile) 173 firstMonth = False