Debian Codegraph @

planetary_system_stacker/Test_programs/argparser.py

raw symbols SCIP
1 import argparse
2 import sys
3
4 print("The command was called with " + str(len(sys.argv)) + " arguments")
5
6 if len(sys.argv) <= 1:
7 print ("Running PSS in interactive mode, starting GUI.")
8 exit()
9
10 def noise_type(x):
11 x = int(x)
12 if not 0 <= x <= 11:
13 raise argparse.ArgumentTypeError("Noise level must be between 0 and 11")
14 return x
15
16
17 def stab_size_type(x):
18 x = int(x)
19 if not 5 <= x <= 80:
20 raise argparse.ArgumentTypeError("Stabilization patch size must be between 5% and 80%")
21 return x
22
23
24 def stab_sw_type(x):
25 x = int(x)
26 if not 5 <= x <= 150:
27 raise argparse.ArgumentTypeError(
28 "Stabilization search width must be between 5 and 150 pixels")
29 return x
30
31
32 def rf_percent_type(x):
33 x = int(x)
34 if not 3 <= x <= 30:
35 raise argparse.ArgumentTypeError(
36 "Percentage of best frames for reference frame computation must be between 3% and 30%")
37 return x
38
39
40 def align_box_width_type(x):
41 x = int(x)
42 if not 20 <= x <= 140:
43 raise argparse.ArgumentTypeError(
44 "Alignment point box width must be between 20 and 140 pixels")
45 return x
46
47
48 def align_search_width_type(x):
49 x = int(x)
50 if not 6 <= x <= 30:
51 raise argparse.ArgumentTypeError(
52 "Alignment point search width must be between 6 and 30 pixels")
53 return x
54
55
56 def align_min_struct_type(x):
57 x = float(x)
58 if not 0.01 <= x <= 0.30:
59 raise argparse.ArgumentTypeError(
60 "Alignment point minimum structure must be between 0.01 and 0.30")
61 return x
62
63
64 def align_min_bright_type(x):
65 x = int(x)
66 if not 2 <= x <= 50:
67 raise argparse.ArgumentTypeError(
68 "Alignment point minimum brightness must be between 2 and 50")
69 return x
70
71
72 def stack_percent_type(x):
73 x = int(x)
74 if not 1 <= x <= 100:
75 raise argparse.ArgumentTypeError(
76 "Percentage of best frames to be stacked must be between 1 and 100")
77 return x
78
79 def stack_number_type(x):
80 x = int(x)
81 if not 1 <= x:
82 raise argparse.ArgumentTypeError(
83 "Number of best frames to be stacked must be greater or equal 1")
84 return x
85
86 def normalize_bco_type(x):
87 x = int(x)
88 if not 0 <= x <= 40:
89 raise argparse.ArgumentTypeError(
90 "Normalization black cut-off must be between 0 and 40")
91 return x
92
93
94 parser = argparse.ArgumentParser()
95 parser.add_argument("job_input", nargs='+', help="input video files or still image folders")
96
97 parser.add_argument("-p", "--protocol", action="store_true",
98 help="Store protocol with results")
99 parser.add_argument("--protocol_detail", type=int, choices=[0, 1, 2], default=1,
100 help="Protocol detail level")
101 parser.add_argument("-b", "--buffering_level", type=int, choices=[0, 1, 2, 3, 4], default=2,
102 help="Buffering level")
103 parser.add_argument("--out_format", choices=["png", "tiff", "fits"], default="png",
104 help="Image format for output")
105 parser.add_argument("--name_add_f", action="store_true",
106 help="Add number of stacked frames to output file name")
107 parser.add_argument("--name_add_p", action="store_true",
108 help="Add percentage of stacked frames to output file name")
109 parser.add_argument("--name_add_apb", action="store_true",
110 help="Add alignment point box size (pixels) to output file name")
111 parser.add_argument("--name_add_apn", action="store_true",
112 help="Add number of alignment points to output file name")
113
114 parser.add_argument("--debayering", choices=["Auto detect color", "Grayscale", "RGB", "RGB", "BGR",
115 "Force Bayer RGGB", "Force Bayer GRBG",
116 "Force Bayer GBRG", "Force Bayer BGGR"],
117 default="Auto detect color", help="Debayering option")
118 parser.add_argument("--noise", type=noise_type, default=7, help="Noise level (add Gaussian blur)")
119 parser.add_argument("-m", "--stab_mode", choices=["Surface", "Planet"], default="Surface",
120 help="Frame stabilization mode")
121 parser.add_argument("--stab_size", type=stab_size_type, default=33,
122 help="Stabilization patch size (% of frame)")
123 parser.add_argument("--stab_sw", type=stab_sw_type, default=34,
124 help="Stabilization search width (pixels)")
125 parser.add_argument("--rf_percent", type=rf_percent_type, default=5,
126 help="Percentage of best frames for reference frame computation")
127 parser.add_argument("-d", "--dark", help="Image file for dark frame correction")
128 parser.add_argument("-f", "--flat", help="Image file for flat frame correction")
129
130 parser.add_argument("-a", "--align_box_width", type=align_box_width_type, default=48,
131 help="Alignment point box width (pixels)")
132 parser.add_argument("-w", "--align_search_width", type=align_search_width_type, default=14,
133 help="Alignment point search width (pixels)")
134 parser.add_argument("--align_min_struct", type=align_min_struct_type, default=0.04,
135 help="Alignment point minimum structure")
136 parser.add_argument("--align_min_bright", type=align_min_bright_type, default=10,
137 help="Alignment point minimum brightness")
138
139 parser.add_argument("-s", "--stack_percent", type=stack_percent_type, default=10,
140 help="Percentage of best frames to be stacked")
141 parser.add_argument("--stack_number", type=stack_number_type,
142 help="Number of best frames to be stacked")
143 parser.add_argument("-n", "--normalize_bright", action="store_true",
144 help="Normalize frame brightness")
145 parser.add_argument("--normalize_bco", type=normalize_bco_type, default=15,
146 help="Normalization black cut-off")
147
148 args = parser.parse_args()
149
150 print(str(args.job_input))
151 print("Store protocol with results: " + str(args.protocol))
152 print("Protocol detail level: " + str(args.protocol_detail))
153 print("Buffering level: " + str(args.buffering_level))
154 print("Image format for output: " + args.out_format)
155 print("Add number of stacked frames to output file name: " + str(args.name_add_f))
156 print("Add percentage of stacked frames to output file name: " + str(args.name_add_p))
157 print("Add alignment point box size (pixels) to output file name: " + str(args.name_add_apb))
158 print("Add number of alignment points to output file name: " + str(args.name_add_apn))
159 print("")
160 print("Debayering option: " + args.debayering)
161 print("Noise level: " + str(args.noise))
162 print("Frame stabilization mode: " + args.stab_mode)
163 print("Stabilization patch size (% of frame): " + str(args.stab_size))
164 print("Stabilization search width (pixels): " + str(args.stab_sw))
165 print("Percentage of best frames for reference frame computation: " + str(args.rf_percent))
166 if args.dark:
167 print("Image file for dark frame correction: " + args.dark)
168 if args.flat:
169 print("Image file for flat frame correction: " + args.flat)
170 print("")
171 print("Alignment point box width (pixels): " + str(args.align_box_width))
172 print("Alignment point search width (pixels): " + str(args.align_search_width))
173 print("Alignment point minimum structure: " + str(args.align_min_struct))
174 print("Alignment point minimum brightness: " + str(args.align_min_bright))
175 print("")
176 print("Percentage of best frames to be stacked: " + str(args.stack_percent))
177 print("Number of best frames to be stacked: " + str(args.stack_number))
178 print("Normalize frame brightness: " + str(args.normalize_bright))
179 print("Normalization black cut-off: " + str(args.normalize_bco))