-
Notifications
You must be signed in to change notification settings - Fork 2
/
DataEditor.py
70 lines (55 loc) · 1.77 KB
/
DataEditor.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Style:PEP-8
"""
Created on Thu Sep 7 10:20:35 2017
@author: anto
"""
__author__ = "Anto I Lonappan"
__copyright__ = "Copyright 2017, MB-II analysis Project, Presidency University"
__date__ = "14-Sep-2017"
__version__ = "0.0"
__email__ = "antoidicherian@gmail.com"
__status__ = "Completed"
# PYTHON LIBRARIES
import numpy as np
import _pickle as pl
from configparser import ConfigParser as cnf
# CONFIGURATION
conf = cnf()
conf.read('abe.ini')
output_dir = conf.get('live', 'cat_anl_out')
last_program = conf.get('live', 'last_program')
mode_run = conf.get('misc', 'mode_run')
if mode_run == 'automated':
if not last_program == 'CatalogAnalyser_MPI.py':
print("""
I found Last program that you have run was {}
Before running this code please run DataEditor.py.
Also see abe.ini
""".format(last_program))
raise Exception('PreviousRunError')
else:
pass
elif mode_run == 'individual':
pass
XH = 0.76
with open('%s/dataUpd.p' % output_dir, 'rb') as fr:
data = pl.load(fr)
Real_data = data.copy()
bhs = list(data.keys())
def temperature(internal_E, ElectronAb):
return 120.99 * (2./3.) * internal_E/(ElectronAb *
XH + (1.-XH) * 0.25 + XH)
for bh in bhs:
dummy = data[bh]
temp = temperature(dummy[:, 0], dummy[:, -1])
dummy1 = np.array([temp, dummy[:, 1], dummy[:, 2], dummy[:, 3],
dummy[:, 4], dummy[:, 5]])
data[bh] = dummy1.T
with open('%s/dataEdt.p' % output_dir,'wb') as fw:
pl.dump(data, fw)
print('Edited')
conf.set('live', 'last_program', 'DataEditor.py')
with open('abe.ini', 'w') as fw:
conf.write(fw)