LSSTApplications  19.0.0-1-g1faeb96+1,19.0.0-1-g8c57eb9+36,19.0.0-1-ga3b31f8+9,19.0.0-1-gad49e94+1,19.0.0-10-g3250e53+1,19.0.0-15-g7d47663+6,19.0.0-17-gde1f5b76+9,19.0.0-18-gfb21c91+8,19.0.0-2-g15ad1b6+8,19.0.0-2-g2ed0b45+3,19.0.0-2-g4aada73+1,19.0.0-2-g5e94dc7+3,19.0.0-2-g6e0b8f9,19.0.0-2-g822544a+8,19.0.0-2-gb013ac2+8,19.0.0-2-gd82b0d5+9,19.0.0-20-g12a598f+6,19.0.0-20-g3336a1e+9,19.0.0-22-gd98cb7f78+2,19.0.0-23-g2f46faf+6,19.0.0-23-g4cc2bcb+6,19.0.0-3-g3912c24,19.0.0-3-g57fcecc+8,19.0.0-3-g9629746+3,19.0.0-3-g99a058e+1,19.0.0-3-ga84a0ef+1,19.0.0-3-gbea416a+3,19.0.0-3-gc70e9ed+1,19.0.0-3-gc851abf+9,19.0.0-4-gb4e0033,19.0.0-4-gc799371+9,19.0.0-5-g309d03d+4,19.0.0-5-gac6c5c4+4,19.0.0-57-gef2e0c0,19.0.0-59-g5d40e1c7+2,19.0.0-6-g4aaee92+9,19.0.0-6-g60c8ecb,19.0.0-6-gce3e386+9,19.0.0-8-g967c747+1,19.0.0-8-gb750100+8,w.2020.19
LSSTDataManagementBasePackage
Functions
convertGen2RepoToGen3 Namespace Reference

Functions

def build_argparser ()
 
def parse_args (parser)
 
def convert (gen2root, gen3root, instrumentClass, skymapName=None, skymapConfig=None, calibs=None, reruns=[], config=None, transferMode="auto")
 
def main ()
 

Function Documentation

◆ build_argparser()

def convertGen2RepoToGen3.build_argparser ( )

Definition at line 36 of file convertGen2RepoToGen3.py.

36 def build_argparser():
37  parser = argparse.ArgumentParser(description=__doc__,
38  formatter_class=argparse.RawDescriptionHelpFormatter)
39  parser.add_argument("instrumentClass", metavar="lsst.obs.CAMERA.INSTRUMENT",
40  help=("The full import path to the gen3 Instrument class for this camera"
41  " (e.g. lsst.obs.decam.DarkEnergyCamera)."))
42  parser.add_argument("--gen2root", required=True,
43  help="Root path of the gen 2 repo to be converted.")
44  parser.add_argument("--gen3root", required=True,
45  help="Root path of the gen 3 repo to be produced.")
46  parser.add_argument("--skymapName", default=None,
47  help="Name of the new gen3 skymap (e.g. 'discrete/ci_hsc').")
48  parser.add_argument("--skymapConfig", default=None,
49  help="Path to skymap config file defining the new gen3 skymap.")
50  parser.add_argument("--calibs", default=None,
51  help="Path to the gen 2 calibration repo; absolute, or relative to gen2root.")
52  parser.add_argument("--reruns", default=[], nargs="*",
53  help="List of gen 2 reruns to convert.")
54  parser.add_argument("--transferMode", default="auto",
55  choices=["auto", "link", "symlink", "hardlink", "copy", "move", "relsymlink"],
56  help="Mode to use to transfer files into the new repository.")
57  parser.add_argument("-v", "--verbose", action="store_const", dest="verbose",
58  default=lsst.log.Log.INFO, const=lsst.log.Log.DEBUG,
59  help="Set the log level to DEBUG.")
60  parser.add_argument("-c", "--config", default=None,
61  help=("Path to a `ConvertRepoConfig` override to be included after "
62  "the Instrument config overrides are applied."))
63 
64  return parser
65 
66 

◆ convert()

def convertGen2RepoToGen3.convert (   gen2root,
  gen3root,
  instrumentClass,
  skymapName = None,
  skymapConfig = None,
  calibs = None,
  reruns = [],
  config = None,
  transferMode = "auto" 
)
Convert the gen 2 Butler repo living at gen2root into a gen 3 repo
living at gen3root.

Parameters
----------
gen2root : `str`
    Root path to the gen2 repo to be converted.
gen3root : `str`
    Root path to the gen3 output repo.
instrumentClass : `str`
    Full python path to the `lsst.obs.base.Instrument` class of the repo
    being converted.
skymapName : `str`, optional
    Name of the skymap to be converted in the repo.
skymapConfig : `str`, optional
    Path to the `lsst.skymap.BaseSkyMapConfig` of the gen2 skymap to be
    converted.
calibs : `str`, optional
    Path to the gen2 calibration repository to be converted.
    If a relative path, it is assumed to be relative to ``gen2root``.
reruns : `list` [`str`], optional
    List of reruns to convert. They will be placed in the
    ``shared/INSTRUMENT/RERUN`` collection.
config : `str`, optional
    Path to `lsst.obs.base.ConvertRepoConfig` configuration to load
    after all default/instrument configurations.
transferMode : `str`, optional
    Mode to use when transferring data into the gen3 repository.

Definition at line 77 of file convertGen2RepoToGen3.py.

77 def convert(gen2root, gen3root, instrumentClass,
78  skymapName=None, skymapConfig=None,
79  calibs=None, reruns=[], config=None, transferMode="auto"):
80  """Convert the gen 2 Butler repo living at gen2root into a gen 3 repo
81  living at gen3root.
82 
83  Parameters
84  ----------
85  gen2root : `str`
86  Root path to the gen2 repo to be converted.
87  gen3root : `str`
88  Root path to the gen3 output repo.
89  instrumentClass : `str`
90  Full python path to the `lsst.obs.base.Instrument` class of the repo
91  being converted.
92  skymapName : `str`, optional
93  Name of the skymap to be converted in the repo.
94  skymapConfig : `str`, optional
95  Path to the `lsst.skymap.BaseSkyMapConfig` of the gen2 skymap to be
96  converted.
97  calibs : `str`, optional
98  Path to the gen2 calibration repository to be converted.
99  If a relative path, it is assumed to be relative to ``gen2root``.
100  reruns : `list` [`str`], optional
101  List of reruns to convert. They will be placed in the
102  ``shared/INSTRUMENT/RERUN`` collection.
103  config : `str`, optional
104  Path to `lsst.obs.base.ConvertRepoConfig` configuration to load
105  after all default/instrument configurations.
106  transferMode : `str`, optional
107  Mode to use when transferring data into the gen3 repository.
108  """
109  # instantiate the correct instrument
110  instrument = lsst.utils.doImport(instrumentClass)()
111 
112  convertRepoConfig = ConvertRepoTask.ConfigClass()
113  instrument.applyConfigOverrides(ConvertRepoTask._DefaultName, convertRepoConfig)
114  convertRepoConfig.instrument = instrumentClass
115  convertRepoConfig.raws.transfer = transferMode
116  if skymapName is not None:
117  convertRepoConfig.skyMaps[skymapName] = ConvertRepoSkyMapConfig()
118  convertRepoConfig.skyMaps[skymapName].load(skymapConfig)
119  convertRepoConfig.rootSkyMapName = skymapName
120  if config is not None:
121  convertRepoConfig.load(config)
122 
123  rerunsArg = [Rerun(rerun, runName=f"shared/{instrument.getName()}/{rerun}",
124  chainName=f"shared/{instrument.getName()}", parents=[]) for rerun in reruns]
125 
126  # Allow a gen3 butler to be reused
127  try:
128  butlerConfig = lsst.daf.butler.Butler.makeRepo(gen3root)
129  except FileExistsError:
130  # Use the existing butler configuration
131  butlerConfig = gen3root
132  butler = lsst.daf.butler.Butler(butlerConfig, run=f"raw/{instrument.getName()}")
133  convertRepoTask = ConvertRepoTask(config=convertRepoConfig, butler3=butler)
134  convertRepoTask.run(
135  root=gen2root,
136  reruns=rerunsArg,
137  calibs=None if calibs is None else {calibs: f"calib/{instrument.getName()}"}
138  )
139 
140 

◆ main()

def convertGen2RepoToGen3.main ( )
To be run by the commandline script in `bin/`.
Examples
forEachPixel.cc, image1.cc, image2.cc, imageStatistics.cc, maskedImage1.cc, maskedImage2.cc, and splineInterpolate.cc.

Definition at line 141 of file convertGen2RepoToGen3.py.

141 def main():
142  """To be run by the commandline script in `bin/`.
143  """
144  parser = build_argparser()
145  args = parser.parse_args()
146 
147  log = lsst.log.Log.getLogger("convertRepo")
148  log.setLevel(args.verbose)
149  # Forward python logging to lsst logger
150  logger = logging.getLogger("convertRepo")
151  logger.setLevel(lsst.log.LevelTranslator.lsstLog2logging(log.getLevel()))
152  logger.addHandler(lsst.log.LogHandler())
153 
154  convert(args.gen2root, args.gen3root, args.instrumentClass,
155  skymapName=args.skymapName, skymapConfig=args.skymapConfig,
156  calibs=args.calibs, reruns=args.reruns, config=args.config, transferMode=args.transferMode)

◆ parse_args()

def convertGen2RepoToGen3.parse_args (   parser)

Definition at line 67 of file convertGen2RepoToGen3.py.

67 def parse_args(parser):
68  args = parser.parse_args()
69 
70  skymapList = [args.skymapName, args.skymapConfig]
71  if not all(x is None for x in skymapList) and not all(x is not None for x in skymapList):
72  parser.error("Must specify both --skymapName and --skymapConfig, or neither.")
73 
74  return args
75 
76 
lsst::log::Log::getLogger
static Log getLogger(Log const &logger)
Definition: Log.h:760
convertGen2RepoToGen3.parse_args
def parse_args(parser)
Definition: convertGen2RepoToGen3.py:67
lsst::geom::all
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
Definition: CoordinateExpr.h:81
convertGen2RepoToGen3.build_argparser
def build_argparser()
Definition: convertGen2RepoToGen3.py:36
convertGen2RepoToGen3.convert
def convert(gen2root, gen3root, instrumentClass, skymapName=None, skymapConfig=None, calibs=None, reruns=[], config=None, transferMode="auto")
Definition: convertGen2RepoToGen3.py:77
convertGen2RepoToGen3.main
def main()
Definition: convertGen2RepoToGen3.py:141
lsst::utils.doImport
Definition: doImport.py:1
lsst::log.log.logContinued.LogHandler
Definition: logContinued.py:307