LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
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)
def setAstrometryConfigFromEups(config, menu)
def setDottedAttr(item, name, value)
def setConfigFromEups(photocalConfig=None, astrometryConfig=None, astrometryMenu=None)