55import numpy as np
66from numpy import linalg as LA
77import sys
8+ from pathlib import Path
89
910def get_cov (filename ):
1011
@@ -27,9 +28,15 @@ def get_cov(filename):
2728
2829if __name__ == '__main__' :
2930
31+ if len (sys .argv ) != 3 :
32+ print ("Usage: python cosmocov_process.py <input_file> <output_stub>" )
33+ sys .exit (1 )
34+
3035 covfile = sys .argv [1 ]
36+ output_base = sys .argv [2 ]
37+
38+ c_g , c_ng , ndata = get_cov (covfile )
3139
32- c_g , c_ng , ndata = get_cov (covfile )
3340 cov = c_ng + c_g
3441 cov_g = c_g
3542
@@ -45,11 +52,11 @@ def get_cov(filename):
4552 for i in range (ndata ):
4653 pp_var .append (cov [i ][i ])
4754
48- np .savetxt (covfile + '.txt' ,cov )
49- print ("covmat saved as %s" % covfile + '.txt' )
55+ np .savetxt (str ( output_base ) + '.txt' ,cov )
56+ print ("covmat saved as %s" % ( str ( output_base ) + '.txt' ) )
5057
51- np .savetxt (covfile + '_g.txt' ,cov_g )
52- print ("Gaussian covmat saved as %s" % covfile + '_g.txt' )
58+ np .savetxt (str ( output_base ) + '_g.txt' ,cov_g )
59+ print ("Gaussian covmat saved as %s" % ( str ( output_base ) + '_g.txt' ) )
5360
5461 cmap = 'seismic'
5562
@@ -60,7 +67,7 @@ def get_cov(filename):
6067
6168 print ("Plotting correlation matrix ..." )
6269
63- plot_path = covfile + '_plot.pdf'
70+ plot_path = str ( output_base ) + '_plot.pdf'
6471 fig = plt .figure ()
6572 ax = fig .add_subplot (1 , 1 , 1 )
6673 extent = (0 , ndata , ndata , 0 )
0 commit comments