-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmage_copy2D.py
39 lines (32 loc) · 1.39 KB
/
mage_copy2D.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
from __future__ import print_function
import glob
import subprocess
from os.path import expanduser, basename, normpath, exists
from os import makedirs
def nonblank_lines(f):
for l in f:
line = l.rstrip()
if line:
yield line
atlasdir = expanduser('~') + '/Dropbox/MagE_2D/' # output dir
reduxdir = '/Volumes/Apps_and_Docs/SCIENCE/Lensed-LBGs/Mage/Redux/' # reduction dir
infile = '2D-rectify.dirs' # list of all the 2D dirs to copy over
thisdir = 'foo/' # initalize
with open(reduxdir + infile) as f_in:
for line in nonblank_lines(f_in): # strip blank lines
if '#' in line : next # strip comments
elif 'NAME' in line :
(first, subdir) = line.split()
print("Working on object ", subdir)
outdir = atlasdir + subdir + '/'
if not exists(outdir): makedirs(outdir)
else :
print(line)
subsubdir = basename(normpath(line)) # grab the last dir in the path
goeshere = outdir + subsubdir + '/'
if not exists( goeshere ) : makedirs( goeshere)
dothis = '/bin/cp -pr ' + normpath(line) + '/*sum*fits ' + goeshere
print("Planning to ", dothis)
temp = subprocess.check_output(dothis, shell=True).split()
dothis = '/bin/cp -pr ' + reduxdir + infile + ' ' + atlasdir
temp = subprocess.check_output(dothis, shell=True).split()