-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_galfit.py
42 lines (31 loc) · 1.07 KB
/
run_galfit.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
################################################
# run_galfit.py
#
# Python script to run GALFIT on created parameter files
#################################################
from multiprocessing import Pool
import os
import numpy as np
import time
import pickle
NUM_FILES = 100000
NUM_THREADS = 15
FILE_PATH = "./"
#FILE_PATH = "./"
def run_galfit(x):
command = "~/local_soft/galfit "+FILE_PATH+"galfit_temp_" + str(x) + " > /dev/null 2>&1" #Suppresses Screen I/O. Remove the end-part if you don't want this.
out = os.system(command)
return out
if __name__ == '__main__':
start_timestamp = time.time()
pl = Pool(NUM_THREADS)
exit_codes = pl.map(run_galfit,range(0,NUM_FILES))
bool = all(i == 0 for i in exit_codes)
if bool == True:
print("All seems to have gone well!!")
else:
print("Some Images may have some issues")
pickle_file = open("exit_codes.pkl","w")
pickle.dump(exit_codes,pickle_file)
print("Dumped Array of Exit Codes as a pickle.Check for non-zero exit codes.")
print("Real Time of Execution:- %s seconds" % (time.time() - start_timestamp) )