LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
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