forked from KazAndr/temporunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_best_par.py
64 lines (52 loc) · 1.74 KB
/
plot_best_par.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 10 15:14:02 2018
@author: Kazantsev Andrey
03.02.2019
Changes"
Rewriting file for work with best params from file
"""
import os
import numpy as np
import matplotlib.pyplot as plt
name_pulsar = input('Enter name pulsar: ')
par_data = np.genfromtxt('best_par_' + name_pulsar + '.txt', dtype=str).T
with open(name_pulsar + '_start.par', 'r') as file:
lines = file.readlines()
iteration = 0
for i in range(len(par_data[0])):
lines[1] = 'RAJ ' + par_data[1][i] + '\n'
lines[2] = 'DECJ ' + par_data[2][i] + '\n'
lines[3] = 'F0 ' + par_data[0][i] + ' 1' + '\n'
with open(name_pulsar + '.par', 'w') as file:
for line in lines:
file.write(line)
os.system('tempo ' + name_pulsar + '.tim > outtempo.log')
os.system(
'~/work/tempo/util/print_resid/./print_resid -mre > ' +
'resid_' + name_pulsar + '.ascii')
data = np.genfromtxt('resid_' + name_pulsar + '.ascii').T
plt.close()
plt.title(
str(iteration)
+ '/' + par_data[0][i]
+ '/' + par_data[1][i]
+ '/' + par_data[2][i]
+ '/' + par_data[3][i])
plt.xlabel('MJD')
plt.ylabel('Residuals, us')
plt.plot(data[0], data[1], '+')
# создание директории в том случае, если она не существует
if os.path.isdir('./plot_res_' + name_pulsar + '/'):
pass
else:
os.system('mkdir ' + './plot_res_' + name_pulsar + '/')
plt.savefig(
'./plot_res_' + name_pulsar + '/'
+ str(iteration)
+ '_'
+ name_pulsar
+ '.png',
format='png')
iteration += 1