24 This helper class automatically parses the arguments received by the Python script via
25 sys.argv, using the set of key-value parameters received on its constructor to cast the types
26 and define the defaults.
31 A set of key-values with the defaults, or the types of the expected values. For instance, it is valid to do
37 For the first case - a value -, if no value is passed via sys.argv, this will be the default. Otherwise,
38 its type (float) will be used to cast the received value.
40 For the second case - a type -, if no value is passed via sys.argv, the parameter will default to None.
41 Otherwise, the type will be used to cast the received value.
43 Callables are also accepted. They should accept to be called with no parameters, returning the default,
44 or with a single string, returning the parsed value.
46 Values can be accessed later as attributes:
48 instance.key1 and instance.key2
53 If the cast of the parameter failed (i.e. an invalid integer or float format)
55 If additional unknown parameters are received
62 argv = dict([arg.split(
'=', 1)
if '=' in arg
else (arg,
True)
for arg
in sys.argv[1:]])
65 for arg_name, arg_spec
in kwargs.items():
66 if isinstance(arg_spec, type):
69 elif callable(arg_spec):
71 arg_default = arg_spec()
73 arg_type = type(arg_spec)
74 arg_default = arg_spec
78 self.
__args__args[arg_name] = arg_type(argv[arg_name])
80 raise ValueError(
'Invalid value for {}: {}'.format(arg_name, argv[arg_name]))
83 self.
__args__args[arg_name] = arg_default
86 raise KeyError(
'Unknown parameters found: {}'.format(
', '.
join(argv.keys())))
94 Name of the parameter to retrieve
98 The parsed value of the parameter
103 If item has not been defined on construction
105 if item
not in self.
__args__args:
106 raise AttributeError(item)
107 return self.
__args__args[item]
114 Human readable representation for the object
116 return str(self.
__args__args)
123 String representation for the object
125 return repr(self.
__args__args)
130 Helper class for receiving a globing pattern as a parameter, defining a list of files
131 - i.e. measurement images or PSFs.
132 It is an iterable, and can be passed directly to load_fits_images.
137 A file globing expression. i.e "*.psf", "band_[r|i|g]_*.fits" or similar.
138 The result is always stored and returned in alphabetical order, so the order between two
139 file lists - i.e frame image and PSF - is consistent and a matching can be done easily between them.
143 glob.glob : Return a list of paths matching a pathname pattern.
158 return iter(self.
__files__files)
167 return len(self.
__files__files)
174 Human readable representation for the object
176 return str(self.
__files__files)
183 String representation for the object
185 return repr(self.
__files__files)
ELEMENTS_API auto join(Args &&... args) -> decltype(joinPath(std::forward< Args >(args)...))