Index: sodarplot/trunk/sodarplot/scintec/meanspeed.py =================================================================== --- sodarplot/trunk/sodarplot/scintec/meanspeed.py (revision 75) +++ sodarplot/trunk/sodarplot/scintec/meanspeed.py (revision 78) @@ -68,5 +68,5 @@ t = nc.var('time')[:] - z = nc.var('z')[:] + z = nc.var('z')[:] u = nc.var('u')[:] v = nc.var('v')[:] @@ -107,5 +107,5 @@ ylabel('Elevation (m)') xlim(-8,8) - ylim(0,200) + ylim(0,int(max(z))) xticks(fontsize=spt.get_fontsize()*0.6) plot(mumean.data,z,label=r'$\bar{u}$') @@ -119,5 +119,5 @@ xlabel('% of Samples per Month',fontsize=spt.get_fontsize()*0.6) xlim(0,100) - ylim(0,200) + ylim(0,int(max(z))) xticks(range(0,101,25),fontsize=spt.get_fontsize()*0.6) yticks([]) @@ -131,5 +131,5 @@ xlabel('Velocity (m/s)',fontsize=spt.get_fontsize()*0.6) xlim(0,10) - ylim(0,200) + ylim(0,int(max(z))) xticks(fontsize=spt.get_fontsize()*0.6) yticks([]) @@ -142,5 +142,5 @@ xlabel('Direction (Wind From)',fontsize=spt.get_fontsize()*0.6) xlim(0,360) - ylim(0,200) + ylim(0,int(max(z))) xticks(range(0,361,90),['N','E','S','W','N',], fontsize=spt.get_fontsize()*0.6) @@ -155,5 +155,5 @@ ylabel('Elevation (m)') xlim(0,16) - ylim(0,200) + ylim(0,int(max(z))) xticks(fontsize=spt.get_fontsize()*0.6) plot(mustd.data,z,label=r'$\sigma_u$') @@ -167,5 +167,5 @@ xlabel('% of Samples per Month',fontsize=spt.get_fontsize()*0.6) xlim(0,100) - ylim(0,200) + ylim(0,int(max(z))) xticks(range(0,101,25),fontsize=spt.get_fontsize()*0.6) yticks([]) @@ -179,5 +179,5 @@ xlabel('Std Dev (m/s)',fontsize=spt.get_fontsize()*0.6) xlim(0,10) - ylim(0,200) + ylim(0,int(max(z))) xticks(fontsize=spt.get_fontsize()*0.6) yticks([]) Index: sodarplot/trunk/sodarplot/scintec/winddist.py =================================================================== --- sodarplot/trunk/sodarplot/scintec/winddist.py (revision 77) +++ sodarplot/trunk/sodarplot/scintec/winddist.py (revision 78) @@ -1,3 +1,4 @@ import os,datetime,glob +import multiprocessing import numpy as np import matplotlib as mpl @@ -19,5 +20,6 @@ ncFilePattern = os.path.join(ncDir,ncFileGlob) files = glob.glob(ncFilePattern) -files = files[:-1] # sodar was broken last month +# files = files[:-1] # sodar was broken last month +# files = files[-4:] previous = [files[-1]] + files[:-1] next = files[1:] + [files[0]] @@ -58,22 +60,21 @@ """ -firstMonth = True -for previous,ncFile,next in files: +def winddist((previous, ncFile, next), pngDir, genHtml=False, firstMonth=False): print 'Processing',ncFile ncFileName = os.path.splitext(os.path.basename(ncFile))[0] year = ncFileName[19:23] month = ncFileName[24:26] - month = datetime.datetime(int(year),int(month),1).strftime('%B') + monthName = datetime.datetime(int(year),int(month),1).strftime('%B') if previous: previous = os.path.splitext(os.path.basename(previous))[0] previousYear = previous[19:23] previousMonth = previous[24:26] - previousMonth = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B') + previousMonthName = datetime.datetime(int(previousYear),int(previousMonth),1).strftime('%B') if next: next = os.path.splitext(os.path.basename(next))[0] nextYear = next[19:23] nextMonth = next[24:26] - nextMonth = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B') - + nextMonthName = datetime.datetime(int(nextYear),int(nextMonth),1).strftime('%B') + nc = pycdf.CDF(ncFile) @@ -126,5 +127,5 @@ if rho[x].any(): fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w') - spt = fig.suptitle('Billy Mitchell Sodar :: ' + month + " " + year) + spt = fig.suptitle('Billy Mitchell Sodar :: ' + monthName + " " + year) rect = [0.16, 0.16, 0.68, 0.68] ax = WindroseAxes(fig, rect, axisbg='w') @@ -138,28 +139,39 @@ l = ax.legend(axespad=-0.20,title="Magnitude (m/s)") plt.setp(l.get_texts(), fontsize=8) - if not os.path.exists(os.path.join(pngDir,ncFileName)): - os.mkdir(os.path.join(pngDir,ncFileName)) - outFile = os.path.join(pngDir,ncFileName,('%dm' % z[x]) + os.extsep + pngExt) + dirName = "%4u_%02u" % (int(year), int(month)) + if not os.path.exists(os.path.join(pngDir, dirName)): + os.mkdir(os.path.join(pngDir, dirName)) + outFile = os.path.join(pngDir,dirName,('%03um' % z[x]) + os.extsep + pngExt) print 'Saving', outFile fig.savefig(outFile) + fig.clear() - # htmlFile = os.path.join(pngDir,ncFileName + "_" + ('%dm' % z[x]) + os.extsep + htmlExt) - # html = html1 + month + " " + year - # html = html + html2 + ('%dm' % z[x]) - # html = html + html3 + previous + "_" + ('%dm' % z[x]) + os.extsep + htmlExt - # html = html + html4 + next + "_" + ('%dm' % z[x]) + os.extsep + htmlExt - # html = html + html5 + ncFileName + "_" + ('%dm' % z[previousX]) + os.extsep + htmlExt - # html = html + html6 + ncFileName + "_" + ('%dm' % z[nextX]) + os.extsep + htmlExt - # html = html + html7 + os.path.join(ncFileName,os.path.basename(outFile)) + html8 - # handle = open(htmlFile,'w') - # handle.write(html) - # handle.close() + if genHtml: + htmlFile = os.path.join(pngDir,ncFileName + "_" + ('%dm' % z[x]) + os.extsep + htmlExt) + html = html1 + monthName + " " + year + html = html + html2 + ('%dm' % z[x]) + html = html + html3 + previous + "_" + ('%dm' % z[x]) + os.extsep + htmlExt + html = html + html4 + next + "_" + ('%dm' % z[x]) + os.extsep + htmlExt + html = html + html5 + ncFileName + "_" + ('%dm' % z[previousX]) + os.extsep + htmlExt + html = html + html6 + ncFileName + "_" + ('%dm' % z[nextX]) + os.extsep + htmlExt + html = html + html7 + os.path.join(ncFileName,os.path.basename(outFile)) + html8 + handle = open(htmlFile,'w') + handle.write(html) + handle.close() - # if firstMonth and firstElevation: - # firstMonth = False - # firstElevation = False - # htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) - # handle = open(htmlFile,'w') - # handle.write(html) - # handle.close() - + if firstMonth and firstElevation: + firstElevation = False + htmlFile = os.path.join(pngDir,"index" + os.extsep + htmlExt) + handle = open(htmlFile,'w') + handle.write(html) + handle.close() + +if __name__ == "__main__": + firstMonth = True + for previous,ncFile,next in files: + p = multiprocessing.Process(target=winddist, args=((previous, ncFile, next), pngDir, {'genHtml':True, 'firstMonth':firstMonth})) + p.start() + p.join() + if p.exitcode: + print "Exitcode %s from processing %s" % (p.exitcode, ncFile) + firstMonth = False