LSSTApplications  19.0.0-1-g1faeb96,19.0.0-1-g8c57eb9+34,19.0.0-1-ga3b31f8+3,19.0.0-1-gad49e94,19.0.0-10-g3250e53,19.0.0-15-g7d47663,19.0.0-17-gde1f5b76+3,19.0.0-18-gfb21c91+2,19.0.0-2-g15ad1b6+2,19.0.0-2-g2ed0b45+1,19.0.0-2-g456d77f+3,19.0.0-2-g4aada73,19.0.0-2-g5e94dc7+1,19.0.0-2-g6e0b8f9,19.0.0-2-g822544a+2,19.0.0-2-gb013ac2+2,19.0.0-2-gd82b0d5+3,19.0.0-20-g12a598f,19.0.0-20-g3336a1e+3,19.0.0-22-gd98cb7f78,19.0.0-23-g2f46faf,19.0.0-23-g4cc2bcb,19.0.0-3-g57fcecc+2,19.0.0-3-g9629746+1,19.0.0-3-g99a058e,19.0.0-3-ga84a0ef,19.0.0-3-gbea416a+1,19.0.0-3-gc2296d9,19.0.0-3-gc70e9ed,19.0.0-3-gc851abf+3,19.0.0-4-gac56cce+22,19.0.0-4-gb666382+3,19.0.0-4-gc799371+3,19.0.0-5-g24a5ec6,19.0.0-53-gf4ac060,19.0.0-55-g5222f1c4,19.0.0-6-g4aaee92+3,19.0.0-6-gce3e386+3,19.0.0-8-g967c747,19.0.0-8-gb750100+2,w.2020.18
LSSTDataManagementBasePackage
setConfigFromEups.py
Go to the documentation of this file.
1 from eups import Eups
2 from fnmatch import fnmatch
3 
4 from lsst.pipe.base.argumentParser import setDottedAttr
5 
6 __all__ = ["getAndVersion", "setAstrometryConfigFromEups", "setPhotocalConfigFromEups", "setConfigFromEups", ]
7 
8 
9 def getEups():
10  """Return a cached eups instance"""
11  try:
12  return getEups._eups
13  except AttributeError:
14  getEups._eups = Eups()
15  return getEups._eups
16 
17 
19  """Return the version of astrometry_net_data in use"""
20  return getEups().findSetupVersion("astrometry_net_data")[0]
21 
22 
23 def setAstrometryConfigFromEups(config, menu):
24  """Set the astrometry configuration according to the astrometry_net_data being used
25 
26  The menu is a dict mapping the astrometry_net_data version to a dict of configuration
27  values to apply. The menu key may also be a glob. For example:
28  menu = { "ps1*": {}, # No changes
29  "ps1-without-y": { "solver.filterMap": {"y": "z"} }, # No y-band in this specific version
30  "sdss*": { "solver.filterMap": {"y": "z"} }, # No y-band, use z instead
31  "2mass*": { "solver.filterMap": {"y": "J"} }, # No y-band, use J instead
32  }
33  """
34  version = getAndVersion()
35 
36  if version in menu:
37  selected = menu[version]
38  else:
39  # Treat keys in menu as glob; see if any match
40  matchList = [key for key in menu if fnmatch(version, key)]
41  if len(matchList) > 1:
42  raise RuntimeError("Multiple menu keys match astrometry_net_data version %s: %s" %
43  (version, matchList))
44  if len(matchList) == 0:
45  raise RuntimeError("No menu key matches astrometry_net_data version %s" % version)
46  selected = menu[matchList.pop()]
47  for name, value in selected.items():
48  setDottedAttr(config, name, value)
49 
50 
52  """Set the photocal configuration according to the astrometry_net_data being used"""
53  config.photoCatName = getAndVersion()
54 
55 
56 def setConfigFromEups(photocalConfig=None, astrometryConfig=None, astrometryMenu=None):
57  """Set the astrometry and photocal configuration according to the astrometry_net_data being used
58 
59  The 'astrometryMenu' is as defined for the 'menu' parameter for 'setAstrometryConfigFromEups'.
60  """
61  if photocalConfig:
62  setPhotocalConfigFromEups(photocalConfig)
63  if astrometryConfig:
64  if astrometryMenu is None:
65  raise RuntimeError("No astrometryMenu provided for astrometryConfig")
66  setAstrometryConfigFromEups(astrometryConfig, astrometryMenu)
lsst.pipe.tasks.setConfigFromEups.getEups
def getEups()
Definition: setConfigFromEups.py:9
lsst.pipe.base.argumentParser.setDottedAttr
def setDottedAttr(item, name, value)
Definition: argumentParser.py:1300
lsst.pipe.base.argumentParser
Definition: argumentParser.py:1
lsst.pipe.tasks.setConfigFromEups.setPhotocalConfigFromEups
def setPhotocalConfigFromEups(config)
Definition: setConfigFromEups.py:51
lsst.pipe.tasks.setConfigFromEups.setConfigFromEups
def setConfigFromEups(photocalConfig=None, astrometryConfig=None, astrometryMenu=None)
Definition: setConfigFromEups.py:56
lsst.pipe.tasks.setConfigFromEups.getAndVersion
def getAndVersion()
Definition: setConfigFromEups.py:18
lsst.pipe.tasks.setConfigFromEups.setAstrometryConfigFromEups
def setAstrometryConfigFromEups(config, menu)
Definition: setConfigFromEups.py:23