@@ -9,10 +9,9 @@ from __future__ import unicode_literals
9
9
import sys
10
10
import argparse
11
11
import warnings
12
- warnings .simplefilter ('once' )
13
12
import glob
14
13
import numpy as np
15
- from matplotlib . mlab import rec2txt
14
+ import astropy . table as at
16
15
import WDmodel .io
17
16
18
17
@@ -28,6 +27,8 @@ def get_options(args=None):
28
27
help = "Specify a custom output root directory. Directories go under outroot/objname/subdir." )
29
28
parser .add_argument ('-o' , '--outdir' , required = False ,\
30
29
help = "Specify a custom output directory. Default is CWD+objname/ subdir" )
30
+ parser .add_argument ('-v' , '--verbose' , help = "print warnings" ,
31
+ action = "store_true" )
31
32
args = parser .parse_args (args = args )
32
33
return args
33
34
@@ -43,6 +44,8 @@ def main(inargs=None):
43
44
else :
44
45
specfiles = args .specfiles
45
46
47
+ verbose = args .verbose
48
+
46
49
out = []
47
50
colnames = []
48
51
colbool = False
@@ -53,8 +56,9 @@ def main(inargs=None):
53
56
try :
54
57
params = WDmodel .io .read_params (outfile )
55
58
except IOError as e :
56
- message = 'Could not get results for {}({}) from outfile {}' .format (objname , specfile , outfile )
57
- warnings .warn (message )
59
+ if verbose :
60
+ message = 'Could not get results for {}({}) from outfile {}' .format (objname , specfile , outfile )
61
+ warnings .warn (message )
58
62
params = None
59
63
continue
60
64
this_out = []
@@ -74,10 +78,15 @@ def main(inargs=None):
74
78
colbool = True
75
79
out .append (this_out )
76
80
colnames = [str (x ) for x in colnames ]
77
- out = np .rec .fromrecords (out , names = colnames )
78
- out .sort ()
79
- precision = [None , None ] + [2 ,2 ,2 ]* 7 + [5 ,5 ,5 ] + [2 ,2 ,2 ] + [4 ,4 ,4 ]
80
- print (rec2txt (out , precision = precision ))
81
+
82
+ out = at .Table (rows = out , names = colnames )
83
+ out .sort ('obj' )
84
+
85
+ collengths = [2 ,2 ,2 ]* 7 + [5 ,5 ,5 ] + [2 ,2 ,2 ] + [4 ,4 ,4 ]
86
+ for i , col in enumerate (colnames [2 :]):
87
+ out [col ].format = '%0.{}f' .format (collengths [i ])
88
+ out .write ('result_table.dat' , format = 'ascii' , overwrite = True )
89
+ print (out )
81
90
82
91
83
92
if __name__ == '__main__' :
0 commit comments