2 We used to have AstrometryNetDataConfig() use the pex_config 3 mechanism, but we need nested lists, so we do this home-brew version 6 __all__ = [
"AstrometryNetDataConfig"]
9 def _checkMagMap(magmap):
11 Checks the validity of a magnitude column map in AstrometryNetDataConfig. 13 if not isinstance(magmap, dict):
14 raise RuntimeError(
'Mag maps must be dicts')
15 for k, v
in magmap.items():
16 if not isinstance(k, str):
17 raise RuntimeError(
'Mag maps must be dicts mapping str->str: got bad key \"%s\"' % str(k))
18 if not isinstance(v, str):
19 raise RuntimeError(
'Mag maps must be dicts mapping str->str: got bad value \"%s\"' % str(v))
20 if not (len(k) > 0
and len(v) > 0):
21 raise RuntimeError(
'Mag maps items must be non-empty: got bad values \"%s\" -> \"%s\"' %
25 def _checkIndexList(indexList):
27 Checks the validity of an index list in AstrometryNetDataConfig. 29 if not isinstance(indexList, list):
30 raise RuntimeError(
'indexList config item must be a list')
32 if not isinstance(k, str):
33 raise RuntimeError(
'indexList config items must be strings: got bad one \"%s\"' % (str(k),))
35 raise RuntimeError(
'indexList config items must be non-empty strings')
38 def _checkMultiIndexList(multiIndexList):
40 Checks the validity of a multi_index list in AstrometryNetDataConfig. 42 if not isinstance(multiIndexList, list):
43 raise RuntimeError(
'multiIndexList config item must be a list')
44 for k
in multiIndexList:
45 if not isinstance(k, list):
46 raise RuntimeError(
'multiIndexList config items must be lists: got bad one \"%s\"' % (str(k),))
48 raise RuntimeError(
'multiIndexList config items must be non-empty lists')
50 if not isinstance(kk, str):
51 raise RuntimeError(
'multiIndexList config items must be strings: got bad one \"%s\"' %
54 raise RuntimeError(
'multiIndexList config items must be non-empty strings')
59 Astrometry.net data config object. This is a plain-python config 60 structure similar to pexConfig. 62 For examples of use, see tests/astrometry_net_data/photocal/andConfig*.py 66 (
'idColumn', str,
'id',
None,
67 'Column name (in the index files) of the ID number of reference sources'),
68 (
'defaultMagColumn', str,
'mag',
None,
69 'Default column name (in the index files) of the reference source mag'),
70 (
'defaultMagErrorColumn', str,
'',
None,
71 'Default column name (in the index files) of the reference source mag error'),
72 (
'starGalaxyColumn', str,
None,
None,
73 'Column name of the star/galaxy flag'),
74 (
'variableColumn', str,
None,
None,
75 'Column name of the star variability flag'),
76 (
'magErrorColumnMap', dict, {}, _checkMagMap,
77 'Mapping from LSST filter name to mag error column name'),
78 (
'magColumnMap', dict, {}, _checkMagMap,
79 'Mapping from LSST filter name to mag column name'),
80 (
'indexFiles', list, [], _checkIndexList,
81 'List of Astrometry.net index filenames'),
82 (
'multiIndexFiles', list, [], _checkMultiIndexList,
83 'Astrometry.net multi-index filename lists. ' 84 'Each item in this list must itself be a list of filenames. ' 85 'The first filename is the file that contains the star kd-tree and tag-along tables. ' 86 'Subsequent filenames must be files containing just the non-star index parts ' 87 '(quads and code kd-tree). Note that this means you may need to repeat the first filename ' 88 'if it contains a star kd-tree and the first index.'),
89 (
'allowCache', bool,
True,
None,
90 'Allow use of cache for reading index file regions?'),
96 with open(fn,
'rb')
as file:
97 code = compile(file.read(), fn,
'exec')
98 exec(code, globals(), loc)
102 for k, v
in kwargs.items():
106 for nm, typ, deef, check, doc
in AstrometryNetDataConfig.fields:
113 for nm, typ, deef, check, doc
in AstrometryNetDataConfig.fields:
119 elif not isinstance(v, typ):
120 raise RuntimeError((
'Attempted to set AstrometryNetDataConfig' 121 ' field \"%s\" to type %s, but need type %s') %
122 (nm, str(typ), str(type(v))))
123 if check
is not None:
126 object.__setattr__(self, nm, v)
129 raise RuntimeError(
'Attempted to set invalid AstrometryNetDataConfig'
def __setattr__(self, k, v)
def __init__(self, kwargs)