LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Classes | Functions
lsst.meas.algorithms.convertReferenceCatalog Namespace Reference

Classes

class  ConvertReferenceCatalogTask
 

Functions

def build_argparser ()
 
def run_convert (outputDir, configFile, fileglob)
 
def main ()
 

Function Documentation

◆ build_argparser()

def lsst.meas.algorithms.convertReferenceCatalog.build_argparser ( )
Construct an argument parser for the ``convertReferenceCatalog`` script.

Returns
-------
argparser : `argparse.ArgumentParser`
    The argument parser that defines the ``convertReferenceCatalog``
    command-line interface.

Definition at line 92 of file convertReferenceCatalog.py.

92 def build_argparser():
93  """Construct an argument parser for the ``convertReferenceCatalog`` script.
94 
95  Returns
96  -------
97  argparser : `argparse.ArgumentParser`
98  The argument parser that defines the ``convertReferenceCatalog``
99  command-line interface.
100  """
101  parser = argparse.ArgumentParser(
102  description=__doc__,
103  formatter_class=argparse.RawDescriptionHelpFormatter,
104  epilog='More information is available at https://pipelines.lsst.io.'
105  )
106  parser.add_argument("outputDir",
107  help="Path to write the output shard files, configs, and `ingest-files` table to.")
108  parser.add_argument("configFile",
109  help="File containing the ConvertReferenceCatalogConfig fields.")
110  # Use a "+"-list here, so we can produce a more useful error if the user
111  # uses an unquoted glob that gets shell expanded.
112  parser.add_argument("fileglob", nargs="+",
113  help="Quoted glob for the files to be read in and converted."
114  " Example (note required quotes to prevent shell expansion):"
115  ' "gaia_source/csv/GaiaSource*"')
116  return parser
117 
118 

◆ main()

def lsst.meas.algorithms.convertReferenceCatalog.main ( )

Definition at line 151 of file convertReferenceCatalog.py.

151 def main():
152  args = build_argparser().parse_args()
153  if len(args.fileglob) > 1:
154  raise RuntimeError("Final argument must be a quoted file glob, not a shell-expanded list of files.")
155  # Fileglob comes out as a length=1 list, so we can test it above.
156  run_convert(args.outputDir, args.configFile, args.fileglob[0])
def run_convert(outputDir, configFile, fileglob)

◆ run_convert()

def lsst.meas.algorithms.convertReferenceCatalog.run_convert (   outputDir,
  configFile,
  fileglob 
)
Run `ConvertReferenceCatalogTask` on the input arguments.

Parameters
----------
outputDir : `str`
    Path to write the output files to.
configFile : `str`
    File specifying the ``ConvertReferenceCatalogConfig`` fields.
fileglob : `str`
    Quoted glob for the files to be read in and converted.

Definition at line 119 of file convertReferenceCatalog.py.

119 def run_convert(outputDir, configFile, fileglob):
120  """Run `ConvertReferenceCatalogTask` on the input arguments.
121 
122  Parameters
123  ----------
124  outputDir : `str`
125  Path to write the output files to.
126  configFile : `str`
127  File specifying the ``ConvertReferenceCatalogConfig`` fields.
128  fileglob : `str`
129  Quoted glob for the files to be read in and converted.
130  """
131  # We have to initialize the logger manually when running from the commandline.
132  logging.basicConfig(level=logging.INFO, format="{name} {levelname}: {message}", style="{")
133 
134  config = ConvertReferenceCatalogTask.ConfigClass()
135  config.load(configFile)
136  config.validate()
137  converter = ConvertReferenceCatalogTask(output_dir=outputDir, config=config)
138  files = glob.glob(fileglob)
139  converter.run(files)
140  with open(os.path.join(outputDir, "convertReferenceCatalogConfig.py"), "w") as outfile:
141  converter.config.saveToStream(outfile)
142  msg = ("Completed refcat conversion."
143  " Ingest the resulting files with the following commands,"
144  " substituting the path to your butler repo for REPO:"
145  f"\n butler register-dataset-type REPO {config.dataset_config.ref_dataset_name} "
146  "SimpleCatalog htm7"
147  f"\n butler ingest-files -t direct REPO gaia_dr2 refcats {converter.ingest_table_file}")
148  print(msg)
149 
150