#sfset contains the unique values of sf disset=set(dis) dissetcount=[(x, dis.count(x)) for x in disset] dissetcountdict=dict(dissetcount) #sfsetcountdict is a dictionary whose keys are weather and values are # reported ############# hours = dict(observing=obstothr, ToO=tootothr, engineering=engtothr, sys_failure=systothr, weather=wthrtothr) #gather up the seeing values in a list minseelist=[eval(i.minsee) for i in nights if (i.hrobs >0 and i.minsee!='miminum seeing')]#'miminum is not a typo!' maxseelist=[eval(i.maxsee) for i in nights if ((i.hrobs >0) and (i.maxsee != 'Maximum seeing'))] #make charts nr_charts.dispositionchart(dissetcountdict) nr_charts.timepie(hours) nr_charts.failurechart(sfsetcountdict) nr_charts.weatherchart(wsetcountdict) #print our results ''' print '-------------------------' print 'weather types experienced' print '-------------------------' for key in wsetcountdict: print key, wsetcountdict[key] print '---------------------------' print 'system failures experienced' print '---------------------------' for key in sfsetcountdict: if key!='': print key, sfsetcountdict[key]
sys_failure=systothr, weather=wthrtothr) #gather up the seeing values in a list minseelist = [ eval(i.minsee) for i in nights if (i.hrobs > 0 and i.minsee != 'miminum seeing') ] #'miminum is not a typo!' maxseelist = [ eval(i.maxsee) for i in nights if ((i.hrobs > 0) and (i.maxsee != 'Maximum seeing')) ] #make charts nr_charts.dispositionchart(dissetcountdict) nr_charts.timepie(hours) nr_charts.failurechart(sfsetcountdict) nr_charts.weatherchart(wsetcountdict) #print our results ''' print '-------------------------' print 'weather types experienced' print '-------------------------' for key in wsetcountdict: print key, wsetcountdict[key] print '---------------------------' print 'system failures experienced' print '---------------------------' for key in sfsetcountdict: if key!='': print key, sfsetcountdict[key]
def createHTML(datestart,tele): table=ReadResponse(tele) tableMonth=table[ (table['SMARTS Date (BON)'] >= int(datestart)) & (table['SMARTS Date (BON)'] < int(datestart) + 100)] weather=countUniq(tableMonth,'Weather Types Experienced') sysfail=countUniq(tableMonth, 'System Failures Experienced') disposition=countUniq(tableMonth, 'Disposition of the Night') hrobs=tableMonth['Hours Observing [Scheduled Science]'].sum() hrswthr=tableMonth['Hours Lost to Weather'].sum() hreng=tableMonth['Hours Engineering'].sum() hrsys=tableMonth['Hours Lost to System Failures'].sum() hrsToO=tableMonth['Hours spent doing ToO'].sum() hours={"observing":hrobs, "weather":hrswthr, "engineering":hreng, "sys_failure":hrsys, "ToO":hrsToO} #make charts nr_charts.dispositionchart(disposition,datestart,tele) nr_charts.weatherchart(weather,datestart,tele) nr_charts.failurechart(sysfail,datestart,tele) nr_charts.timepie(hours,datestart,tele) #make the html page fileHTML=open(str(tele)+'-m-'+datestart+'report.html','w') fileHTML.write('<html>') fileHTML.write('<head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 5px;text-align: left;}</style></head>') fileHTML.write('<body><h1>SMARTS '+str(tele)+'-m Night Report Summary '+datestart+'</h1>') fileHTML.write('<p><em>created on '+datetime.datetime.today().isoformat(' ')+'</em></p>') fileHTML.write('<p><em>Total Nights :'+str(len(tableMonth))+'</em></p>') if tele==1.3: bonseestat=columnCalc(tableMonth,'Seeing (BON)') monseestat=columnCalc(tableMonth,'Seeing (Middle of Night)') eonseestat=columnCalc(tableMonth,'Seeing (EON)') projdict, noObs = tallyascii(datestart) fileHTML.write('<p><em>Nights With No Observing : '+str(noObs)+'</em></p>') fileHTML.write('<fieldset><h3>Observing Conditions</h3>') cond=countUniq(tableMonth,'Program used') nr_charts.condpie(cond,datestart) fileHTML.write('<img src="'+datestart+'conditions.png" align="left" width="500px">') parseHTMLtable(cond,fileHTML,['Program Used','Total']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Science Observation Break Down</h3>') projtime={} for key in projdict: projtime[key]=np.around(projdict[key]['time']/3600, decimals=1) nr_charts.breakdownpie(projdict,datestart) fileHTML.write('<img src="'+datestart+'breakdown.png" align="left" width="500px">') parseHTMLtable(projtime,fileHTML,['Project ID','Hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Seeing Conditions<h3>') bonclean=np.where(tableMonth['Seeing (BON)'].__array__()!='n/a') monclean=np.where(tableMonth['Seeing (Middle of Night)'].__array__()!='n/a') eonclean=np.where(tableMonth['Seeing (EON)'].__array__()!='n/a') times=np.array([datetime.datetime.strptime(i, "%m/%d/%Y %H:%M:%S") for i in tableMonth['Timestamp'].__array__()]) nr_charts.seeingtime(times,[tableMonth['Seeing (BON)'],tableMonth['Seeing (Middle of Night)'],tableMonth['Seeing (EON)']], [bonclean,monclean,eonclean],datestart,tele) fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'seeing.png" align="left" width="500px">') parseHTMLtable(bonseestat,fileHTML,['BON Statistic','Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(monseestat,fileHTML,['MON Statistic','Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(eonseestat,fileHTML,['EON Statistic','Seeing Value']) fileHTML.write('</fieldset>') elif tele==1.5: fileHTML.write('<fieldset><h3>Seeing Conditions<h3>') maxseestat=columnCalc(tableMonth,'Maximum Seeing') minseestat=columnCalc(tableMonth,'Minimum Seeing') maxsclean=np.where(tableMonth['Maximum Seeing'].__array__()!='n/a') minsclean=np.where(tableMonth['Minimum Seeing'].__array__()!='n/a') times=np.array([datetime.datetime.strptime(i, "%m/%d/%Y %H:%M:%S") for i in tableMonth['Timestamp'].__array__()]) nr_charts.seeingtime(times,[tableMonth['Maximum Seeing'],tableMonth['Minimum Seeing']], [maxsclean,minsclean],datestart,tele) fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'seeing.png" align="left" width="500px">') parseHTMLtable(maxseestat,fileHTML,['BON Statistic','Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(minseestat,fileHTML,['EON Statistic','Seeing Value']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Time Loss & Observing</h3>') fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'hours.png" align="left" width="500px">') parseHTMLtable(hours,fileHTML,['task','hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset>') fileHTML.write('<h3>Weather Conditions</h3>') fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'weather.png" align="left" width="500px">') parseHTMLtable(weather,fileHTML,['conditions','hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>System Failures</h3>') fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'systemfail.png" align="left" width="500px">') parseHTMLtable(sysfail,fileHTML,['failure','freq.']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Night Disposition</h3>') fileHTML.write('<img src="'+str(tele)+'-m-'+datestart+'disposition.png" align="left" width="500px">') parseHTMLtable(disposition,fileHTML,['Disposition','freq.']) fileHTML.write('</fieldset>') fileHTML.write('</body></html>') fileHTML.close() return
def createHTML(datestart, tele): table = ReadResponse(tele) tableMonth = table[(table['SMARTS Date (BON)'] >= int(datestart)) & (table['SMARTS Date (BON)'] < int(datestart) + 100)] weather = countUniq(tableMonth, 'Weather Types Experienced') sysfail = countUniq(tableMonth, 'System Failures Experienced') disposition = countUniq(tableMonth, 'Disposition of the Night') hrobs = tableMonth['Hours Observing [Scheduled Science]'].sum() hrswthr = tableMonth['Hours Lost to Weather'].sum() hreng = tableMonth['Hours Engineering'].sum() hrsys = tableMonth['Hours Lost to System Failures'].sum() hrsToO = tableMonth['Hours spent doing ToO'].sum() hours = { "observing": hrobs, "weather": hrswthr, "engineering": hreng, "sys_failure": hrsys, "ToO": hrsToO } #make charts nr_charts.dispositionchart(disposition, datestart, tele) nr_charts.weatherchart(weather, datestart, tele) nr_charts.failurechart(sysfail, datestart, tele) nr_charts.timepie(hours, datestart, tele) #make the html page fileHTML = open(str(tele) + '-m-' + datestart + 'report.html', 'w') fileHTML.write('<html>') fileHTML.write( '<head><style>table, th, td {border: 1px solid black;border-collapse: collapse;}th, td {padding: 5px;text-align: left;}</style></head>' ) fileHTML.write('<body><h1>SMARTS ' + str(tele) + '-m Night Report Summary ' + datestart + '</h1>') fileHTML.write('<p><em>created on ' + datetime.datetime.today().isoformat(' ') + '</em></p>') fileHTML.write('<p><em>Total Nights :' + str(len(tableMonth)) + '</em></p>') if tele == 1.3: bonseestat = columnCalc(tableMonth, 'Seeing (BON)') monseestat = columnCalc(tableMonth, 'Seeing (Middle of Night)') eonseestat = columnCalc(tableMonth, 'Seeing (EON)') projdict, noObs = tallyascii(datestart) fileHTML.write('<p><em>Nights With No Observing : ' + str(noObs) + '</em></p>') fileHTML.write('<fieldset><h3>Observing Conditions</h3>') cond = countUniq(tableMonth, 'Program used') nr_charts.condpie(cond, datestart) fileHTML.write('<img src="' + datestart + 'conditions.png" align="left" width="500px">') parseHTMLtable(cond, fileHTML, ['Program Used', 'Total']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Science Observation Break Down</h3>') projtime = {} for key in projdict: projtime[key] = np.around(projdict[key]['time'] / 3600, decimals=1) nr_charts.breakdownpie(projdict, datestart) fileHTML.write('<img src="' + datestart + 'breakdown.png" align="left" width="500px">') parseHTMLtable(projtime, fileHTML, ['Project ID', 'Hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Seeing Conditions<h3>') bonclean = np.where(tableMonth['Seeing (BON)'].__array__() != 'n/a') monclean = np.where( tableMonth['Seeing (Middle of Night)'].__array__() != 'n/a') eonclean = np.where(tableMonth['Seeing (EON)'].__array__() != 'n/a') times = np.array([ datetime.datetime.strptime(i, "%m/%d/%Y %H:%M:%S") for i in tableMonth['Timestamp'].__array__() ]) nr_charts.seeingtime(times, [ tableMonth['Seeing (BON)'], tableMonth['Seeing (Middle of Night)'], tableMonth['Seeing (EON)'] ], [bonclean, monclean, eonclean], datestart, tele) fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'seeing.png" align="left" width="500px">') parseHTMLtable(bonseestat, fileHTML, ['BON Statistic', 'Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(monseestat, fileHTML, ['MON Statistic', 'Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(eonseestat, fileHTML, ['EON Statistic', 'Seeing Value']) fileHTML.write('</fieldset>') elif tele == 1.5: fileHTML.write('<fieldset><h3>Seeing Conditions<h3>') maxseestat = columnCalc(tableMonth, 'Maximum Seeing') minseestat = columnCalc(tableMonth, 'Minimum Seeing') maxsclean = np.where(tableMonth['Maximum Seeing'].__array__() != 'n/a') minsclean = np.where(tableMonth['Minimum Seeing'].__array__() != 'n/a') times = np.array([ datetime.datetime.strptime(i, "%m/%d/%Y %H:%M:%S") for i in tableMonth['Timestamp'].__array__() ]) nr_charts.seeingtime( times, [tableMonth['Maximum Seeing'], tableMonth['Minimum Seeing']], [maxsclean, minsclean], datestart, tele) fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'seeing.png" align="left" width="500px">') parseHTMLtable(maxseestat, fileHTML, ['BON Statistic', 'Seeing Value']) fileHTML.write('<br><br>') parseHTMLtable(minseestat, fileHTML, ['EON Statistic', 'Seeing Value']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Time Loss & Observing</h3>') fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'hours.png" align="left" width="500px">') parseHTMLtable(hours, fileHTML, ['task', 'hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset>') fileHTML.write('<h3>Weather Conditions</h3>') fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'weather.png" align="left" width="500px">') parseHTMLtable(weather, fileHTML, ['conditions', 'hours']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>System Failures</h3>') fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'systemfail.png" align="left" width="500px">') parseHTMLtable(sysfail, fileHTML, ['failure', 'freq.']) fileHTML.write('</fieldset>') fileHTML.write('<fieldset><h3>Night Disposition</h3>') fileHTML.write('<img src="' + str(tele) + '-m-' + datestart + 'disposition.png" align="left" width="500px">') parseHTMLtable(disposition, fileHTML, ['Disposition', 'freq.']) fileHTML.write('</fieldset>') fileHTML.write('</body></html>') fileHTML.close() return