-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
71 lines (56 loc) · 2.6 KB
/
setup.py
File metadata and controls
71 lines (56 loc) · 2.6 KB
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
import time
import subprocess
import numpy as np
from stacking_functions import check_dir
wd = subprocess.check_output('pwd', shell=True)[:-1]
print "\nBeginning OAStack setup. Make sure you are running this in the OAStack directory."
time.sleep(3)
print "\nBy default raw maps are assumed to be located in OAStack/maps and outputted stacks in OAStack/stacks. Do you want to use the default settings? [y/n]\n"
default = raw_input()
while not (default == "y" or default == "n"):
print "\nPlease enter either 'y' or 'n'"
default = raw_input('\n')
COOP_dir = raw_input('\nEnter location of COOP:\n')
while not check_dir(COOP_dir):
print "\nERROR: No such directory. Try Again."
COOP_dir = raw_input('\n')
if default == "y":
if not check_dir(COOP_dir+'/maps'):
_ = subprocess.Popen("mkdir {}/maps".format(wd), shell=True),
if not check_dir(COOP_dir+'/stacks'):
_ = subprocess.Popen("mkdir {}/stacks".format(wd), shell=True),
_ = subprocess.Popen("mkdir {}/stacks/out".format(wd), shell=True),
map_dir, stack_dir = wd+"/maps", wd+"/stacks"
else:
map_dir = raw_input('\nEnter location where raw maps will be located:\n')
while not check_dir(map_dir):
print "\nERROR: No such directory. Try Again."
map_dir = raw_input('\n')
stack_dir = raw_input('\nEnter location for outputted stacks:\n')
while not check_dir(stack_dir):
print "\nERROR: No such directory. Try Again."
stack_dir = raw_input('\n')
_ = subprocess.Popen("mkdir {}/out".format(stack_dir), shell=True),
print "\nRaw maps to be stored at {}".format(map_dir)
print "Stacks to be stored at {}".format(stack_dir)
time.sleep(1)
print "\nChecking for required libraries..."
try:
import healpy
print "Healpy installed."
except (ImportError):
print "Healpy not installed. Beginning installation...\n"
subprocess.check_output("pip install healpy", stderr=subprocess.STDOUT, shell=True)
try:
import astropy
print "Astropy installed."
except (ImportError):
print "Astropy not installed. Beginning installation...\n"
subprocess.check_output("pip install astropy", stderr=subprocess.STDOUT, shell=True)
ftcomp = raw_input('\nEnter name of Fortran compiler used to build COOP: [gfortran/ifort]\n')
while not (ftcomp == 'gfortran' or ftcomp == 'ifort'):
print "\nOnly gfortran or ifort supported. Try Again."
ftcomp = raw_input('\n')
settings = np.array([['COOP', COOP_dir], ['maps', map_dir], ['stacks', stack_dir], ['fortran', ftcomp]])
np.savetxt('{}/settings.txt'.format(wd), settings, delimiter='\t', fmt='%s')
print "\nSetup Complete! Settings have been stored in {}/settings.txt and can be edited at any time directly or by running this script again.".format(wd)