-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmatchcam.py
More file actions
executable file
·64 lines (48 loc) · 2.06 KB
/
matchcam.py
File metadata and controls
executable file
·64 lines (48 loc) · 2.06 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
#!/usr/bin/env python
import sys
import os
import argparse
from sciimg.isis3 import cameras
from sciimg.isis3 import _core
from sciimg.isis3 import utility
def match_cam(from_cube, match_cube, output_dir, pad=2000, frommap=False):
source_dirname = os.path.dirname(from_cube)
if source_dirname == "":
source_dirname = "."
work_dir = "%s/work" % source_dirname
if not os.path.exists(work_dir):
os.mkdir(work_dir)
padded_match_file = "%s/__padded__%s" % (work_dir, match_cube)
padded_file = "%s/%s" % (work_dir, file_name)
out_file = "%s/%s" % (output_dir, file_name)
utility.pad(from_cube, padded_file, top=pad, right=pad, bottom=pad, left=pad)
utility.pad(match_cube, padded_match_file, top=pad, right=pad, bottom=pad, left=pad)
if frommap:
cameras.map2cam(padded_file, out_file, padded_match_file)
else:
cameras.cam2cam(padded_file, out_file, padded_match_file)
os.unlink(padded_file)
os.unlink(padded_match_file)
if __name__ == "__main__":
try:
_core.is_isis3_initialized()
except:
print "ISIS3 has not been initialized. Please do so. Now."
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--data", help="Source cube file", required=True, type=str, nargs='+')
parser.add_argument("-m", "--match", help="Input cube to match", required=False, type=str)
parser.add_argument("-o", "--output", help="Output Directory", required=True, type=str)
parser.add_argument("-p", "--padding", help="Cube padding (pixels)", required=False, type=int, default=2000)
parser.add_argument("-f", "--frommap", help="Input cubes are map projected", required=False, type=str)
args = parser.parse_args()
source = args.data
match = args.match
output = args.output
padding = args.padding
frommap = args.frommap
for file_name in source:
if file_name[-3:].upper() != "CUB":
print "Not a ISIS cube file file. Skipping '%s'"%file_name
else:
match_cam(file_name, match, output, padding, frommap)