Changeset 79
- Timestamp:
- 10/06/11 16:13:19
- Files:
-
- sodarplot/trunk/sodarplot/scintec/winddist.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodarplot/trunk/sodarplot/scintec/winddist.py
r78 r79 20 20 ncFilePattern = os.path.join(ncDir,ncFileGlob) 21 21 files = glob.glob(ncFilePattern) 22 # files = files[:-1] # sodar was broken last month23 # files = files[-4:]24 22 previous = [files[-1]] + files[:-1] 25 23 next = files[1:] + [files[0]] … … 59 57 </body> 60 58 </html>""" 59 60 def _components(fileSpec): 61 "Figure out year and month from file specification." 62 63 fileName = os.path.splitext(os.path.basename(fileSpec))[0] 64 year = fileName[-7:-3] 65 month = fileName[-2:] 66 monthName = datetime.datetime(int(year),int(month),1).strftime('%B') 67 return (fileName, year, month, monthName) 61 68 62 69 def winddist((previous, ncFile, next), pngDir, genHtml=False, firstMonth=False): 63 print 'Processing',ncFile 64 ncFileName = os.path.splitext(os.path.basename(ncFile))[0] 65 year = ncFileName[19:23] 66 month = ncFileName[24:26] 67 monthName = datetime.datetime(int(year),int(month),1).strftime('%B') 68 if previous: 69 previous = os.path.splitext(os.path.basename(previous))[0] 70 previousYear = previous[19:23] 71 previousMonth = previous[24:26] 72 previousMonthName = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B') 73 if next: 74 next = os.path.splitext(os.path.basename(next))[0] 75 nextYear = next[19:23] 76 nextMonth = next[24:26] 77 nextMonthName = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B') 70 print 'Processing',ncFile 71 ncFileName, year, month, monthName = _components(ncFile) 72 previous, previousYear, previousMonth, previousMonthName = _components(previous) 73 next, nextYear, nextMonth, nextMonthName = _components(next) 78 74 79 75 nc = pycdf.CDF(ncFile) … … 155 151 html = html + html5 + ncFileName + "_" + ('%dm' % z[previousX]) + os.extsep + htmlExt 156 152 html = html + html6 + ncFileName + "_" + ('%dm' % z[nextX]) + os.extsep + htmlExt 157 html = html + html7 + os.path.join( ncFileName,os.path.basename(outFile)) + html8153 html = html + html7 + os.path.join(dirName,os.path.basename(outFile)) + html8 158 154 handle = open(htmlFile,'w') 159 155 handle.write(html) … … 170 166 firstMonth = True 171 167 for previous,ncFile,next in files: 172 p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, {'genHtml':True, 'firstMonth':firstMonth}))168 p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, True, firstMonth)) 173 169 p.start() 174 170 p.join()