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 from __future__
import absolute_import, division, print_function
8 __all__ = [
"AstrometryNetDataConfig"]
10 from past.builtins
import execfile
11 from builtins
import object
14 def _checkMagMap(magmap):
16 Checks the validity of a magnitude column map in AstrometryNetDataConfig. 18 if not isinstance(magmap, dict):
19 raise RuntimeError(
'Mag maps must be dicts')
20 for k, v
in magmap.items():
21 if not isinstance(k, str):
22 raise RuntimeError(
'Mag maps must be dicts mapping str->str: got bad key \"%s\"' % str(k))
23 if not isinstance(v, str):
24 raise RuntimeError(
'Mag maps must be dicts mapping str->str: got bad value \"%s\"' % str(v))
25 if not (len(k) > 0
and len(v) > 0):
26 raise RuntimeError(
'Mag maps items must be non-empty: got bad values \"%s\" -> \"%s\"' %
30 def _checkIndexList(indexList):
32 Checks the validity of an index list in AstrometryNetDataConfig. 34 if not isinstance(indexList, list):
35 raise RuntimeError(
'indexList config item must be a list')
37 if not isinstance(k, str):
38 raise RuntimeError(
'indexList config items must be strings: got bad one \"%s\"' % (str(k),))
40 raise RuntimeError(
'indexList config items must be non-empty strings')
43 def _checkMultiIndexList(multiIndexList):
45 Checks the validity of a multi_index list in AstrometryNetDataConfig. 47 if not isinstance(multiIndexList, list):
48 raise RuntimeError(
'multiIndexList config item must be a list')
49 for k
in multiIndexList:
50 if not isinstance(k, list):
51 raise RuntimeError(
'multiIndexList config items must be lists: got bad one \"%s\"' % (str(k),))
53 raise RuntimeError(
'multiIndexList config items must be non-empty lists')
55 if not isinstance(kk, str):
56 raise RuntimeError(
'multiIndexList config items must be strings: got bad one \"%s\"' %
59 raise RuntimeError(
'multiIndexList config items must be non-empty strings')
64 Astrometry.net data config object. This is a plain-python config 65 structure similar to pexConfig. 67 For examples of use, see tests/astrometry_net_data/photocal/andConfig*.py 71 (
'idColumn', str,
'id',
None,
72 'Column name (in the index files) of the ID number of reference sources'),
73 (
'defaultMagColumn', str,
'mag',
None,
74 'Default column name (in the index files) of the reference source mag'),
75 (
'defaultMagErrorColumn', str,
'',
None,
76 'Default column name (in the index files) of the reference source mag error'),
77 (
'starGalaxyColumn', str,
None,
None,
78 'Column name of the star/galaxy flag'),
79 (
'variableColumn', str,
None,
None,
80 'Column name of the star variability flag'),
81 (
'magErrorColumnMap', dict, {}, _checkMagMap,
82 'Mapping from LSST filter name to mag error column name'),
83 (
'magColumnMap', dict, {}, _checkMagMap,
84 'Mapping from LSST filter name to mag column name'),
85 (
'indexFiles', list, [], _checkIndexList,
86 'List of Astrometry.net index filenames'),
87 (
'multiIndexFiles', list, [], _checkMultiIndexList,
88 'Astrometry.net multi-index filename lists. ' 89 'Each item in this list must itself be a list of filenames. ' 90 'The first filename is the file that contains the star kd-tree and tag-along tables. ' 91 'Subsequent filenames must be files containing just the non-star index parts ' 92 '(quads and code kd-tree). Note that this means you may need to repeat the first filename ' 93 'if it contains a star kd-tree and the first index.'),
94 (
'allowCache', bool,
True,
None,
95 'Allow use of cache for reading index file regions?'),
100 loc = dict(root=self)
101 execfile(fn, globals(), loc)
105 for k, v
in kwargs.items():
109 for nm, typ, deef, check, doc
in AstrometryNetDataConfig.fields:
116 for nm, typ, deef, check, doc
in AstrometryNetDataConfig.fields:
122 elif not isinstance(v, typ):
123 raise RuntimeError((
'Attempted to set AstrometryNetDataConfig' 124 ' field \"%s\" to type %s, but need type %s') %
125 (nm, str(typ), str(type(v))))
126 if check
is not None:
129 object.__setattr__(self, nm, v)
132 raise RuntimeError(
'Attempted to set invalid AstrometryNetDataConfig'
def __setattr__(self, k, v)
def __init__(self, kwargs)