-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_reader.py
executable file
·42 lines (30 loc) · 1.06 KB
/
log_reader.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 2 22:03:16 2020
@author: asif
"""
import numpy as np
no_of_specs=8
base_name="spec"
def Log_reader(base_name,no_of_specs):
"""Takes in base name and number of spectra as argument. Returns Photon index and normalisation
The data is of the format [lower lim, upper lim, -ve error, +ve error] """
ph_idx=[]
norm=[]
for i in range(no_of_specs):
log_name=base_name+str(i)+".log"
with open(log_name,'r') as reader:
log=reader.readlines()
line=log[-11]
temp=line.strip().split(' ')
temp=[i for i in temp if i !='']
temp1=temp[-1][1:-1].split(',')
ph_idx.append(temp[2:-1]+temp1)
line=log[-7]
temp=line.strip().split(' ')
temp=[i for i in temp if i !='']
temp1=temp[-1][1:-1].split(',')
norm.append(temp[2:-1]+temp1)
return [np.array(ph_idx,dtype=np.float64),np.array(norm,dtype=np.float64)]
ph,nm=Log_reader(base_name,no_of_specs)