Source
xxxxxxxxxx
#! /usr/bin/env python
def cmptabs(tab1, tab2):
"""
Returns 1 if any of the columns in tab1 differ from the corresponding ones
in tab2, 0 otherwise.
"""
tabs = (tab1, tab2)
tb.open(tab1)
colnames = set(tb.colnames())
nrows1 = tb.nrows()
tb.close()
tb.open(tab2)
colnames2 = set(tb.colnames())
nrows2 = tb.nrows()
tb.close()
if colnames2 != colnames:
print tab1, "has cols", str(colnames)
print tab2, "has cols", str(colnames2)
return 1
del colnames2
# After this point, both tables are assumed to have some rows, so check now.
if 0 in (nrows1, nrows2):
if nrows1 == nrows2:
return 0
else:
return 1
for col in colnames:
cols = [-1, -1] # Default to a semi-invalid code.
for i in xrange(2):
tb.open(tabs[i])
try:
if tb.iscelldefined(col): # col in colnames does not
cols[i] = tb.getcol(col) # imply col is valid.
except:
print "Error getting", tabs[i], " col =", col
return 1
finally:
tb.close()
diff = cols[0] != cols[1]
if hasattr(diff, 'any'):
diff = diff.any()
if diff:
print col, "differs"
return 1
return 0
def cmpmses(ms1, ms2, subtabs_to_check=['ANTENNA', 'DATA_DESCRIPTION', 'FEED',
'FLAG_CMD', 'FIELD',
'OBSERVATION', 'POINTING',
'POLARIZATION', 'PROCESSOR',
'SPECTRAL_WINDOW', 'STATE',
'SOURCE', 'WEATHER'],
kws_to_check=['MS_VERSION']):
"""
Returns 1 if any of the columns, listed subtables, or listed keywords in
ms1 differ from the corresponding ones in ms2, 0 otherwise.
"""
mses = (ms1, ms2)