def addQualityTable(image, usedCounts, visCounts): # Create the table using TaQL. tab = pt.taql("create table '" + image.name() + "/LOFAR_QUALITY' " + "QUALITY_MEASURE string, VALUE string, FLAG_ROW bool") # Get the rms noise of I,Q,U,V as list of tuples. noises = grn.get_rms_noise(image.name()) for noise in noises: row = tab.nrows() tab.addrows(2) tab.putcell("QUALITY_MEASURE", row, "RMS_NOISE_" + noise[0]) tab.putcell("VALUE", row, str(noise[1])) tab.putcell("FLAG_ROW", row, False) perc = 100. nvis = 1.0 * visCounts.sum() if nvis > 0: # Get flagged percentage to 2 decimals. perc = int(10000. * (1 - usedCounts.sum() / nvis) + 0.5) / 100. tab.putcell("QUALITY_MEASURE", row + 1, "PERC_FLAGGED_VIS") tab.putcell("VALUE", row + 1, str(perc)[:5]) tab.putcell("FLAG_ROW", row + 1, False) tab.flush() image.putkeyword("ATTRGROUPS." + "LOFAR_QUALITY", tab) print "Added subtable LOFAR_QUALITY containing", tab.nrows(), "rows" tab.close()
def addQualityTable (image, usedCounts, visCounts): # Create the table using TaQL. tab = pt.taql ("create table '" + image.name() + "/LOFAR_QUALITY' " + "QUALITY_MEASURE string, VALUE string, FLAG_ROW bool") # Get the rms noise of I,Q,U,V as list of tuples. noises = grn.get_rms_noise (image.name()) for noise in noises: row = tab.nrows() tab.addrows (2) tab.putcell ("QUALITY_MEASURE", row, "RMS_NOISE_"+noise[0]) tab.putcell ("VALUE", row, str(noise[1])) tab.putcell ("FLAG_ROW", row, False) perc = 100. nvis = 1.0 * visCounts.sum() if nvis > 0: # Get flagged percentage to 2 decimals. perc = int(10000. * (1 - usedCounts.sum() / nvis) + 0.5) / 100. tab.putcell ("QUALITY_MEASURE", row+1, "PERC_FLAGGED_VIS") tab.putcell ("VALUE", row+1, str(perc)[:5]) tab.putcell ("FLAG_ROW", row+1, False) tab.flush() image.putkeyword ("ATTRGROUPS." + "LOFAR_QUALITY", tab) print "Added subtable LOFAR_QUALITY containing", tab.nrows(), "rows" tab.close()