-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
86 lines (61 loc) · 2.08 KB
/
install.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import getpass
import os
import sys
try: import pyfits
except: print "Could not import pyfits, please reinstall stscipython"
try: import stsci
except: print "STScI python not properly installed"
print "Installing mospy to /usr/local/bin"
try:
f = open("apps/mospy_mac")
lines = f.readlines()
f.close()
except:
print """Could not open or read the apps/mospy file. Make sure
that you run this file from the MOSFIRE directory"""
os.system("cp apps/mospy_mac /usr/local/bin/mospy")
os.system('chmod a+x /usr/local/bin/mospy')
print """Default directories:
The DRP will be moved to:
~/mosdrp/DRP
Place raw data files here:
~/mosdrp/data
Reduced data will be placed
~/mosdrp/output
The bad pixel mask in
~/mosdrp/badpixels/
If mospy issues a command not found, place
/usr/local/bin in your PATH
"""
os.system("mkdir -p $HOME/mosdrp/DRP")
os.system("mkdir -p $HOME/mosdrp/data")
os.system("mkdir -p $HOME/mosdrp/output")
os.system("mkdir -p $HOME/mosdrp/badpixels")
os.system("cp -r ~/mosfire/* $HOME/mosdrp/DRP/")
os.system("cp -r ~/mosfire/.hg $HOME/mosdrp/DRP/")
yorn = raw_input("Would you like to download the bad pixel mask [y/n]?")
bpm = 'badpix_10sep2012.fits'
if yorn == 'y' or yorn == 'Y':
os.system("curl -O http://mosfire.googlecode.com/files/%s" % bpm)
os.system("mv badpix_*.fits $HOME/mosdrp/badpixels/")
try:
f = open(os.path.expanduser("~/mosdrp/DRP/MOSFIRE/Options.py"))
lines = f.readlines()
f.close()
except:
print "Could not open and read Options.py in DRP directory"
sys.exit()
f = open(os.path.expanduser("~/mosdrp/DRP/MOSFIRE/Options.py"), "w")
path = os.path.expanduser('~')
for line in lines:
sp = line.split('=')
if sp[0].rstrip() == 'indir':
sp[1] = " '%s/mosdrp/data'" % (path)
if sp[0].rstrip() == 'outdir':
sp[1] = " '%s/mosdrp/output'" % (path)
if sp[0].rstrip() == 'path_bpm':
sp[1] = " '%s/mosdrp/badpixels/%s'" % (path, bpm)
outstr = '='.join(sp) + "\n"
f.write(outstr)
f.close()
print("I recommend that you remove the ~/mosfire directory now.")