-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_info_stats.py
48 lines (37 loc) · 1.48 KB
/
table_info_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def table_info_stats(table=None, short=False, stats=True, debug=False):
"""print some info about astropy table
CAVEAT: astropy does some fancy masking when there is missing/bad data
"""
ncolumns=len(table.columns)
print('Number of rows: ', len(table))
print('Number of columns: ', ncolumns)
print('meta: ', table.meta)
print('dtype: ', table.dtype)
print('colnames: ', table.colnames)
columns = table.columns
if debug: print(table)
if debug: print(len(table.columns[0]))
if debug: print(len(table.field(0)))
#help(table.columns)
#help(table.field)
if stats or not short:
for i in xrange(ncolumns):
j=0
# process the columns that are 1D vectors
if len(table.columns[i].shape) == 1:
try:
print(i, j, table.columns[i].name, table.columns[i].format,\
table.columns[i].shape, len(table.columns[i].shape), \
len(table.columns[i]), \
': ',np.min(table.columns[i]), ' : ',np.max(table.columns[i]))
except:
print(i, j, table.columns[i].name, 'problem with column')
pass
# process the columns that are 2D vectors (i,j)
if len(table.columns[i].shape) == 2:
for j in xrange(table.columns[i].shape[1]):
print(i,j, columns[i].name, columns[i].format, \
columns[i].dim, table.columns[i].shape, \
len(table.field(i).shape), \
len(table.field(i)), \
': ',np.min(table.field(i)[j]),' : ',np.max(table.columns[i][j]))