Logo coherent WaveBurst  
Library Reference Guide
Logo
h52psd.py
Go to the documentation of this file.
1 # Copyright (C) 2020 Gabriele Vedovato
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 # extract psd from h5 file and save to dat file
17 # uses pesummary package
18 
19 from pesummary.io import write
20 from pesummary.gw.file.read import read
21 import sys
22 import os
23 
24 ifile=sys.argv[1]
25 model=sys.argv[2]
26 ofile_tag=sys.argv[3]
27 
28 def main(ifile,model,ofile_tag):
29 
30  cwd = os.getcwd()
31 
32  print('\nPlease wait while reading file '+cwd+'/'+ifile+' ...')
33 
34  f = read(ifile)
35  print(f.labels)
36 
37  print('\nPlease wait while reading psd '+model+' from file '+cwd+'/'+ifile+'...')
38 
39  psd_dict = f.psd[model]
40  psd_ifos = sorted(list(psd_dict.keys()))
41  print(psd_ifos)
42 
43 
44  for ifo in psd_ifos:
45  print('\nPlease wait while writing psd '+model+' to file '+cwd+'/'+ofile_tag+'_'+ifo+'.dat'+' ...')
46  psd_dict[ifo].save_to_file(ofile_tag+"_"+ifo+".dat", delimiter="\t")
47 
48 main(ifile,model,ofile_tag)
TList * list
def main(ifile, model, ofile_tag)
Definition: h52psd.py:28
iD print()