Changeset 78
- Timestamp:
- 10/06/11 14:29:05
- Files:
-
- sodarplot/trunk/sodarplot/scintec/meanspeed.py (modified) (8 diffs)
- sodarplot/trunk/sodarplot/scintec/winddist.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodarplot/trunk/sodarplot/scintec/meanspeed.py
r75 r78 68 68 69 69 t = nc.var('time')[:] 70 z = nc.var('z')[:] 70 z = nc.var('z')[:] 71 71 u = nc.var('u')[:] 72 72 v = nc.var('v')[:] … … 107 107 ylabel('Elevation (m)') 108 108 xlim(-8,8) 109 ylim(0, 200)109 ylim(0,int(max(z))) 110 110 xticks(fontsize=spt.get_fontsize()*0.6) 111 111 plot(mumean.data,z,label=r'$\bar{u}$') … … 119 119 xlabel('% of Samples per Month',fontsize=spt.get_fontsize()*0.6) 120 120 xlim(0,100) 121 ylim(0, 200)121 ylim(0,int(max(z))) 122 122 xticks(range(0,101,25),fontsize=spt.get_fontsize()*0.6) 123 123 yticks([]) … … 131 131 xlabel('Velocity (m/s)',fontsize=spt.get_fontsize()*0.6) 132 132 xlim(0,10) 133 ylim(0, 200)133 ylim(0,int(max(z))) 134 134 xticks(fontsize=spt.get_fontsize()*0.6) 135 135 yticks([]) … … 142 142 xlabel('Direction (Wind From)',fontsize=spt.get_fontsize()*0.6) 143 143 xlim(0,360) 144 ylim(0, 200)144 ylim(0,int(max(z))) 145 145 xticks(range(0,361,90),['N','E','S','W','N',], 146 146 fontsize=spt.get_fontsize()*0.6) … … 155 155 ylabel('Elevation (m)') 156 156 xlim(0,16) 157 ylim(0, 200)157 ylim(0,int(max(z))) 158 158 xticks(fontsize=spt.get_fontsize()*0.6) 159 159 plot(mustd.data,z,label=r'$\sigma_u$') … … 167 167 xlabel('% of Samples per Month',fontsize=spt.get_fontsize()*0.6) 168 168 xlim(0,100) 169 ylim(0, 200)169 ylim(0,int(max(z))) 170 170 xticks(range(0,101,25),fontsize=spt.get_fontsize()*0.6) 171 171 yticks([]) … … 179 179 xlabel('Std Dev (m/s)',fontsize=spt.get_fontsize()*0.6) 180 180 xlim(0,10) 181 ylim(0, 200)181 ylim(0,int(max(z))) 182 182 xticks(fontsize=spt.get_fontsize()*0.6) 183 183 yticks([]) sodarplot/trunk/sodarplot/scintec/winddist.py
r77 r78 1 1 import os,datetime,glob 2 import multiprocessing 2 3 import numpy as np 3 4 import matplotlib as mpl … … 19 20 ncFilePattern = os.path.join(ncDir,ncFileGlob) 20 21 files = glob.glob(ncFilePattern) 21 files = files[:-1] # sodar was broken last month 22 # files = files[:-1] # sodar was broken last month 23 # files = files[-4:] 22 24 previous = [files[-1]] + files[:-1] 23 25 next = files[1:] + [files[0]] … … 58 60 </html>""" 59 61 60 firstMonth = True 61 for previous,ncFile,next in files: 62 def winddist((previous, ncFile, next), pngDir, genHtml=False, firstMonth=False): 62 63 print 'Processing',ncFile 63 64 ncFileName = os.path.splitext(os.path.basename(ncFile))[0] 64 65 year = ncFileName[19:23] 65 66 month = ncFileName[24:26] 66 month = datetime.datetime(int(year),int(month),1).strftime('%B')67 monthName = datetime.datetime(int(year),int(month),1).strftime('%B') 67 68 if previous: 68 69 previous = os.path.splitext(os.path.basename(previous))[0] 69 70 previousYear = previous[19:23] 70 71 previousMonth = previous[24:26] 71 previousMonth = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B')72 previousMonthName = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B') 72 73 if next: 73 74 next = os.path.splitext(os.path.basename(next))[0] 74 75 nextYear = next[19:23] 75 76 nextMonth = next[24:26] 76 nextMonth = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B')77 77 nextMonthName = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B') 78 78 79 nc = pycdf.CDF(ncFile) 79 80 … … 126 127 if rho[x].any(): 127 128 fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w') 128 spt = fig.suptitle('Billy Mitchell Sodar :: ' + month + " " + year)129 spt = fig.suptitle('Billy Mitchell Sodar :: ' + monthName + " " + year) 129 130 rect = [0.16, 0.16, 0.68, 0.68] 130 131 ax = WindroseAxes(fig, rect, axisbg='w') … … 138 139 l = ax.legend(axespad=-0.20,title="Magnitude (m/s)") 139 140 plt.setp(l.get_texts(), fontsize=8) 140 if not os.path.exists(os.path.join(pngDir,ncFileName)): 141 os.mkdir(os.path.join(pngDir,ncFileName)) 142 outFile = os.path.join(pngDir,ncFileName,('%dm' % z[x]) + os.extsep + pngExt) 141 dirName = "%4u_%02u" % (int(year), int(month)) 142 if not os.path.exists(os.path.join(pngDir, dirName)): 143 os.mkdir(os.path.join(pngDir, dirName)) 144 outFile = os.path.join(pngDir,dirName,('%03um' % z[x]) + os.extsep + pngExt) 143 145 print 'Saving', outFile 144 146 fig.savefig(outFile) 147 fig.clear() 145 148 146 # htmlFile = os.path.join(pngDir,ncFileName + "_" + ('%dm' % z[x]) + os.extsep + htmlExt) 147 # html = html1 + month + " " + year 148 # html = html + html2 + ('%dm' % z[x]) 149 # html = html + html3 + previous + "_" + ('%dm' % z[x]) + os.extsep + htmlExt 150 # html = html + html4 + next + "_" + ('%dm' % z[x]) + os.extsep + htmlExt 151 # html = html + html5 + ncFileName + "_" + ('%dm' % z[previousX]) + os.extsep + htmlExt 152 # html = html + html6 + ncFileName + "_" + ('%dm' % z[nextX]) + os.extsep + htmlExt 153 # html = html + html7 + os.path.join(ncFileName,os.path.basename(outFile)) + html8 154 # handle = open(htmlFile,'w') 155 # handle.write(html) 156 # handle.close() 149 if genHtml: 150 htmlFile = os.path.join(pngDir,ncFileName + "_" + ('%dm' % z[x]) + os.extsep + htmlExt) 151 html = html1 + monthName + " " + year 152 html = html + html2 + ('%dm' % z[x]) 153 html = html + html3 + previous + "_" + ('%dm' % z[x]) + os.extsep + htmlExt 154 html = html + html4 + next + "_" + ('%dm' % z[x]) + os.extsep + htmlExt 155 html = html + html5 + ncFileName + "_" + ('%dm' % z[previousX]) + os.extsep + htmlExt 156 html = html + html6 + ncFileName + "_" + ('%dm' % z[nextX]) + os.extsep + htmlExt 157 html = html + html7 + os.path.join(ncFileName,os.path.basename(outFile)) + html8 158 handle = open(htmlFile,'w') 159 handle.write(html) 160 handle.close() 157 161 158 # if firstMonth and firstElevation: 159 # firstMonth = False 160 # firstElevation = False 161 # htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) 162 # handle = open(htmlFile,'w') 163 # handle.write(html) 164 # handle.close() 165 162 if firstMonth and firstElevation: 163 firstElevation = False 164 htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) 165 handle = open(htmlFile,'w') 166 handle.write(html) 167 handle.close() 168 169 if __name__ == "__main__": 170 firstMonth = True 171 for previous,ncFile,next in files: 172 p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, {'genHtml':True, 'firstMonth':firstMonth})) 173 p.start() 174 p.join() 175 if p.exitcode: 176 print "Exitcode %s from processing %s" % (p.exitcode, ncFile) 177 firstMonth = False